Skip to content

Commit

Permalink
warning message addedfor addition of different signs in tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
serengil committed Oct 5, 2024
1 parent 8dcc9ae commit 8f6a3f4
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 8f6a3f4

Please sign in to comment.