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):
field : Field or MultiField
The field by which the input is shifted.
def __init__(self, field):
def __init__(self, field, neg=False):
if not isinstance(field, (Field, MultiField)):
raise TypeError
self._field = field
self._domain = self._target = field.domain
self._neg = bool(neg)
def apply(self, x):
if self._neg:
return x - self._field
return x + self._field
Supports Markdown
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