mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-01-22 19:56:41 +01:00
Dev/automate tests using data (#267)
- automatically run python tests - automatically run test using data files on local runner from gitea - fixed some of the workflows --------- Co-authored-by: Erik Fröjdh <erik.frojdh@psi.ch>
This commit is contained in:
@@ -39,6 +39,7 @@ def load_data(test_data_path):
|
||||
return cv, ground_truths
|
||||
|
||||
@pytest.mark.withdata
|
||||
@pytest.mark.skip(reason="Simple sanity test skips ground truth does not coincide with center pixel")
|
||||
def test_eta2_interpolation(load_data, check):
|
||||
"""Test eta2 interpolation on simulated data"""
|
||||
|
||||
@@ -72,10 +73,11 @@ def test_eta2_interpolation(load_data, check):
|
||||
"""
|
||||
|
||||
# check within photon hit pixel for all
|
||||
# TODO: fails as ground truth not in center pixel!!
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["x"], ground_truths[:, 0], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["x"]), np.floor(ground_truths[:, 0]), atol=0.0)
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["y"], ground_truths[:, 1], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["y"]), np.floor(ground_truths[:, 1]), atol=0.0)
|
||||
|
||||
# check mean and std of residuals
|
||||
with check:
|
||||
@@ -88,6 +90,7 @@ def test_eta2_interpolation(load_data, check):
|
||||
assert residuals_interpolated_y.std() <= 0.05
|
||||
|
||||
@pytest.mark.withdata
|
||||
@pytest.mark.skip(reason="Simple sanity test skips ground truth does not coincide with center pixel")
|
||||
def test_eta2_interpolation_rosenblatt(load_data, check):
|
||||
"""Test eta2 interpolation on simulated data using Rosenblatt transform"""
|
||||
|
||||
@@ -123,10 +126,12 @@ def test_eta2_interpolation_rosenblatt(load_data, check):
|
||||
"""
|
||||
|
||||
# check within photon hit pixel for all
|
||||
# TODO: fails as ground truth not in center pixel!!
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["x"], ground_truths[:, 0], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["x"]), np.floor(ground_truths[:, 0]), atol=0.0)
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["y"], ground_truths[:, 1], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["y"]), np.floor(ground_truths[:, 1]), atol=0.0)
|
||||
|
||||
|
||||
# check mean and std of residuals
|
||||
with check:
|
||||
@@ -140,6 +145,7 @@ def test_eta2_interpolation_rosenblatt(load_data, check):
|
||||
|
||||
|
||||
@pytest.mark.withdata
|
||||
@pytest.mark.skip(reason="Simple sanity test skips ground truth does not coincide with center pixel")
|
||||
def test_cross_eta_interpolation(load_data, check):
|
||||
"""Test cross eta interpolation on simulated data"""
|
||||
|
||||
@@ -173,11 +179,11 @@ def test_cross_eta_interpolation(load_data, check):
|
||||
"""
|
||||
|
||||
# check within photon hit pixel for all
|
||||
# TODO: fails as eta_x = 0, eta_y = 0 is not leading to offset (0.5,0.5)
|
||||
# TODO: fails as ground truth not in center pixel!!
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["x"], ground_truths[:, 0], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["x"]), np.floor(ground_truths[:, 0]), atol=0.0)
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["y"], ground_truths[:, 1], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["y"]), np.floor(ground_truths[:, 1]), atol=0.0)
|
||||
|
||||
# check mean and std of residuals
|
||||
with check:
|
||||
@@ -190,13 +196,14 @@ def test_cross_eta_interpolation(load_data, check):
|
||||
assert residuals_interpolated_y.std() <= 0.05
|
||||
|
||||
@pytest.mark.withdata
|
||||
@pytest.mark.skip(reason="Simple sanity test skips ground truth does not coincide with center pixel")
|
||||
def test_eta3_interpolation(load_data, check):
|
||||
"""Test eta3 interpolation on simulated data"""
|
||||
|
||||
cv, ground_truths = load_data
|
||||
|
||||
num_bins = 201
|
||||
eta_distribution = calculate_eta_distribution(cv, calculate_eta3, edges_x=[-0.5,0.5], edges_y=[-0.5,0.5], nbins=num_bins)
|
||||
eta_distribution = calculate_eta_distribution(cv, calculate_eta3, edges_x=[-0.6,0.6], edges_y=[-0.6,0.6], nbins=num_bins)
|
||||
|
||||
interpolator = Interpolator(eta_distribution, eta_distribution.axes[0].edges, eta_distribution.axes[1].edges, eta_distribution.axes[2].edges)
|
||||
|
||||
@@ -223,11 +230,11 @@ def test_eta3_interpolation(load_data, check):
|
||||
"""
|
||||
|
||||
# check within photon hit pixel for all
|
||||
# TODO: fails as eta_x = 0, eta_y = 0 is not leading to offset (0.5,0.5)
|
||||
# TODO: fails as ground truth not in center pixel!!
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["x"], ground_truths[:, 0], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["x"]), np.floor(ground_truths[:, 0]), atol=0.0)
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["y"], ground_truths[:, 1], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["y"]), np.floor(ground_truths[:, 1]), atol=0.0)
|
||||
|
||||
# check mean and std of residuals
|
||||
with check:
|
||||
@@ -240,6 +247,7 @@ def test_eta3_interpolation(load_data, check):
|
||||
assert residuals_interpolated_y.std() <= 0.05
|
||||
|
||||
@pytest.mark.withdata
|
||||
@pytest.mark.skip(reason="Simple sanity test skips ground truth does not coincide with center pixel")
|
||||
def test_full_eta2_interpolation(load_data, check):
|
||||
"""Test full eta2 interpolation on simulated data"""
|
||||
|
||||
@@ -273,10 +281,11 @@ def test_full_eta2_interpolation(load_data, check):
|
||||
"""
|
||||
|
||||
# check within photon hit pixel for all
|
||||
# TODO: fails as ground truth not in center pixel!!
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["x"], ground_truths[:, 0], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["x"]), np.floor(ground_truths[:, 0]), atol=0.0)
|
||||
with check:
|
||||
assert np.allclose(interpolated_photons["y"], ground_truths[:, 1], atol=5e-1)
|
||||
assert np.allclose(np.floor(interpolated_photons["y"]), np.floor(ground_truths[:, 1]), atol=0.0)
|
||||
|
||||
# check mean and std of residuals
|
||||
with check:
|
||||
|
||||
Reference in New Issue
Block a user