def test_BH_redirection_function(): halo = tangos.get_halo("sim/ts1/1") bh_dbid = halo.calculate("BH('BH_mass','max','BH').dbid()") assert bh_dbid == tangos.get_halo("sim/ts1/1.1").id bh_dbid = halo.calculate("BH('BH_mass','min','BH').dbid()") assert bh_dbid == tangos.get_halo("sim/ts1/1.2").id
def test_non_existent_redirection(): halo = tangos.get_halo("sim/ts1/2") with assert_raises(ValueError): halo.calculate("BH.dbid()")
def test_non_existent_property(): halo = tangos.get_halo("sim/ts1/1") with assert_raises(KeyError): halo.calculate("non_existent_property")
def test_function_after_property_redirection(): halo = tangos.get_halo("sim/ts1/1") bh_dbid = halo.calculate("BH.dbid()") assert bh_dbid == tangos.get_halo("sim/ts1/1.1").id
def test_abcissa_passing_function(): """In this example, the x-coordinates need to be successfully passed "through" the abs function for the at function to return the correct result.""" halo = tangos.get_halo("sim/ts1/1") assert np.allclose(halo.calculate("at(3.0,abs(dummy_property_2))"), 15.0 * np.sqrt(3))
def test_property_redirection(): halo = tangos.get_halo("sim/ts1/1") assert halo.calculate("BH.BH_mass") == tangos.get_halo( "sim/ts1/1.1")["BH_mass"]
def test_nested_abs_at_function(): halo = tangos.get_halo("sim/ts1/1") # n.b. for J_dm_enc assert np.allclose(halo.calculate("abs(at(3.0,dummy_property_2))"), 15.0 * np.sqrt(3))
def test_abs_scalar_function(): # Test that abs also works on a single scalar (issue 110) halo = tangos.get_halo("sim/ts1/1") assert np.allclose(halo.calculate("abs(dummy_property_3)"), -halo.calculate("dummy_property_3")) assert np.allclose(halo.calculate("abs(dummy_property_3)"), 2.5)
def test_abs_array_function(): halo = tangos.get_halo("sim/ts1/1") assert np.allclose(halo.calculate("abs(dummy_property_2)"), halo.calculate("abs(dummy_property_2 * (-1))")) assert np.allclose(halo.calculate("abs(dummy_property_2)"), np.arange(0, 100.0) * np.sqrt(3))
def test_custom_at_function(): halo = tangos.get_halo("sim/ts1/1") assert np.allclose( halo.calculate("at(3.0,property_with_custom_interpolator())"), 3.0)
def test_at_function(): halo = tangos.get_halo("sim/ts1/1") assert np.allclose(halo.calculate("at(3.0,dummy_property_1)"), 30.0)