Skip to content

Commit

Permalink
add test for #45
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Ludwig committed Nov 21, 2024
1 parent 5bcfffa commit 4bc2756
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,17 @@ def test_GlobalSplineFit_similar(gsf):
assert f == pytest.approx(f_gsf, rel=0.4)


@pytest.mark.parametrize("gsf", gsfmodels)
def test_GlobalSplineFIt_negative(gsf):
"""
Since GSF was using a cubic spline, it could oscillate a bit between the interpolated data point.
This was noticed due to a very minor undershoot below zero for protons at high energies.
So here we explicitly test that we only return non-negative values.
"""
test_e = np.geomspace(9.95e10, 10e10, 9)
flux = gsf(*np.meshgrid(test_e, gsf.pdgids))
assert np.all(flux >= 0)


if __name__ == "__main__":
sys.exit(pytest.main(["-v", __file__, *sys.argv[1:]]))

0 comments on commit 4bc2756

Please sign in to comment.