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
Neel Shah
NIFTy
Commits
b0946178
Commit
b0946178
authored
Nov 30, 2020
by
Philipp Arras
Browse files
Remove is_endo again
parent
fa08ba32
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/extra.py
View file @
b0946178
...
...
@@ -31,7 +31,7 @@ from .operators.linear_operator import LinearOperator
from
.operators.operator
import
Operator
from
.operators.scaling_operator
import
ScalingOperator
from
.probing
import
StatCalculator
from
.sugar
import
from_random
,
full
,
is_endo
,
is_fieldlike
,
is_operator
from
.sugar
import
from_random
,
full
,
is_fieldlike
,
is_operator
from
.utilities
import
myassert
__all__
=
[
"check_linear_operator"
,
"check_operator"
,
"assert_allclose"
,
"minisanity"
]
...
...
src/sugar.py
View file @
b0946178
...
...
@@ -38,7 +38,7 @@ from .plot import Plot
__all__
=
[
'PS_field'
,
'power_analyze'
,
'create_power_operator'
,
'create_harmonic_smoothing_operator'
,
'from_random'
,
'full'
,
'makeField'
,
'is_fieldlike'
,
'is_linearization'
,
'is_operator'
,
'is_endo'
,
'is_fieldlike'
,
'is_linearization'
,
'is_operator'
,
'makeDomain'
,
'get_signal_variance'
,
'makeOp'
,
'domain_union'
,
'get_default_codomain'
,
'single_plot'
,
'exec_time'
,
'calculate_position'
]
+
list
(
pointwise
.
ptw_dict
.
keys
())
...
...
@@ -559,22 +559,3 @@ def is_fieldlike(obj):
:class:`~nifty7.linearization.Linearization` behave field-like.
"""
return
isinstance
(
obj
,
Operator
)
and
obj
.
val
is
not
None
def
is_endo
(
obj
):
"""Check if object is an endomorphic (linear) operator.
Note
----
A simple `isinstance(obj, ift.EndomorphicOperator)` does not cover all
cases. One counter example would be an `ChainOperator` where the domain of
the first sub operator and target of the last sub operator coincide.
"""
from
.operators.endomorphic_operator
import
EndomorphicOperator
from
.operators.linear_operator
import
LinearOperator
return
isinstance
(
obj
,
EndomorphicOperator
)
or
(
is_operator
(
obj
)
and
isinstance
(
obj
,
LinearOperator
)
and
obj
.
domain
==
obj
.
target
)
test/test_sugar.py
View file @
b0946178
...
...
@@ -85,16 +85,3 @@ def test_isinstance_helpers():
assert
ift
.
is_operator
(
op
)
assert
not
ift
.
is_operator
(
lin
)
assert
not
ift
.
is_operator
(
fld
)
assert
ift
.
is_endo
(
op
)
assert
not
ift
.
is_endo
(
lin
)
assert
not
ift
.
is_endo
(
fld
)
def
test_isendo
():
dom
=
ift
.
RGSpace
(
12
,
harmonic
=
True
)
op
=
ift
.
FFTOperator
(
dom
)
assert
not
ift
.
is_endo
(
op
)
assert
not
ift
.
is_endo
(
op
.
inverse
)
assert
not
ift
.
is_endo
(
op
.
adjoint
)
assert
ift
.
is_endo
(
op
@
op
.
adjoint
)
assert
ift
.
is_endo
(
op
@
op
.
inverse
)
Write
Preview
Supports
Markdown
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