Skip to content

Commit

Permalink
Merge pull request #28 from serengil/feat-task-0510-warning-message-f…
Browse files Browse the repository at this point in the history
…or-addition-of-tensors-with-different-signs

warning message addedfor addition of different signs in tensors
  • Loading branch information
serengil authored Oct 5, 2024
2 parents 8dcc9ae + 0a939c1 commit 2157de8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lightphe/models/Tensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from typing import Union, List
from lightphe.models.Homomorphic import Homomorphic
from lightphe.commons import phe_utils
from lightphe.commons.logger import Logger

logger = Logger(module="lightphe/models/Tensor.py")


# pylint: disable=too-few-public-methods, no-else-return
Expand Down Expand Up @@ -174,6 +177,12 @@ def __add__(self, other: "EncryptedTensor") -> "EncryptedTensor":
else:
# if one is positive and one is negative, then i cannot know
# the result is positive or negative. trust mod calculations.
if alpha_tensor.sign != beta_tensor.sign:
logger.warn(
f"{i}-th items of the vectors have different signs, and result's sign "
"cannot be determined in PHE. Result will be shown for positive for this anyway."
)

current_tensor = Fraction(
dividend=current_dividend,
abs_dividend=current_dividend,
Expand Down

0 comments on commit 2157de8

Please sign in to comment.