Skip to content

Commit

Permalink
Merge pull request #32 from uncountableinc/catherine/fix-tensor-input-ne
Browse files Browse the repository at this point in the history
allow tensor inputs to not equals
  • Loading branch information
leb2 authored Oct 27, 2023
2 parents e0c43f5 + 0cec58e commit 9c735d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions hotxlfp/formulas/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def __eq__(self, other):
if type(self.value) != type(other):
other = self.convert_other(other)
return self.value == other

def __ne__(self, other):
return torch.logical_not(self.__eq__(other))

def __ge__(self, other):
return torch.logical_or(self.__gt__(other), self.__eq__(other))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="hotxlfp",
version="0.0.11+unc.28",
version="0.0.11+unc.29",
packages=[
"hotxlfp",
"hotxlfp._compat",
Expand Down
4 changes: 4 additions & 0 deletions tests/test_formula_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ def test_tensors(self):
_test_equation(equation="CEILING(a1, a2)", variables={"a1": [0.5, 0.5], "a2": [1, 2]}, answer=[1, 2])
_test_equation(equation="CEILING(a1, a2)", variables={"a1": [0.5, 0.5], "a2": [2]}, answer=[2, 2])
_test_equation(equation="CEILING(a1, a2)", variables={"a1": [0.5], "a2": [1]}, answer=[1])
_test_equation(equation="IF(a1 <> a2, 1, 0)", variables={"a1": [3, 2], "a2": [3, 3]}, answer=[0, 1])
_test_equation(equation="IF(a1 <> a2, 1, 0)", variables={"a1": 4, "a2": 2}, answer=1)
_test_equation(equation="IF(a1 < a2, 1, 0)", variables={"a1": [1, 2], "a2": [0, 0]}, answer=[0, 0])
_test_equation(equation="IF(a1 < a2, 1, 0)", variables={"a1": 2, "a2": 3}, answer=1)

def test_scientific_notation(self):
_test_equation(equation="2e2", variables={"a1" : [1.1]}, answer=[200])
Expand Down

0 comments on commit 9c735d3

Please sign in to comment.