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
25275186
Commit
25275186
authored
Oct 06, 2018
by
Martin Reinecke
Browse files
factor out common code
parent
db3e0bfa
Changes
2
Hide whitespace changes
Inline
Side-by-side
nifty5/operators/linear_operator.py
View file @
25275186
...
...
@@ -259,10 +259,4 @@ class LinearOperator(Operator):
def
_check_input
(
self
,
x
,
mode
):
self
.
_check_mode
(
mode
)
if
self
.
_dom
(
mode
)
!=
x
.
domain
:
s
=
"The operator's and field's domains don't match."
from
..domain_tuple
import
DomainTuple
from
..multi_domain
import
MultiDomain
if
not
isinstance
(
self
.
_dom
(
mode
),
[
DomainTuple
,
MultiDomain
]):
s
+=
" Your operator's domain is neither a `DomainTuple` nor a `MultiDomain`."
raise
ValueError
(
s
)
self
.
_check_domain_equality
(
self
.
_dom
(
mode
),
x
.
domain
)
nifty5/operators/operator.py
View file @
25275186
...
...
@@ -23,6 +23,17 @@ class Operator(NiftyMetaBase()):
The domain on which the Operator's output Field lives."""
return
self
.
_target
@
staticmethod
def
_check_domain_equality
(
dom_op
,
dom_field
):
if
dom_op
!=
dom_field
:
s
=
"The operator's and field's domains don't match."
from
..domain_tuple
import
DomainTuple
from
..multi_domain
import
MultiDomain
if
not
isinstance
(
dom_op
,
[
DomainTuple
,
MultiDomain
]):
s
+=
" Your operator's domain is neither a `DomainTuple`"
\
" nor a `MultiDomain`."
raise
ValueError
(
s
)
def
scale
(
self
,
factor
):
if
factor
==
1
:
return
self
...
...
@@ -66,13 +77,7 @@ class Operator(NiftyMetaBase()):
def
_check_input
(
self
,
x
):
from
..linearization
import
Linearization
d
=
x
.
target
if
isinstance
(
x
,
Linearization
)
else
x
.
domain
if
self
.
_domain
!=
d
:
s
=
"The operator's and field's domains don't match."
from
..domain_tuple
import
DomainTuple
from
..multi_domain
import
MultiDomain
if
not
isinstance
(
self
.
_dom
(
mode
),
[
DomainTuple
,
MultiDomain
]):
s
+=
" Your operator's domain is neither a `DomainTuple` nor a `MultiDomain`."
raise
ValueError
(
s
)
self
.
_check_domain_equality
(
self
.
_domain
,
d
)
def
__call__
(
self
,
x
):
if
isinstance
(
x
,
Operator
):
...
...
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