Skip to content

Commit 48fc22d

Browse files
Update matrix_operation.py
1 parent f24ca20 commit 48fc22d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

matrix/matrix_operation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
from __future__ import annotations
6-
from typing import Optional
76

87

98
def add(*matrix_s: list[list]) -> list[list]:
@@ -122,7 +121,7 @@ def determinant(matrix: list[list]) -> int:
122121
)
123122

124123

125-
def inverse(matrix: list[list]) -> Optional[list[list]]:
124+
def inverse(matrix: list[list]) -> list[list] | None:
126125
"""
127126
>>> inverse([[1, 2], [3, 4]])
128127
[[-2.0, 1.0], [1.5, -0.5]]
@@ -159,6 +158,7 @@ def _shape(matrix: list[list]) -> tuple[int, int]:
159158
def _verify_matrix_sizes(
160159
matrix_a: list[list], matrix_b: list[list]
161160
) -> tuple[tuple, tuple]:
161+
shape = _shape(matrix_a) + _shape(matrix_b)
162162
if shape[0] != shape[3] or shape[1] != shape[2]:
163163
raise ValueError(
164164
f"operands could not be broadcast together with shape "

0 commit comments

Comments
 (0)