Skip to content

Commit

Permalink
Add test for empty edisp slice
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Oct 27, 2023
1 parent 8cf972b commit 9a4baa1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pyirf/benchmarks/tests/test_bias_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def test_energy_bias_resolution():
assert u.isclose(resolution[1], TRUE_RES_2, rtol=0.05)



def test_energy_bias_resolution():
from pyirf.benchmarks import energy_bias_resolution_from_energy_dispersion
from pyirf.binning import bin_center
Expand Down Expand Up @@ -115,3 +114,16 @@ def test_energy_bias_resolution():

assert np.allclose(bias, true_bias, atol=0.01)
assert np.allclose(resolution, true_resolution, atol=0.01)

with_empty = np.zeros((n_energy_bins + 1, n_migra_bins, n_fov_bins))
with_empty[1:, :, :] = edisp

bias, resolution = energy_bias_resolution_from_energy_dispersion(
with_empty,
migra_bins,
)

assert np.all(np.isnan(bias[0]))
assert np.all(np.isnan(resolution[0]))
assert np.allclose(bias[1:], true_bias, atol=0.01)
assert np.allclose(resolution[1:], true_resolution, atol=0.01)

0 comments on commit 9a4baa1

Please sign in to comment.