def test_own_v(self): for v in [self.v, self.t]: v_rot = fixed_to_comoving(v, v) e_y_like_v = np.zeros_like(v) e_y_like_v[..., 1] = 1 np.testing.assert_almost_equal(v_rot, norm(v, keepdims=True) * e_y_like_v)
def test_angles_with_rot(self): t_rot = fixed_to_comoving(self.t, self.v) e_y = np.zeros_like(self.v) e_y[..., 1] = 1 angles1 = signed_angle_between_vectors(self.t, t_rot) angles2 = signed_angle_between_vectors(self.v, e_y) np.testing.assert_almost_equal(angles1, angles2)
def test_own_t(self): t_rot = fixed_to_comoving(self.t, self.t) e_y_like_t = np.zeros_like(self.t) e_y_like_t[..., 1] = 1 np.testing.assert_almost_equal( t_rot, norm(self.t, keepdims=True) * e_y_like_t)
def test_angles_with_rot(self): t_rot = fixed_to_comoving(self.t, self.v) e_y = np.zeros_like(self.v) e_y[..., 1] = 1 angles1 = signed_angle_between_vectors(self.t, t_rot) angles2 = signed_angle_between_vectors(self.v, e_y) angles2_b = np.broadcast_to(angles2[:, :, None], angles1.shape) np.testing.assert_almost_equal(angles1, angles2_b)
def test_comoving_to_fixed(self): t_rot = fixed_to_comoving(self.t, self.v) t_back = comoving_to_fixed(t_rot, self.v) np.testing.assert_almost_equal(self.t, t_back)
def test_angles_unchanged(self): t_rot = fixed_to_comoving(self.t, self.v) t2_rot = fixed_to_comoving(self.t2, self.v) angles_before = signed_angle_between_vectors(self.t, self.t2) angles_after = signed_angle_between_vectors(t_rot, t2_rot) np.testing.assert_almost_equal(angles_before, angles_after)
def test_conmute_with_normalise(self): t_rot1 = normalise(fixed_to_comoving(self.t, self.v)) t_rot2 = fixed_to_comoving(normalise(self.t), self.v) np.testing.assert_almost_equal(t_rot1, t_rot2)
def test_fixed_to_comoving_unnormalised(self): t_rot1 = fixed_to_comoving(self.t, self.v) t_rot2 = fixed_to_comoving(self.t, self.e) np.testing.assert_almost_equal(t_rot1, t_rot2) np.testing.assert_almost_equal(norm(t_rot1), norm(self.t))