Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning message addedfor addition of different signs in tensors #28

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading