import unittest
from pkg import Linear_Algebra
import numpy as np

class TestLU(unittest.TestCase):
    def setUp(self):
        self.U_answer = np.around(np.array([[2,1,0],[0,3/2,1],[0,0,4/3]], dtype=float), decimals=2).tolist()
        self.L_answer = np.around(np.array([[1,0,0],[1/2,1,0],[0,2/3,1]], dtype=float), decimals=2).tolist()

    def test_perm(self):
        answer = np.array([[0,1,0], [1,0,0], [0,0,1]], dtype=float).tolist()
        result = Linear_Algebra.make_perm_mx(3, 0, 1).tolist()
        self.assertEqual(result, answer)

    def test_LU(self):
        L_result, U_result = np.around(Linear_Algebra.LU(np.array([[2,1,0],[1,2,1],[0,1,2]], dtype=float)), decimals=2).tolist()
        self.assertEqual(U_result, self.U_answer)
        self.assertEqual(L_result, self.L_answer)
    
class TestDet(unittest.TestCase):
    def setUp(self):
        self.input_mx = np.array([[2,-1,0,0],[-1,2,-1,0],[0,-1,2,-1],[0,0,-1,2]], dtype=float)
    def test_find_det(self):
        result = np.around(Linear_Algebra.find_det(A = self.input_mx), decimals=2).tolist()
        answer = np.around(5, decimals=2).tolist()
        self.assertEqual(result, answer)

if __name__ == '__main__':
    unittest.main()
[((1199, 1214), 'unittest.main', 'unittest.main', ([], {}), '()\n', (1212, 1214), False, 'import unittest\n'), ((883, 972), 'numpy.array', 'np.array', (['[[2, -1, 0, 0], [-1, 2, -1, 0], [0, -1, 2, -1], [0, 0, -1, 2]]'], {'dtype': 'float'}), '([[2, -1, 0, 0], [-1, 2, -1, 0], [0, -1, 2, -1], [0, 0, -1, 2]],\n    dtype=float)\n', (891, 972), True, 'import numpy as np\n'), ((382, 438), 'numpy.array', 'np.array', (['[[0, 1, 0], [1, 0, 0], [0, 0, 1]]'], {'dtype': 'float'}), '([[0, 1, 0], [1, 0, 0], [0, 0, 1]], dtype=float)\n', (390, 438), True, 'import numpy as np\n'), ((459, 495), 'pkg.Linear_Algebra.make_perm_mx', 'Linear_Algebra.make_perm_mx', (['(3)', '(0)', '(1)'], {}), '(3, 0, 1)\n', (486, 495), False, 'from pkg import Linear_Algebra\n'), ((1092, 1116), 'numpy.around', 'np.around', (['(5)'], {'decimals': '(2)'}), '(5, decimals=2)\n', (1101, 1116), True, 'import numpy as np\n'), ((155, 219), 'numpy.array', 'np.array', (['[[2, 1, 0], [0, 3 / 2, 1], [0, 0, 4 / 3]]'], {'dtype': 'float'}), '([[2, 1, 0], [0, 3 / 2, 1], [0, 0, 4 / 3]], dtype=float)\n', (163, 219), True, 'import numpy as np\n'), ((264, 328), 'numpy.array', 'np.array', (['[[1, 0, 0], [1 / 2, 1, 0], [0, 2 / 3, 1]]'], {'dtype': 'float'}), '([[1, 0, 0], [1 / 2, 1, 0], [0, 2 / 3, 1]], dtype=float)\n', (272, 328), True, 'import numpy as np\n'), ((1010, 1050), 'pkg.Linear_Algebra.find_det', 'Linear_Algebra.find_det', ([], {'A': 'self.input_mx'}), '(A=self.input_mx)\n', (1033, 1050), False, 'from pkg import Linear_Algebra\n'), ((627, 683), 'numpy.array', 'np.array', (['[[2, 1, 0], [1, 2, 1], [0, 1, 2]]'], {'dtype': 'float'}), '([[2, 1, 0], [1, 2, 1], [0, 1, 2]], dtype=float)\n', (635, 683), True, 'import numpy as np\n')]