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

Draft unit test for shift inversion. Needs to be double checked.

parent 83e289d3
No related branches found
No related tags found
No related merge requests found
Pipeline #384714 failed
"""Unit tests for module shift_inversion_numpy"""
import numpy as np
import pytest
from lisainstrument.shift_inversion_numpy import make_shift_inverse_lagrange_numpy
def test_shift_inversion_numpy():
"""Test basic functioning of shift_inversion_numpy on analytic coordinate transform"""
order = 31
nsamp = 200
k_mod = 8 * np.pi
a_mod = 1e-3
max_it = 5
tol = 1e-10
def dx_from_x(x):
return np.sin(x * k_mod) * a_mod
xi, dt = np.linspace(0, 1, nsamp, retstep=True)
fsample = 1 / dt
dxi = dx_from_x(xi)
op_np = make_shift_inverse_lagrange_numpy(order, a_mod * 1.01, max_it, tol / dt)
ai_np = op_np(dxi, fsample)
ai_ex = dx_from_x(xi - ai_np)
valid_range = slice(op_np.margin_left, -op_np.margin_right)
assert ai_np[valid_range] == pytest.approx(ai_ex[valid_range], abs=tol, rel=0)
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