def test_update(): c = CosmoParams() c_pystruct = c.pystruct c.update( SIGMA_8=0.9 ) # update c parameters. since pystruct as dynamically created, it is a new object each call. assert c_pystruct != c.pystruct
def test_bad_construction(c): with pytest.raises(TypeError): CosmoParams(c, c) with pytest.raises(TypeError): CosmoParams(UserParams()) with pytest.raises(TypeError): CosmoParams(1)
def test_diff(c): """Ensure that the python dict has all fields""" d = CosmoParams(SIGMA_8=0.9) assert c is not d assert c != d assert hash(c) != hash(d)
def test_c_structures(c): # See if the C structures are behaving correctly c2 = CosmoParams(SIGMA_8=0.8) assert c() != c2() assert ( c() is c() ) # Re-calling should not re-make the object (object should have persistence)
def test_self(c): c5 = CosmoParams(c.self) assert c5 == c assert c5.pystruct == c.pystruct assert c5.defining_dict == c.defining_dict assert ( c5.defining_dict != c5.pystruct ) # not the same because the former doesn't include dynamic parameters. assert c5.self == c.self
def test_constructed_from_itself(c): c3 = CosmoParams(c) assert c == c3 assert c is not c3
def test_warning_bad_params(caplog): CosmoParams(bad_param=1) assert ( "The following parameters to CosmoParams are not supported: ['bad_param']" in caplog.text )
def test_constructed_the_same(c): c2 = CosmoParams(SIGMA_8=0.8) assert c is not c2 assert c == c2 assert hash(c) == hash(c2)
def c(): return CosmoParams(SIGMA_8=0.8)
def test_c_struct_update(): c = CosmoParams() _c = c() c.update(SIGMA_8=0.8) assert _c != c()
flag_options = FlagOptions( USE_MASS_DEPENDENT_ZETA=True, USE_TS_FLUCT=False, INHOMO_RECO=False, SUBCELL_RSD=False, M_MIN_in_Mass=False, PHOTON_CONS=False, ) if __name__ == "__main__": random_seed = 42 cosmo_params = CosmoParams(OMb=0.0486, OMm=0.3075, POWER_INDEX=0.97, SIGMA_8=0.82, hlittle=0.6774) astro_params = AstroParams( ALPHA_ESC=-0.5, ALPHA_STAR=0.5, F_ESC10=-1.30102999566, F_STAR10=-1.0, L_X=40.5, M_TURN=8.7, NU_X_THRESH=500.0, X_RAY_SPEC_INDEX=1.0, t_STAR=0.5, R_BUBBLE_MAX=15.0, )