Skip to content
Snippets Groups Projects
Commit fe134693 authored by Wolfgang Kastaun's avatar Wolfgang Kastaun
Browse files

Update shift inversion unit tests to interface change and use more realistic parameters

Made test stricter. The previous parameters used a maximum shift too small to increase
the required margin size, thus not testing anything related to its size.
parent 23c6811e
No related branches found
No related tags found
No related merge requests found
...@@ -8,28 +8,43 @@ from lisainstrument.shift_inversion_dask import make_shift_inverse_lagrange_dask ...@@ -8,28 +8,43 @@ from lisainstrument.shift_inversion_dask import make_shift_inverse_lagrange_dask
from lisainstrument.shift_inversion_numpy import make_shift_inverse_lagrange_numpy from lisainstrument.shift_inversion_numpy import make_shift_inverse_lagrange_numpy
def test_shift_inversion_numpy(): def test_shift_inversion_dask():
"""Test basic functioning of shift_inversion_dask on analytic coordinate transform""" """Test basic functioning of shift_inversion_dask on analytic coordinate transform"""
order = 31
nsamp = 600
chunks = 70 chunks = 70
k_mod = 8 * np.pi order = 31
a_mod = 1e-3 nsamp = 3000
max_it = 6 fsample = 16.0
tol = 1e-12 dt = 1 / fsample
f_mod = 0.005
a_mod = 1e-2 / (2 * np.pi * f_mod)
max_it = 5
tol = 1e-10
def dx_from_x(x): def dx_from_x(x):
return np.sin(x * k_mod) * a_mod return np.sin(2 * np.pi * f_mod * x) * a_mod
xi = np.arange(nsamp) * dt
xi, dt = np.linspace(0, 1, nsamp, retstep=True)
fsample = 1 / dt
dxi = dx_from_x(xi) dxi = dx_from_x(xi)
op_np = make_shift_inverse_lagrange_numpy(order, a_mod * 1.01 / dt, max_it, tol) op_np = make_shift_inverse_lagrange_numpy(
op_da = make_shift_inverse_lagrange_dask(order, a_mod * 1.01 / dt, max_it, tol) order=order,
fsample=fsample,
max_abs_shift=a_mod * 1.01,
max_iter=max_it,
tolerance=tol,
)
op_da = make_shift_inverse_lagrange_dask(
order=order,
fsample=fsample,
max_abs_shift=a_mod * 1.01,
max_iter=max_it,
tolerance=tol,
)
op_na = numpyfy_dask_multi(op_da, chunks) op_na = numpyfy_dask_multi(op_da, chunks)
ai_np = op_np(dxi, fsample) ai_np = op_np(dxi)
ai_na = op_na(dxi, fsample) ai_na = op_na(dxi)
assert ai_np == pytest.approx(ai_na, abs=tol, rel=0) assert ai_np == pytest.approx(ai_na, abs=tol, rel=0)
...@@ -9,22 +9,30 @@ from lisainstrument.shift_inversion_numpy import make_shift_inverse_lagrange_num ...@@ -9,22 +9,30 @@ from lisainstrument.shift_inversion_numpy import make_shift_inverse_lagrange_num
def test_shift_inversion_numpy(): def test_shift_inversion_numpy():
"""Test basic functioning of shift_inversion_numpy on analytic coordinate transform""" """Test basic functioning of shift_inversion_numpy on analytic coordinate transform"""
order = 31 order = 31
nsamp = 200 nsamp = 3000
k_mod = 8 * np.pi fsample = 16.0
a_mod = 1e-3 dt = 1 / fsample
f_mod = 0.005
a_mod = 1e-2 / (2 * np.pi * f_mod)
max_it = 5 max_it = 5
tol = 1e-10 tol = 1e-10
def dx_from_x(x): def dx_from_x(x):
return np.sin(x * k_mod) * a_mod return np.sin(2 * np.pi * f_mod * x) * a_mod
xi, dt = np.linspace(0, 1, nsamp, retstep=True) xi = np.arange(nsamp) * dt
fsample = 1 / dt
dxi = dx_from_x(xi) dxi = dx_from_x(xi)
op_np = make_shift_inverse_lagrange_numpy(order, a_mod * 1.01 / dt, max_it, tol) op_np = make_shift_inverse_lagrange_numpy(
order=order,
fsample=fsample,
max_abs_shift=a_mod * 1.01,
max_iter=max_it,
tolerance=tol,
)
ai_np = op_np(dxi, fsample) ai_np = op_np(dxi)
ai_ex = dx_from_x(xi - ai_np) ai_ex = dx_from_x(xi - ai_np)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment