Skip to content
GitLab
Menu
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
7d9e2eba
Commit
7d9e2eba
authored
Nov 09, 2020
by
Philipp Arras
Browse files
Use nifty operator logic
parent
1d299991
Pipeline
#86090
passed with stages
in 13 minutes and 44 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/sugar.py
View file @
7d9e2eba
...
...
@@ -539,12 +539,12 @@ def is_operator(obj):
result because, e.g., :class:`~nifty7.field.Field` inherits from
:class:`~nifty7.operators.operator.Operator`.
"""
return
isinstance
(
obj
,
Operator
)
and
obj
.
val
is
None
and
obj
.
jac
is
None
return
isinstance
(
obj
,
Operator
)
and
obj
.
val
is
None
def
is_linearization
(
obj
):
"""Checks if object is linearization-like."""
return
isinstance
(
obj
,
Operator
)
and
obj
.
val
is
not
None
and
obj
.
jac
is
not
None
return
isinstance
(
obj
,
Operator
)
and
obj
.
jac
is
not
None
def
is_fieldlike
(
obj
):
...
...
@@ -555,6 +555,7 @@ def is_fieldlike(obj):
A simple `isinstance(obj, ift.Field)` does give the expected
result because users might have implemented another class which
behaves field-like but is not an instance of
:class:`~nifty7.field.Field`.
:class:`~nifty7.field.Field`. Also not that instances of
:class:`~nifty7.linearization.Linearization` behave field-like.
"""
return
isinstance
(
obj
,
Operator
)
and
obj
.
val
is
not
None
and
obj
.
jac
is
None
return
isinstance
(
obj
,
Operator
)
and
obj
.
val
is
not
None
test/test_sugar.py
View file @
7d9e2eba
...
...
@@ -77,7 +77,7 @@ def test_isinstance_helpers():
fld
=
ift
.
full
(
dom
,
0.
)
lin
=
ift
.
Linearization
.
make_var
(
fld
)
assert
not
ift
.
is_fieldlike
(
op
)
assert
not
ift
.
is_fieldlike
(
lin
)
assert
ift
.
is_fieldlike
(
lin
)
assert
ift
.
is_fieldlike
(
fld
)
assert
not
ift
.
is_linearization
(
op
)
assert
ift
.
is_linearization
(
lin
)
...
...
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