Пример #1
0
 def test_rotate_tensor_simple(self):
     r = transformations.euler_matrix(0, 0, np.pi/2, "sxyz")[:3, :3]
     d = np.arange(3)
     nptest.assert_almost_equal(d[[1, 0, 2]],
             utils.rotate_tensor(d, r, 1))
     d = np.arange(9).reshape(1,3,3)
     nptest.assert_almost_equal([[[4, -3, 5], [-1, 0, -2], [7, -6, 8]]],
             utils.rotate_tensor(d, r, 2))
Пример #2
0
 def test_rotate_tensor_identity(self):
     dr = np.identity(3)
     d = np.arange(3).reshape((1,3,))
     nptest.assert_almost_equal(d, utils.rotate_tensor(d, dr, 1))
     d = np.arange(3**2).reshape((1,3,3))
     nptest.assert_almost_equal(d, utils.rotate_tensor(d, dr, 2))
     d = np.arange(3**3).reshape(1,3,3,3)
     nptest.assert_almost_equal(d, utils.rotate_tensor(d, dr, 3))
     d = np.arange(3**4).reshape(1,3,3,3,3)
     nptest.assert_almost_equal(d, utils.rotate_tensor(d, dr, 4))
     d = np.arange(3**2*5).reshape(5,3,3)
     nptest.assert_almost_equal(d, utils.rotate_tensor(d, dr, 2))
     d = np.arange(3**4*5).reshape(5,3,3,3,3)
     nptest.assert_almost_equal(d, utils.rotate_tensor(d, dr, 4))
Пример #3
0
 def test_rotate_tensor_rot(self):
     r = transformations.euler_matrix(*np.random.random(3))[:3, :3]
     d = np.arange(3**3*5).reshape(5,3,3,3)
     dr = utils.rotate_tensor(d, r, 3)
     drr = utils.rotate_tensor(dr, r.T, 3)
     nptest.assert_almost_equal(d, drr)
Пример #4
0
 def test_curve(self):
     self.get()
     c = self.s.electrical_potential(self.x0, "rf", 2, expand=True)
     c = utils.rotate_tensor(c, self.r)
     nptest.assert_almost_equal(c[0]/self.c,
         2**(-1/3.)*np.eye(3)*[1, 1, -2])