Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
369354fc
Commit
369354fc
authored
May 29, 2019
by
Philipp Arras
Browse files
Add subtraction mode to adder
parent
859c79be
Pipeline
#50160
passed with stages
in 17 minutes and 50 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty5/operators/adder.py
View file @
369354fc
...
...
@@ -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
):
self
.
_check_input
(
x
)
if
self
.
_neg
:
return
x
-
self
.
_field
return
x
+
self
.
_field
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment