diff --git a/test/test_operators/test_adjoint.py b/test/test_operators/test_adjoint.py index 0a0c4b278e789d4ee3a39f686ac469468e1b4196..124588bd5dc48ebe4406baaeba7763a345c93110 100644 --- a/test/test_operators/test_adjoint.py +++ b/test/test_operators/test_adjoint.py @@ -9,8 +9,17 @@ from numpy.testing import assert_allclose def _check_adjointness(op, dtype=np.float64): f1 = ift.Field.from_random("normal", domain=op.domain, dtype=dtype) f2 = ift.Field.from_random("normal", domain=op.target, dtype=dtype) - assert_allclose(f1.vdot(op.adjoint_times(f2)), op.times(f1).vdot(f2), - rtol=1e-8) + cap = op.capability + if ((cap & ift.LinearOperator.TIMES) and + (cap & ift.LinearOperator.ADJOINT_TIMES)): + assert_allclose(f1.vdot(op.adjoint_times(f2)), + op.times(f1).vdot(f2), + rtol=1e-8) + if ((cap & ift.LinearOperator.INVERSE_TIMES) and + (cap & ift.LinearOperator.INVERSE_ADJOINT_TIMES)): + assert_allclose(f1.vdot(op.inverse_times(f2)), + op.inverse_adjoint_times(f1).vdot(f2), + rtol=1e-8) _harmonic_spaces = [ift.RGSpace(7, distances=0.2, harmonic=True), ift.RGSpace((12, 46), distances=(0.2, 0.3), harmonic=True), @@ -41,3 +50,5 @@ class Adjointness_Tests(unittest.TestCase): def testFFT(self, sp, dtype): op = ift.FFTOperator(sp) _check_adjointness(op, dtype) + op = ift.FFTOperator(sp.get_default_codomain()) + _check_adjointness(op, dtype) diff --git a/test/test_operators/test_fft_operator.py b/test/test_operators/test_fft_operator.py index 63ba59cb6e5d80cb7ecb33f0e8377685e0f9a918..95052965ea0235242d3dd6c544d69c682ea55ce6 100644 --- a/test/test_operators/test_fft_operator.py +++ b/test/test_operators/test_fft_operator.py @@ -39,9 +39,18 @@ class FFTOperatorTests(unittest.TestCase): tol = _get_rtol(itp) a = ift.RGSpace(dim1, distances=d) b = ift.RGSpace(dim1, distances=1./(dim1*d), harmonic=True) + np.random.seed(16) + fft = ift.FFTOperator(domain=a, target=b) + inp = ift.Field.from_random(domain=a, random_type='normal', + std=7, mean=3, dtype=itp) + out = fft.inverse_times(fft.times(inp)) + assert_allclose(ift.dobj.to_global_data(inp.val), + ift.dobj.to_global_data(out.val), rtol=tol, atol=tol) - np.random.seed(16) + a, b = b, a + + fft = ift.FFTOperator(domain=a, target=b) inp = ift.Field.from_random(domain=a, random_type='normal', std=7, mean=3, dtype=itp) out = fft.inverse_times(fft.times(inp)) @@ -56,8 +65,18 @@ class FFTOperatorTests(unittest.TestCase): a = ift.RGSpace([dim1, dim2], distances=[d1, d2]) b = ift.RGSpace([dim1, dim2], distances=[1./(dim1*d1), 1./(dim2*d2)], harmonic=True) + + fft = ift.FFTOperator(domain=a, target=b) + inp = ift.Field.from_random(domain=a, random_type='normal', + std=7, mean=3, dtype=itp) + out = fft.inverse_times(fft.times(inp)) + assert_allclose(ift.dobj.to_global_data(inp.val), + ift.dobj.to_global_data(out.val), rtol=tol, atol=tol) fft = ift.FFTOperator(domain=a, target=b) + a, b = b, a + + fft = ift.FFTOperator(domain=a, target=b) inp = ift.Field.from_random(domain=a, random_type='normal', std=7, mean=3, dtype=itp) out = fft.inverse_times(fft.times(inp)) @@ -132,6 +151,7 @@ class FFTOperatorTests(unittest.TestCase): assert_allclose(v1, v2, rtol=tol, atol=tol) @expand(product([ift.RGSpace(128, distances=3.76, harmonic=True), + ift.RGSpace(73, distances=0.5643), ift.LMSpace(lmax=30, mmax=25)], [np.float64, np.float32, np.complex64, np.complex128])) def test_normalisation(self, space, tp):