Commit 369354fc authored by Philipp Arras's avatar Philipp Arras
Browse files

Add subtraction mode to adder

parent 859c79be
Pipeline #50160 passed with stages
in 17 minutes and 50 seconds
...@@ -28,12 +28,15 @@ class Adder(Operator): ...@@ -28,12 +28,15 @@ class Adder(Operator):
field : Field or MultiField field : Field or MultiField
The field by which the input is shifted. The field by which the input is shifted.
""" """
def __init__(self, field): def __init__(self, field, neg=False):
if not isinstance(field, (Field, MultiField)): if not isinstance(field, (Field, MultiField)):
raise TypeError raise TypeError
self._field = field self._field = field
self._domain = self._target = field.domain self._domain = self._target = field.domain
self._neg = bool(neg)
def apply(self, x): def apply(self, x):
self._check_input(x) self._check_input(x)
if self._neg:
return x - self._field
return x + self._field return x + self._field
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment