Skip to content

Commit a8771ad

Browse files
cailmdaleyclaude
andcommitted
test: pin inverse converters and nonpositive-T contract; author email
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent fc9580b commit a8771ad

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

cs_util/size.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
producers (ShapePipe) and consumers (sp_validation) should import
1818
from here rather than re-deriving the factors locally.
1919
20-
:Author: Cail Daley
20+
:Author: Cail Daley <cailmdaley@gmail.com>
2121
2222
"""
2323

cs_util/tests/test_size.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ def test_T_to_r50_closed_form(self):
5151
T = np.array([0.05, 0.18, 2.0, 10.0])
5252
npt.assert_allclose(size.T_to_r50(T), np.sqrt(np.log(2) * T))
5353

54+
def test_inverse_direct_values(self):
55+
"""Test each inverse converter directly on the unit-sigma case."""
56+
npt.assert_almost_equal(size.r50_to_sigma(self._r50), self._sigma)
57+
npt.assert_almost_equal(size.fwhm_to_sigma(self._fwhm), self._sigma)
58+
npt.assert_almost_equal(size.r50_to_T(self._r50), self._T)
59+
60+
def test_nonpositive_T(self):
61+
"""Test that T = 0 maps to size 0 and negative T to NaN."""
62+
npt.assert_equal(size.T_to_sigma(0.0), 0.0)
63+
npt.assert_equal(size.T_to_r50(0.0), 0.0)
64+
npt.assert_equal(size.T_to_fwhm(0.0), 0.0)
65+
with np.errstate(invalid="ignore"):
66+
self.assertTrue(np.isnan(size.T_to_r50(-1.0)))
67+
5468
def test_round_trips(self):
5569
"""Test that inverse pairs compose to the identity."""
5670
values = np.array([0.01, 0.1, 1.0, 7.5])

0 commit comments

Comments
 (0)