class TestHernquistEllipse(object): def setup(self): self.profile = Hernquist_Ellipse() def test_function(self): x = np.array([1]) y = np.array([2]) Rs = 1. sigma0 = 0.5 q, phi_G = 0.8, 0.5 e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) values = self.profile.function(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(values[0], 0.6431256503990406, decimal=6) x = np.array([0]) y = np.array([0]) Rs = 1. sigma0 = 0.5 values = self.profile.function(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(values[0], 0, decimal=6) x = np.array([2,3,4]) y = np.array([1,1,1]) values = self.profile.function( x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(values[0], 0.5983066087852915, decimal=6) npt.assert_almost_equal(values[1], 0.8014743038748537, decimal=6) npt.assert_almost_equal(values[2], 0.9806423979121521, decimal=6) def test_derivatives(self): x = 1 y = 2 Rs = 1. sigma0 = 0.5 q, phi_G = 0.8, 0.5 e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) f_x, f_y = self.profile.derivatives( x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(f_x, 0.06066651014748484, decimal=6) npt.assert_almost_equal(f_y, 0.24321226850316485, decimal=6) x = np.array([0]) y = np.array([0]) f_x, f_y = self.profile.derivatives(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(f_x, 0, decimal=8) npt.assert_almost_equal(f_y, 0, decimal=8) def test_hessian(self): x = np.array([1.]) y = np.array([2.]) Rs = 1. sigma0 = 0.5 q, phi_G = 0.8, 0.5 e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) f_xx, f_xy, f_yx, f_yy = self.profile.hessian(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(f_xx[0], 0.09437634437420293, decimal=6) npt.assert_almost_equal(f_yy[0], -0.029223594277816286, decimal=6) npt.assert_almost_equal(f_xy[0], -0.062239983771028566, decimal=6) npt.assert_almost_equal(f_xy, f_yx, decimal=6)
class TestHernquistEllipse(object): def setup(self): self.profile = Hernquist_Ellipse() def test_function(self): x = np.array([1]) y = np.array([2]) Rs = 1. sigma0 = 0.5 q, phi_G = 0.8, 0.5 e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) values = self.profile.function(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(values[0], 0.6451374041763912, decimal=8) x = np.array([0]) y = np.array([0]) Rs = 1. sigma0 = 0.5 values = self.profile.function(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(values[0], 0, decimal=6) x = np.array([2, 3, 4]) y = np.array([1, 1, 1]) values = self.profile.function(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(values[0], 0.60477384241056542, decimal=8) npt.assert_almost_equal(values[1], 0.80854098526603968, decimal=8) npt.assert_almost_equal(values[2], 0.98780932325084092, decimal=8) def test_derivatives(self): x = 1 y = 2 Rs = 1. sigma0 = 0.5 q, phi_G = 0.8, 0.5 e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) f_x, f_y = self.profile.derivatives(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(f_x, 0.065446024625706908, decimal=8) npt.assert_almost_equal(f_y, 0.24132860718623173, decimal=8) x = np.array([0]) y = np.array([0]) f_x, f_y = self.profile.derivatives(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(f_x, 0, decimal=8) npt.assert_almost_equal(f_y, 0, decimal=8) def test_hessian(self): x = np.array([1]) y = np.array([2]) Rs = 1. sigma0 = 0.5 q, phi_G = 0.8, 0.5 e1, e2 = param_util.phi_q2_ellipticity(phi_G, q) f_xx, f_xy, f_yx, f_yy = self.profile.hessian(x, y, sigma0, Rs, e1, e2) npt.assert_almost_equal(f_xx[0], 0.09340916928834986, decimal=6) npt.assert_almost_equal(f_yy[0], -0.02853883795950196, decimal=6) npt.assert_almost_equal(f_xy[0], -0.06298489507727822, decimal=6) npt.assert_almost_equal(f_xy, f_yx, decimal=6)