def test_different_component_forms(): """Check component forms can be different""" tiny_age = 1e-10 mean1 = np.zeros(6) covmatrix1 = np.eye(6) * 4 comp1 = SphereComponent(attributes={ 'mean':mean1, 'covmatrix':covmatrix1, 'age':tiny_age, }) mean2 = np.zeros(6) + 10. covmatrix2 = np.eye(6) * 9 comp2 = EllipComponent(attributes={ 'mean':mean2, 'covmatrix':covmatrix2, 'age':tiny_age, }) starcounts = [100,100] synth_data = SynthData(pars=[comp1.get_pars(), comp2.get_pars()], starcounts=starcounts, Components=[SphereComponent, EllipComponent]) synth_data.synthesise_everything() assert len(synth_data.table) == np.sum(starcounts)
def test_externalise_and_internalise_pars(): """Check that pars are successfully converted from internal form (used by emcee) to external form (interacted with by user) successfully""" # Check SphereComponent internal_sphere_pars = np.copy(SPHERE_PARS) internal_sphere_pars[6:8] = np.log(internal_sphere_pars[6:8]) sphere_comp = SphereComponent(emcee_pars=internal_sphere_pars) external_sphere_pars = sphere_comp.get_pars() assert np.allclose(SPHERE_PARS, external_sphere_pars) re_internal_sphere_pars = sphere_comp.internalise(external_sphere_pars) assert np.allclose(internal_sphere_pars, re_internal_sphere_pars) # Check EllipComponent internal_ellip_pars = np.copy(ELLIP_PARS) internal_ellip_pars[6:10] = np.log(internal_ellip_pars[6:10]) ellip_comp = EllipComponent(emcee_pars=internal_ellip_pars) external_ellip_pars = ellip_comp.get_pars() assert np.allclose(ELLIP_PARS, external_ellip_pars) re_internal_ellip_pars = ellip_comp.internalise(external_ellip_pars) assert np.allclose(internal_ellip_pars, re_internal_ellip_pars)