55from lal import MTSUN_SI
66
77
8+ # rational_fit introduces ~2x more floating-point noise than spline due to its
9+ # iterative QR algorithm, pushing unit-conversion differences to ~2e-7.
10+ # rtol=1e-6 comfortably covers both methods while still catching real unit bugs.
11+ # (numpy assert_allclose default is 1e-7)
12+ UNIT_CONSISTENCY_RTOL = 1e-6
13+
14+
815def test_mks_vs_dimless_units ():
916 """ Tests that the measure_eccentricity interface is working for both
1017 MKS and dimensionless units.
@@ -38,9 +45,7 @@ def test_mks_vs_dimless_units():
3845 "D" : 1 })
3946 dataDictMKS = load_data .load_waveform (** lal_kwargs )
4047
41- # use different omega_gw_extrema_interpolation methods
42- # TODO: Add rational_fit to the list
43- omega_gw_extrema_interpolation_methods = ["spline" ]
48+ omega_gw_extrema_interpolation_methods = ["spline" , "rational_fit" ]
4449
4550 # List of all available methods
4651 available_methods = gw_eccentricity .get_available_methods ()
@@ -74,19 +79,22 @@ def test_mks_vs_dimless_units():
7479 np .testing .assert_allclose (
7580 [tref_out ],
7681 [tref_out_MKS * sec_to_dimless ],
82+ rtol = UNIT_CONSISTENCY_RTOL ,
7783 err_msg = ("tref_out at a single dimensionless and MKS"
7884 " time are inconsistent.\n "
7985 "x = Dimensionless, y = MKS converted to dimless" ))
8086 # Check if the measured ecc an mean ano are the same from the two units
8187 np .testing .assert_allclose (
8288 [ecc_ref ],
8389 [ecc_ref_MKS ],
90+ rtol = UNIT_CONSISTENCY_RTOL ,
8491 err_msg = ("Eccentricity at a single dimensionless and MKS"
8592 " time gives different results.\n "
8693 "x = Dimensionless, y = MKS" ))
8794 np .testing .assert_allclose (
8895 [meanano_ref ],
8996 [meanano_ref_MKS ],
97+ rtol = UNIT_CONSISTENCY_RTOL ,
9098 err_msg = ("Mean anomaly at a single dimensionless and MKS"
9199 " time gives different results.\n "
92100 "x = Dimensionless, y = MKS" ))
@@ -115,13 +123,15 @@ def test_mks_vs_dimless_units():
115123 np .testing .assert_allclose (
116124 [tref_out ],
117125 [tref_out_MKS * sec_to_dimless ],
126+ rtol = UNIT_CONSISTENCY_RTOL ,
118127 err_msg = ("tref_out array for dimensionless and MKS"
119128 " tref_in are inconsistent.\n "
120129 "x = Dimensionless, y = MKS converted to dimless" ))
121130 # Check if the measured ecc an mean ano are the same from the two units
122131 np .testing .assert_allclose (
123132 ecc_ref ,
124133 ecc_ref_MKS ,
134+ rtol = UNIT_CONSISTENCY_RTOL ,
125135 err_msg = ("Eccentricity at dimensionless and MKS array of"
126136 " times are different\n ."
127137 "x = Dimensionless, y = MKS" ))
@@ -130,6 +140,7 @@ def test_mks_vs_dimless_units():
130140 np .testing .assert_allclose (
131141 np .unwrap (meanano_ref ),
132142 np .unwrap (meanano_ref_MKS ),
143+ rtol = UNIT_CONSISTENCY_RTOL ,
133144 err_msg = ("Mean anomaly at dimensionless and MKS array of"
134145 " times are different.\n "
135146 "x = Dimensionless, y = MKS" ))
@@ -160,19 +171,22 @@ def test_mks_vs_dimless_units():
160171 np .testing .assert_allclose (
161172 [fref_out ],
162173 [fref_out_MKS / sec_to_dimless ],
174+ rtol = UNIT_CONSISTENCY_RTOL ,
163175 err_msg = ("fref_out for a single dimensionless and MKS"
164176 " fref_in are inconsistent.\n "
165177 "x = Dimensionless, y = MKS converted to dimless" ))
166178 # Check if the measured ecc an mean ano are the same from the two units
167179 np .testing .assert_allclose (
168180 [ecc_ref ],
169181 [ecc_ref_MKS ],
182+ rtol = UNIT_CONSISTENCY_RTOL ,
170183 err_msg = ("Eccentricity at a single dimensionless and MKS"
171184 " frequency gives different results.\n "
172185 "x = Dimensionless, y = MKS" ))
173186 np .testing .assert_allclose (
174187 [meanano_ref ],
175188 [meanano_ref_MKS ],
189+ rtol = UNIT_CONSISTENCY_RTOL ,
176190 err_msg = ("Mean anomaly at a single dimensionless and MKS"
177191 " frequency gives different results.\n "
178192 "x = Dimensionless, y = MKS" ))
@@ -203,19 +217,22 @@ def test_mks_vs_dimless_units():
203217 np .testing .assert_allclose (
204218 [fref_out ],
205219 [fref_out_MKS / sec_to_dimless ],
220+ rtol = UNIT_CONSISTENCY_RTOL ,
206221 err_msg = ("fref_out for an array of dimensionless and MKS"
207222 " fref_in are inconsistent.\n "
208223 "x = Dimensionless, y = MKS converted to dimless" ))
209224 # Check if the measured ecc an mean ano are the same from the two units
210225 np .testing .assert_allclose (
211226 ecc_ref ,
212227 ecc_ref_MKS ,
228+ rtol = UNIT_CONSISTENCY_RTOL ,
213229 err_msg = ("Eccentricity at dimensionless and MKS array of"
214230 " frequencies are different.\n "
215231 "x = Dimensionless, y = MKS" ))
216232 np .testing .assert_allclose (
217233 np .unwrap (meanano_ref ),
218234 np .unwrap (meanano_ref_MKS ),
235+ rtol = UNIT_CONSISTENCY_RTOL ,
219236 err_msg = ("Mean anomaly at dimensionless and MKS array of"
220237 " frequencies are different.\n "
221238 "x = Dimensionless, y = MKS" ))
0 commit comments