Commit de7c2aba authored by Martin Reinecke's avatar Martin Reinecke
Browse files

nastier tests

parent c15eb016
Pipeline #23740 failed with stage
in 4 minutes and 5 seconds
......@@ -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)
......@@ -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):
......
Markdown is supported
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