def test_can_get_identity_matrix(self): i = Matrix.identity(1) self.assertEqual(i._rows, [[1]]) i = Matrix.identity(2) self.assertEqual(i._rows, [[1, 0], [0, 1]]) i = Matrix.identity(3) self.assertEqual(i._rows, [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
def test_dimensions_must_be_int(self): with self.assertRaises(TypeError): Matrix.identity(1.4)