'unittest jsut runs 1 out of 4 test cases
We have this assigment where i should run these four test cases with the help of unittest but when I run it with the command python test.py (name of the file) it just says it ran 1 test what am I doing wrong?
import sympy as sp
import numpy as np
from scipy import linalg
def numpy_determinant(arr):
if len(sp.Matrix(arr).rref()[1]) < max(np.shape(arr)):
return 0
else:
return np.linalg.det(arr)
def scipy_determinant(arr):
return linalg.det(arr)
class ArrValue:
value = np.array([[2, 1],
[2, 2]])
class TestMethods(unittest.TestCase):
def test_positive(self):
# test case 1
arr1 = ArrValue()
arr_det_np = numpy_determinant(arr1.value)
arr2 = ArrValue()
arr_det_sc = scipy_determinant(arr2.value)
# Test case 2
arr1 = ArrValue()
arr_det_np = numpy_determinant(arr1.value)
arr2 = np.array([[2, 1, 0],
[2, 2, 0]])
arr_det_sc = scipy_determinant(arr2)
# test case 3
arr1 = ArrValue()
arr_det_np = numpy_determinant(arr1.value)
arr2 = np.linalg.inv(arr1)
arr_det_sc = scipy_determinant(arr2.value)
# test case 4
arr1 = ArrValue()
arr_det_np = numpy_determinant(arr1.value)
arr2 = np.linalg.transpose(arr1)
arr_det_sc = scipy_determinant(arr2.value)
#test case 5
arr1 = ([[1,0,0],
[0,0,0],
[0,0,1]])
arr_det_np = numpy_determinant(arr1)
arr2 = ArrValue()
arr_det_sc = scipy_determinant(arr2.value)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|