def test_shape(self): """Test whether the rhodots are shaped correctly.""" arr = nonadiabatic.deltarhosmatrix(self.Vphi, self.phidot, self.H, self.modes, self.modesdot, self.axis) result = arr.shape actual = self.modes.shape assert_(result == actual, "Result shape %s, but desired shape is %s"%(str(result), str(actual)))
def test_extend_Vphi(self): """Test that if Vphi has no k axis it is created.""" Vphi = np.arange(12).reshape((4, 3)) arr = nonadiabatic.deltarhosmatrix( Vphi, self.phidot, self.H, #@UnusedVariable self.modes, self.modesdot, self.axis)
def test_extend_H(self): """Test that if H has no field axis it is created.""" H = np.arange(8).reshape((4, 2)) arr = nonadiabatic.deltarhosmatrix( self.Vphi, self.phidot, H, #@UnusedVariable self.modes, self.modesdot, self.axis)
def test_shape(self): """Test whether the rhodots are shaped correctly.""" arr = nonadiabatic.deltarhosmatrix(self.Vphi, self.phidot, self.H, self.modes, self.modesdot, self.axis) result = arr.shape actual = self.modes.shape assert_( result == actual, "Result shape %s, but desired shape is %s" % (str(result), str(actual)))
def test_two_by_two_by_one(self): """Test that 2x2x1 calculation works.""" Vphi = np.array([1,2]).reshape((2,1)) phidot = np.array([7,9]).reshape((2,1)) modes = np.array([[1,3],[2,5]]).reshape((2,2,1)) modesdot = np.array([[1,3],[2,5]]).reshape((2,2,1)) axis = 0 H = np.array([2]).reshape((1,1)) arr = nonadiabatic.deltarhosmatrix(Vphi, phidot, H, modes, modesdot, axis) desired = np.array([[-2421,-6381],[-3974,-10502]]).reshape((2,2,1)) assert_almost_equal(arr, desired)
def test_two_by_one_by_one(self): """Test results of 2x1x1 calculation.""" Vphi = np.array([2,3]).reshape((2,1,1)) phidot = np.array([3,6]).reshape((2,1,1)) H = np.array([1,2]).reshape((2,1,1)) modes = np.array([10,5]).reshape((2,1,1,1)) modesdot = np.array([10,5]).reshape((2,1,1,1)) axis = 2 arr = nonadiabatic.deltarhosmatrix(Vphi, phidot, H, modes, modesdot, axis) actual = np.array([-85, -2025]).reshape((2,1,1,1)) assert_array_almost_equal(arr, actual)
def test_two_by_two_by_one(self): """Test that 2x2x1 calculation works.""" Vphi = np.array([1, 2]).reshape((2, 1)) phidot = np.array([7, 9]).reshape((2, 1)) modes = np.array([[1, 3], [2, 5]]).reshape((2, 2, 1)) modesdot = np.array([[1, 3], [2, 5]]).reshape((2, 2, 1)) axis = 0 H = np.array([2]).reshape((1, 1)) arr = nonadiabatic.deltarhosmatrix(Vphi, phidot, H, modes, modesdot, axis) desired = np.array([[-2421, -6381], [-3974, -10502]]).reshape( (2, 2, 1)) assert_almost_equal(arr, desired)
def test_scalar(self): """Test results of scalar calculation with 1x1 mode matrix.""" modes = np.array([[7]]) modesdot = np.array([[3]]) arr = nonadiabatic.deltarhosmatrix(3, 1.7, 0.5, modes, modesdot, axis=0) assert_almost_equal( arr, np.array([[0.5**2 * 1.7 * 3 - 0.5**3 * 1.7**2 * 1.7 * 7 + 21]]))
def test_two_by_one_by_one(self): """Test results of 2x1x1 calculation.""" Vphi = np.array([2, 3]).reshape((2, 1, 1)) phidot = np.array([3, 6]).reshape((2, 1, 1)) H = np.array([1, 2]).reshape((2, 1, 1)) modes = np.array([10, 5]).reshape((2, 1, 1, 1)) modesdot = np.array([10, 5]).reshape((2, 1, 1, 1)) axis = 2 arr = nonadiabatic.deltarhosmatrix(Vphi, phidot, H, modes, modesdot, axis) actual = np.array([-85, -2025]).reshape((2, 1, 1, 1)) assert_array_almost_equal(arr, actual)
def test_std_result(self): """Test simple calculation with modes of shape (4,3,3,2).""" arr = nonadiabatic.deltarhosmatrix(self.Vphi, self.phidot, self.H, self.modes, self.modesdot, self.axis) assert_almost_equal(arr, self.stdresult, decimal=12)
def test_extend_Vphi(self): """Test that if Vphi has no k axis it is created.""" Vphi = np.arange(12).reshape((4,3)) arr = nonadiabatic.deltarhosmatrix(Vphi, self.phidot, self.H, #@UnusedVariable self.modes, self.modesdot, self.axis)
def test_extend_H(self): """Test that if H has no field axis it is created.""" H = np.arange(8).reshape((4,2)) arr = nonadiabatic.deltarhosmatrix(self.Vphi, self.phidot, H, #@UnusedVariable self.modes, self.modesdot, self.axis)
def test_scalar(self): """Test results of scalar calculation with 1x1 mode matrix.""" modes = np.array([[7]]) modesdot = np.array([[3]]) arr = nonadiabatic.deltarhosmatrix(3, 1.7, 0.5, modes, modesdot, axis=0) assert_almost_equal(arr, np.array([[0.5**2*1.7*3-0.5**3*1.7**2*1.7*7+21]]))