Exemple #1
0
 def test_not_complex(self):
     """Test that returned object is not complex."""
     Vphi = np.array([1, 2]).reshape((2, 1))
     phidot = np.array([1, 1]).reshape((2, 1))
     H = np.array([1]).reshape((1, 1))
     modes = np.array([[1, 1j], [-1j, 3 - 1j]]).reshape((2, 2, 1))
     modesdot = np.array([[1, -1j], [1j, 3 + 1j]]).reshape((2, 2, 1))
     axis = 0
     arr = adiabatic.Pzeta_spectrum(Vphi, phidot, H, modes, modesdot, axis)
     assert_((not np.iscomplexobj(arr)))
Exemple #2
0
 def test_imaginary(self):
     """Test calculation with complex values."""
     Vphi = np.array([1, 2]).reshape((2, 1))
     phidot = np.array([1, 1]).reshape((2, 1))
     H = np.array([1]).reshape((1, 1))
     modes = np.array([[1, 1j], [-1j, 3 - 1j]]).reshape((2, 2, 1))
     modesdot = np.array([[1, -1j], [1j, 3 + 1j]]).reshape((2, 2, 1))
     axis = 0
     arr = adiabatic.Pzeta_spectrum(Vphi, phidot, H, modes, modesdot, axis)
     desired = np.array([38 / 36.0])
     assert_almost_equal(arr, desired)
Exemple #3
0
 def test_singlefield(self):
     """Test single field calculation."""
     modes = np.array([[7]])
     modesdot = np.array([[5]])
     Vphi = 3
     phidot = 0.5
     H = 2
     axis = 0
     actual = (29.25)**2 / 9.0
     arr = adiabatic.Pzeta_spectrum(Vphi, phidot, H, modes, modesdot, axis)
     assert_almost_equal(arr, actual)
Exemple #4
0
 def test_two_by_two_by_one(self):
     """Test that 2x2x1 calculation works."""
     Vphi = np.array([5.5, 2.3]).reshape((2, 1))
     phidot = np.array([2, 5]).reshape((2, 1))
     modes = np.array([[1 / 3.0, 0.1], [0.1, 0.5]]).reshape((2, 2, 1))
     modesdot = np.array([[0.1, 0.2], [0.2, 1 / 7.0]]).reshape((2, 2, 1))
     axis = 0
     H = np.array([3]).reshape((1, 1))
     arr = adiabatic.Pzeta_spectrum(Vphi, phidot, H, modes, modesdot, axis)
     desired = np.array([135451.600445493 / (783**2)])
     assert_almost_equal(arr, desired)
Exemple #5
0
 def test_shape(self):
     """Test whether the rhodots are shaped correctly."""
     arr = adiabatic.Pzeta_spectrum(self.Vphi, self.phidot, self.H,
                                    self.modes, self.modesdot, self.axis)
     result = arr.shape
     newshape = list(self.phidot.shape)
     del newshape[self.axis]
     actual = tuple(newshape)
     assert_(
         result == actual, "Result shape %s, but desired shape is %s" %
         (str(result), str(actual)))