Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dpti/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def integrate_range_simpson(xx, yy, ye):
# error esti series 0
xx0, inte0, stat_err0 = _integrate_range_simpson_inner(xx, yy, ye)
if len(xx) < 5:
return xx0, inte0, stat_err0, np.zeros(xx0.shape)
return xx0, inte0, np.zeros(xx0.shape), stat_err0
xx1, inte1, stat_err1 = _integrate_range_simpson_inner(xx[::2], yy[::2], ye[::2])
diff1 = np.abs(inte1 - inte0[::2]) / 16.0
assert np.linalg.norm(xx1 - xx0[::2]) < 1e-10
Expand Down
13 changes: 13 additions & 0 deletions tests/test_lib_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ def test_lamb_array_even(self):
self.assertAlmostEqual(stt_err1, stt_err2, places=8)
self.assertAlmostEqual(sys_err2, sys_err2, places=8)

def test_short_simpson_range_preserves_error_order(self):
"""Short Simpson ranges report statistical error in the second slot."""
lambdas = np.array([0.0, 0.5, 1.0])
values = lambdas**2
errors = np.full_like(values, 0.1)

_, stat_err, integration_err = integrate_range_hti(
lambdas, values, errors, scheme="simpson"
)

self.assertGreater(stat_err, 0.0)
self.assertEqual(integration_err, 0.0)


class TestRelativeLinkFile(unittest.TestCase):
@classmethod
Expand Down
Loading