Commit 304d4dc4 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

fixes and more tests

parent 59bf1166
Pipeline #29519 passed with stages
in 3 minutes and 57 seconds
......@@ -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):
foo = from_random("normal",, 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):
......@@ -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
assert_equal(type(op2), ift.BlockDiagonalOperator)
f1 = op2(ift.full(dom, 1))
for val in f1.values():
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment