feat: add neg support to BaseTracer

closes #853
This commit is contained in:
Arthur Meyre
2021-11-09 16:07:24 +01:00
parent 4237b9df32
commit 565756810d
2 changed files with 4 additions and 0 deletions

View File

@@ -122,6 +122,9 @@ class BaseTracer(ABC):
# some changes
__radd__ = __add__
def __neg__(self) -> "BaseTracer":
return 0 - self
def __sub__(self, other: Union["BaseTracer", Any]) -> "BaseTracer":
if not self._supports_other_operand(other):
return NotImplemented

View File

@@ -513,6 +513,7 @@ def test_compile_function_multiple_outputs(
pytest.param(lambda x, y: x + y + 64, ((0, 20), (0, 20)), ["x", "y"]),
pytest.param(lambda x, y: 100 - y + x, ((0, 20), (0, 20)), ["x", "y"]),
pytest.param(lambda x, y: 50 - y * 2 + x, ((0, 20), (0, 20)), ["x", "y"]),
pytest.param(lambda x: -x + 50, ((0, 20),), ["x"]),
],
)
def test_compile_and_run_correctness(