[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2025-01-31 20:09:04 +00:00
parent 792ee57123
commit 30930a6e28

View File

@ -3,19 +3,13 @@ from strassen_matrix_multiplication import split_matrix
class TestSplitMatrix(unittest.TestCase): class TestSplitMatrix(unittest.TestCase):
def test_4x4_matrix(self): def test_4x4_matrix(self):
matrix = [ matrix = [[4, 3, 2, 4], [2, 3, 1, 1], [6, 5, 4, 3], [8, 4, 1, 6]]
[4, 3, 2, 4],
[2, 3, 1, 1],
[6, 5, 4, 3],
[8, 4, 1, 6]
]
expected = ( expected = (
[[4, 3], [2, 3]], [[4, 3], [2, 3]],
[[2, 4], [1, 1]], [[2, 4], [1, 1]],
[[6, 5], [8, 4]], [[6, 5], [8, 4]],
[[4, 3], [1, 6]] [[4, 3], [1, 6]],
) )
self.assertEqual(split_matrix(matrix), expected) self.assertEqual(split_matrix(matrix), expected)
@ -28,31 +22,23 @@ class TestSplitMatrix(unittest.TestCase):
[4, 3, 2, 4, 4, 3, 2, 4], [4, 3, 2, 4, 4, 3, 2, 4],
[2, 3, 1, 1, 2, 3, 1, 1], [2, 3, 1, 1, 2, 3, 1, 1],
[6, 5, 4, 3, 6, 5, 4, 3], [6, 5, 4, 3, 6, 5, 4, 3],
[8, 4, 1, 6, 8, 4, 1, 6] [8, 4, 1, 6, 8, 4, 1, 6],
] ]
expected = ( expected = (
[[4, 3, 2, 4], [2, 3, 1, 1], [6, 5, 4, 3], [8, 4, 1, 6]], [[4, 3, 2, 4], [2, 3, 1, 1], [6, 5, 4, 3], [8, 4, 1, 6]],
[[4, 3, 2, 4], [2, 3, 1, 1], [6, 5, 4, 3], [8, 4, 1, 6]], [[4, 3, 2, 4], [2, 3, 1, 1], [6, 5, 4, 3], [8, 4, 1, 6]],
[[4, 3, 2, 4], [2, 3, 1, 1], [6, 5, 4, 3], [8, 4, 1, 6]], [[4, 3, 2, 4], [2, 3, 1, 1], [6, 5, 4, 3], [8, 4, 1, 6]],
[[4, 3, 2, 4], [2, 3, 1, 1], [6, 5, 4, 3], [8, 4, 1, 6]] [[4, 3, 2, 4], [2, 3, 1, 1], [6, 5, 4, 3], [8, 4, 1, 6]],
) )
self.assertEqual(split_matrix(matrix), expected) self.assertEqual(split_matrix(matrix), expected)
def test_invalid_odd_matrix(self): def test_invalid_odd_matrix(self):
matrix = [ matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
with self.assertRaises(Exception): with self.assertRaises(Exception):
split_matrix(matrix) split_matrix(matrix)
def test_invalid_non_square_matrix(self): def test_invalid_non_square_matrix(self):
matrix = [ matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12]
]
with self.assertRaises(Exception): with self.assertRaises(Exception):
split_matrix(matrix) split_matrix(matrix)