MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / _verify_matrix_sizes

Function _verify_matrix_sizes

matrix/matrix_operation.py:173–183  ·  view source on GitHub ↗
(
    matrix_a: list[list[int]], matrix_b: list[list[int]]
)

Source from the content-addressed store, hash-verified

171
172
173def _verify_matrix_sizes(
174 matrix_a: list[list[int]], matrix_b: list[list[int]]
175) -> tuple[tuple[int, int], tuple[int, int]]:
176 shape = _shape(matrix_a) + _shape(matrix_b)
177 if shape[0] != shape[3] or shape[1] != shape[2]:
178 msg = (
179 "operands could not be broadcast together with shape "
180 f"({shape[0], shape[1]}), ({shape[2], shape[3]})"
181 )
182 raise ValueError(msg)
183 return (shape[0], shape[2]), (shape[1], shape[3])
184
185
186def main() -> None:

Callers 3

addFunction · 0.85
subtractFunction · 0.85
multiplyFunction · 0.85

Calls 1

_shapeFunction · 0.85

Tested by

no test coverage detected