Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
cc59f4ba
Commit
cc59f4ba
authored
Feb 28, 2019
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
081deabf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
nifty5/operators/operator.py
nifty5/operators/operator.py
+7
-1
test/test_operators/test_simplification.py
test/test_operators/test_simplification.py
+5
-0
No files found.
nifty5/operators/operator.py
View file @
cc59f4ba
...
...
@@ -219,10 +219,16 @@ class _ConstantOperator(Operator):
def
apply
(
self
,
x
):
from
..linearization
import
Linearization
from
.simple_linear_operators
import
NullOperator
from
..domain_tuple
import
DomainTuple
self
.
_check_input
(
x
)
if
not
isinstance
(
x
,
Linearization
):
return
self
.
_output
return
x
.
new
(
self
.
_output
,
NullOperator
(
self
.
_domain
,
self
.
_target
))
if
x
.
want_metric
and
self
.
_target
is
DomainTuple
.
scalar_domain
():
met
=
NullOperator
(
self
.
_domain
,
self
.
_domain
)
else
:
met
=
None
return
x
.
new
(
self
.
_output
,
NullOperator
(
self
.
_domain
,
self
.
_target
),
met
)
def
__repr__
(
self
):
return
'ConstantOperator <- {}'
.
format
(
self
.
domain
.
keys
())
...
...
test/test_operators/test_simplification.py
View file @
cc59f4ba
...
...
@@ -48,3 +48,8 @@ def test_simplification():
assert_equal
(
isinstance
(
op2
.
_op1
,
_ConstantOperator
),
True
)
assert_allclose
(
op
(
f1
)[
"a"
].
local_data
,
op2
(
f1
)[
"a"
].
local_data
)
assert_allclose
(
op
(
f1
)[
"b"
].
local_data
,
op2
(
f1
)[
"b"
].
local_data
)
lin
=
ift
.
Linearization
.
make_var
(
ift
.
MultiField
.
full
(
op2
.
domain
,
2.
),
True
)
assert_allclose
(
op
(
lin
).
val
[
"a"
].
local_data
,
op2
(
lin
).
val
[
"a"
].
local_data
)
assert_allclose
(
op
(
lin
).
val
[
"b"
].
local_data
,
op2
(
lin
).
val
[
"b"
].
local_data
)
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