@@ -61,6 +61,32 @@ def test_libraries(pop_and_params):
6161 assert dlib == pop .duste_library
6262
6363
64+ def test_param_checks (pop_and_params ):
65+ pop , params = pop_and_params
66+ _reset_default_params (pop , params )
67+ pop .params ["sfh" ] = 1
68+ pop .params ["tage" ] = 2
69+ pop .params ["sf_start" ] = 0.5
70+ # this should never raise an error:
71+ w , s = pop .get_spectrum (tage = pop .params ["tage" ])
72+ # this used to raise an assertion error in the setter:
73+ pop .params ["sf_start" ] = pop .params ["tage" ] + 0.1
74+ # this also used to raise an assertion error in the setter:
75+ pop .params ["imf_type" ] = 8
76+ # fix the invalid IMF but leave the invalid sf_start > tage
77+ pop .params ["imf_type" ] = 1
78+ try :
79+ # This *should* still raise an AssertionError
80+ w , s = pop .get_spectrum (tage = pop .params ["tage" ])
81+ # Hacky way to make sure the AssertionError still got thrown
82+ raise ValueError ("Did not throw exception for invalid sf_start > tage" )
83+ except (AssertionError ):
84+ pass
85+ pop .params ["tage" ] = 1.0
86+ pop .params ["sf_start" ] = 0.1
87+ w , s = pop .get_spectrum (tage = pop .params ["tage" ])
88+
89+
6490def test_filters ():
6591 """Test all the filters got transmission data loaded."""
6692 flist = filters .list_filters ()
@@ -73,10 +99,11 @@ def test_filters():
7399def test_get_mags (pop_and_params ):
74100 """Basic test for supplying filter names to get_mags"""
75101 pop , params = pop_and_params
102+ _reset_default_params (pop , params )
76103 fuv1 = pop .get_mags (bands = ["galex_fuv" ])[:, 0 ]
77104 mags = pop .get_mags ()
78- fuv2 = mags [:, 61 ]
79- fuv3 = mags [:, 62 ]
105+ fuv2 = mags [:, 61 ] # this should be galex_FUV
106+ fuv3 = mags [:, 62 ] # this should *not* be galex_FUV
80107 assert np .all (fuv1 == fuv2 )
81108 assert np .all (fuv1 != fuv3 )
82109
0 commit comments