@@ -1204,23 +1204,39 @@ def test_thin_bandpass():
12041204 print ('in band: ' ,len (combined_in_band ), combined_in_band )
12051205
12061206 thin_s = s .thin (rel_err = 1.e-3 , preserve_range = True , bandpass = bp )
1207- thin_flux = thin_s .calculateFlux (bp )
1208- thin_err = abs ((thin_flux - flux ) / flux )
1209- print ('thinned' , len (thin_s .wave_list ), thin_s .wave_list )
1210- assert thin_err < 1.e-3
12111207 np .testing .assert_allclose ([thin_s .blue_limit , thin_s .red_limit ],
12121208 [bp .blue_limit , bp .red_limit ])
12131209 assert len (thin_s .wave_list ) < len (combined_in_band )
12141210 assert len (thin_s .wave_list ) < len (s .wave_list )
1211+ thin_flux = thin_s .calculateFlux (bp )
1212+ thin_err = abs ((thin_flux - flux ) / flux )
1213+ print ('thinned' , len (thin_s .wave_list ), thin_s .wave_list )
1214+ print ('thin_err = ' ,thin_err )
1215+ assert thin_err < 1.e-3
12151216
12161217 # trim_zeros=False should retain the original redshifted SED support.
12171218 thin_s2 = s .thin (rel_err = 1.e-3 , preserve_range = True , trim_zeros = False , bandpass = bp )
12181219 print ('trim_zeros=False' , len (thin_s2 .wave_list ), thin_s2 .wave_list )
1220+ np .testing .assert_allclose ([thin_s2 .blue_limit , thin_s2 .red_limit ],
1221+ [s .blue_limit , s .red_limit ])
12191222 thin_flux2 = thin_s2 .calculateFlux (bp )
12201223 thin_err2 = abs ((thin_flux2 - flux ) / flux )
1224+ print ('thin_err2 = ' ,thin_err2 )
12211225 assert thin_err2 < 1.e-3
1222- np .testing .assert_allclose ([thin_s2 .blue_limit , thin_s2 .red_limit ],
1226+
1227+ # Compare the thinned error when not using bp in the thin call.
1228+ thin_s3 = s .thin (rel_err = 1.e-3 , preserve_range = True , trim_zeros = False )
1229+ print ('trim_zeros=False, no bandpass' , len (thin_s3 .wave_list ), thin_s3 .wave_list )
1230+ np .testing .assert_allclose ([thin_s3 .blue_limit , thin_s3 .red_limit ],
12231231 [s .blue_limit , s .red_limit ])
1232+ thin_flux3 = thin_s3 .calculateFlux (bp )
1233+ thin_err3 = abs ((thin_flux3 - flux ) / flux )
1234+ print ('thin_err3 = ' ,thin_err3 )
1235+ # There are no hard guarantees about this result, but it should normally also be < rel_err.
1236+ assert thin_err3 < 1.e-3
1237+ # It would also be expected in practice that the bandpass-aware thinning does a better
1238+ # job, but there are no guarantees about that either. It turns out to be true here.
1239+ assert thin_err2 < thin_err3
12241240
12251241@timer
12261242def test_broadcast ():
0 commit comments