def test_identity_matrix(self) -> None: self.assertEqual(identity_matrix(0), empty_matrix()) self.assertEqual(identity_matrix(5), rows(( (1, 0, 0, 0, 0), (0, 1, 0, 0, 0), (0, 0, 1, 0, 0), (0, 0, 0, 1, 0), (0, 0, 0, 0, 1), ))) self.assertEqual(identity_matrix(1), singleton_matrix(1))
def test_diagonal_matrix(self) -> None: self.assertEqual(diagonal_matrix(()), empty_matrix()) self.assertEqual(diagonal_matrix((1, 1, 1)), identity_matrix(3)) self.assertEqual(diagonal_matrix(range(5)), rows(( (0,) * 5, (0, 1, 0, 0, 0), (0, 0, 2, 0, 0), (0, 0, 0, 3, 0), (0, 0, 0, 0, 4), )))
def test_one_matrix(self) -> None: self.assertEqual(one_matrix(0), empty_matrix()) self.assertEqual(one_matrix(5), rows(((1,) * 5, (1,) * 5, (1,) * 5, (1,) * 5, (1,) * 5))) self.assertEqual(one_matrix(5, 5), rows(((1,) * 5, (1,) * 5, (1,) * 5, (1,) * 5, (1,) * 5))) self.assertEqual(one_matrix(1, 5), row((1,) * 5)) self.assertEqual(one_matrix(5, 1), column((1,) * 5))
def test_empty_matrix(self) -> None: self.assertEqual(empty_matrix().dimensions, (0, 0))