Skip to content

Commit 67d3237

Browse files
doctest for exception
1 parent 48fc22d commit 67d3237

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

matrix/matrix_operation.py

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ def add(*matrix_s: list[list]) -> list[list]:
1313
[[3.2, 5.4], [7, 9]]
1414
>>> add([[1, 2], [4, 5]], [[3, 7], [3, 4]], [[3, 5], [5, 7]])
1515
[[7, 14], [12, 16]]
16+
>>> add([3], [4, 5])
17+
Traceback (most recent call last):
18+
...
19+
TypeError: Expected a matrix, got int/list instead
1620
"""
1721
if all(_check_not_integer(m) for m in matrix_s):
1822
for i in matrix_s[1:]:
@@ -27,6 +31,10 @@ def subtract(matrix_a: list[list], matrix_b: list[list]) -> list[list]:
2731
[[-1, -1], [-1, -1]]
2832
>>> subtract([[1,2.5],[3,4]],[[2,3],[4,5.5]])
2933
[[-1, -0.5], [-1, -1.5]]
34+
>>> subtract([3], [4, 5])
35+
Traceback (most recent call last):
36+
...
37+
TypeError: Expected a matrix, got int/list instead
3038
"""
3139
if (
3240
_check_not_integer(matrix_a)

0 commit comments

Comments
 (0)