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
304d4dc4
Commit
304d4dc4
authored
May 21, 2018
by
Martin Reinecke
Browse files
fixes and more tests
parent
59bf1166
Pipeline
#29519
passed with stages
in 3 minutes and 57 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty4/extra/operator_tests.py
View file @
304d4dc4
...
...
@@ -18,10 +18,18 @@
import
numpy
as
np
from
..sugar
import
from_random
from
..field
import
Field
__all__
=
[
"consistency_check"
]
def
_assert_allclose
(
f1
,
f2
,
atol
,
rtol
):
if
isinstance
(
f1
,
Field
):
return
np
.
testing
.
assert_allclose
(
f1
.
local_data
,
f2
.
local_data
,
atol
=
atol
,
rtol
=
rtol
)
for
key
,
val
in
f1
.
items
():
_assert_allclose
(
val
,
f2
[
key
],
atol
=
atol
,
rtol
=
rtol
)
def
adjoint_implementation
(
op
,
domain_dtype
,
target_dtype
,
atol
,
rtol
):
needed_cap
=
op
.
TIMES
|
op
.
ADJOINT_TIMES
if
(
op
.
capability
&
needed_cap
)
!=
needed_cap
:
...
...
@@ -39,13 +47,11 @@ def inverse_implementation(op, domain_dtype, target_dtype, atol, rtol):
return
foo
=
from_random
(
"normal"
,
op
.
target
,
dtype
=
target_dtype
).
lock
()
res
=
op
(
op
.
inverse_times
(
foo
).
lock
())
np
.
testing
.
assert_allclose
(
res
.
to_global_data
(),
res
.
to_global_data
(),
atol
=
atol
,
rtol
=
rtol
)
_assert_allclose
(
res
,
foo
,
atol
=
atol
,
rtol
=
rtol
)
foo
=
from_random
(
"normal"
,
op
.
domain
,
dtype
=
domain_dtype
).
lock
()
res
=
op
.
inverse_times
(
op
(
foo
).
lock
())
np
.
testing
.
assert_allclose
(
res
.
to_global_data
(),
foo
.
to_global_data
(),
atol
=
atol
,
rtol
=
rtol
)
_assert_allclose
(
res
,
foo
,
atol
=
atol
,
rtol
=
rtol
)
def
full_implementation
(
op
,
domain_dtype
,
target_dtype
,
atol
,
rtol
):
...
...
test/test_multi_field.py
View file @
304d4dc4
...
...
@@ -55,6 +55,7 @@ class Test_Functionality(unittest.TestCase):
def
test_blockdiagonal
(
self
):
op
=
ift
.
BlockDiagonalOperator
({
"d1"
:
ift
.
ScalingOperator
(
20.
,
dom
[
"d1"
])})
op2
=
op
*
op
ift
.
extra
.
consistency_check
(
op2
)
assert_equal
(
type
(
op2
),
ift
.
BlockDiagonalOperator
)
f1
=
op2
(
ift
.
full
(
dom
,
1
))
for
val
in
f1
.
values
():
...
...
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