Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
dac06cc3
Commit
dac06cc3
authored
Jan 16, 2019
by
Martin Reinecke
Browse files
more docstrings
parent
55458cb3
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/multi_field.py
View file @
dac06cc3
...
...
@@ -213,6 +213,21 @@ class MultiField(object):
tuple
(
self
[
key
]
for
key
in
subset
.
keys
()))
def
unite
(
self
,
other
):
"""Merges two MultiFields on potentially different MultiDomains.
Parameters
----------
other : MultiField
the partner Field
Returns
-------
MultiField
This MultiField's domain is the union of the input fields'
domains. The values are the sum of the fields in self and other.
If a field is not present, it is assumed to have an uniform value
of zero.
"""
if
self
.
_domain
is
other
.
_domain
:
return
self
+
other
res
=
self
.
to_dict
()
...
...
@@ -249,6 +264,23 @@ class MultiField(object):
return
MultiField
.
from_dict
(
res
,
domain
)
def
flexible_addsub
(
self
,
other
,
neg
):
"""Merges two MultiFields on potentially different MultiDomains.
Parameters
----------
other : MultiField
the partner Field
neg : bool
if True, the partner field is subtracted, otherwise added
Returns
-------
MultiField
This MultiField's domain is the union of the input fields'
domains. The values are the sum (or difference, if neg==True) of
the fields in self and other. If a field is not present, it is
assumed to have an uniform value of zero.
"""
if
self
.
_domain
is
other
.
_domain
:
return
self
-
other
if
neg
else
self
+
other
res
=
self
.
to_dict
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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