def test_static(self): doublechameleon = DoubleChameleon() x, y = 1., 1. phi_G, q = 0.3, 0.8 e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) kwargs_light = { 'alpha_1': 1, 'ratio': 0.5, 'w_c1': .5, 'w_t1': 1., 'e11': e1, 'e21': e2, 'w_c2': .1, 'w_t2': .5, 'e12': e1, 'e22': e2 } f_ = doublechameleon.function(x, y, **kwargs_light) doublechameleon.set_static(**kwargs_light) f_static = doublechameleon.function(x, y, **kwargs_light) npt.assert_almost_equal(f_, f_static, decimal=8) doublechameleon.set_dynamic() kwargs_light = { 'alpha_1': 2, 'ratio': 0.5, 'w_c1': .5, 'w_t1': 1., 'e11': e1, 'e21': e2, 'w_c2': .1, 'w_t2': .5, 'e12': e1, 'e22': e2 } f_dyn = doublechameleon.function(x, y, **kwargs_light) assert f_dyn != f_static
def test_function(self): """ :return: """ doublechameleon = DoubleChameleon() chameleon = Chameleon() x = np.linspace(0.1, 10, 10) phi_G, q = 0.3, 0.8 theta_E = 1. ratio = 2. e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) kwargs_light = { 'theta_E': 1., 'ratio': 2, 'w_c1': .5, 'w_t1': 1., 'e11': e1, 'e21': e2, 'w_c2': .1, 'w_t2': .5, 'e12': e1, 'e22': e2 } kwargs_1 = { 'theta_E': theta_E / (1 + 1. / ratio), 'w_c': .5, 'w_t': 1., 'e1': e1, 'e2': e2 } kwargs_2 = { 'theta_E': theta_E / (1 + ratio), 'w_c': .1, 'w_t': .5, 'e1': e1, 'e2': e2 } flux = doublechameleon.function(x=x, y=1., **kwargs_light) flux1 = chameleon.function(x=x, y=1., **kwargs_1) flux2 = chameleon.function(x=x, y=1., **kwargs_2) npt.assert_almost_equal(flux, flux1 + flux2, decimal=8)