Beispiel #1
0
 def test_two_by_two_by_one(self):
     """Test that 2x2x1 calculation works."""
     modes = np.array([[1, 3], [2, 5]]).reshape((2, 2, 1))
     axis = 0
     arr = adiabatic.Pphi_matrix(modes, axis)
     desired = np.array([[10, 17], [17, 29]]).reshape((2, 2, 1))
     assert_almost_equal(arr, desired)
Beispiel #2
0
 def test_singlefield(self):
     """Test single field calculation."""
     modes = np.array([[7]])
     axis = 0
     actual = modes**2
     arr = adiabatic.Pphi_matrix(modes, axis)
     assert_almost_equal(arr, actual)
Beispiel #3
0
 def test_shape(self):
     """Test whether the rhodots are shaped correctly."""
     arr = adiabatic.Pphi_matrix(self.modes, self.axis)
     result = arr.shape
     actual = self.modes.shape
     assert_(
         result == actual, "Result shape %s, but desired shape is %s" %
         (str(result), str(actual)))
Beispiel #4
0
 def test_imaginary(self):
     """Test calculation with complex values."""
     modes = np.array([[1, 1j], [-1j, 3 - 1j]]).reshape((2, 2, 1))
     axis = 0
     arr = adiabatic.Pphi_matrix(modes, axis)
     desired = np.array([[2, -1 + 4 * 1j], [-1 - 4 * 1j, 11]]).reshape(
         (2, 2, 1))
     assert_almost_equal(arr, desired)
Beispiel #5
0
 def test_off_diag_conjugates(self):
     """Test that off diagonal elements are conjugate."""
     modes = np.array([[1, 1j], [-1j, 3 - 1j]]).reshape((2, 2, 1))
     axis = 0
     arr = adiabatic.Pphi_matrix(modes, axis)
     assert_equal(arr[0, 1], arr[1, 0].conj())