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

minor updates in unit test

parent e6ae24cf
No related branches found
No related tags found
No related merge requests found
......@@ -4,16 +4,16 @@ import pytest
from lisainstrument.dynamic_delay_dask import (
make_dynamic_shift_lagrange_dask,
make_dynamic_shift_linear_dask,
numpyfy_dask_bivariate,
numpyfy_dask_multi,
)
from lisainstrument.dynamic_delay_numpy import (
DynShiftBC,
make_dynamic_shift_lagrange_numpy,
make_lagrange_polynomials,
)
from lisainstrument.regular_interpolators import make_lagrange_polynomials
def test_dynamic_shift_linear_dask():
def test_dynamic_shift_linear_dask() -> None:
t, dt = np.linspace(-5.345, 10.345, 103, retstep=True)
def g(x):
......@@ -28,7 +28,7 @@ def test_dynamic_shift_linear_dask():
op_da = make_dynamic_shift_linear_dask(
d.min(), d.max(), DynShiftBC.FLAT, DynShiftBC.EXCEPTION
)
op_np = numpyfy_dask_bivariate(op_da, chunks=19)
op_np = numpyfy_dask_multi(op_da, chunks=19)
s_da = op_np(y, d)
s_ex = g(np.maximum(t[0], t - d * dt))
......@@ -36,28 +36,32 @@ def test_dynamic_shift_linear_dask():
assert s_ex == pytest.approx(s_da, abs=1e-15, rel=1e-14)
def test_dynamic_shift_lagrange_dask():
def test_dynamic_shift_lagrange_dask() -> None:
order = 5
length = order + 1
t, dt = np.linspace(-5.345, 10.345, 1003, retstep=True)
def g(x):
n = x / 10.0
return 4.32546 + 3.34324 * x + 4.342 * x**2 + 0.46 * x**3 + 1.43598 * x**4 + 3.3456 * x**5
return (
4.32546
+ 3.34324 * x
+ 4.342 * x**2
+ 0.46 * x**3
+ 1.43598 * x**4
+ 3.3456 * x**5
)
y = g(t)
d = (0.93456456 + 0.0235345 * np.cos(4.3354 * t)) / dt
# ~ print(y[0], t[0], d[0])
op_da = make_dynamic_shift_lagrange_dask(
length, d.min(), d.max(), DynShiftBC.FLAT, DynShiftBC.EXCEPTION
)
op_na = numpyfy_dask_bivariate(op_da, chunks=19)
op_na = numpyfy_dask_multi(op_da, chunks=19)
s_da = op_na(y, d)
s_da: np.ndarray = op_na(y, d)
s_ex = g(np.maximum(t[0], t - d * dt))
assert s_ex[op_da.margin_left :] == pytest.approx(
......@@ -73,6 +77,7 @@ def test_dynamic_shift_lagrange_dask():
assert np.all(s_np == s_da)
def test_lagrange_polynomials():
length = 11
d = -(length // 2)
......
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