Open the context
Choose the project folder and name the files or behavior involved.
Multiply rectangular integer matrices with at most 64 rows and columns each. Test empty and single-cell inputs, rejecting ragged rows, incompatible dimensions and Boolean cells without modifying the matrices.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def matrix_product(left, right):
left, right = [tuple(r) for r in left], [tuple(r) for r in right]
widths = []
for matrix in (left, right):
width = len(matrix[0]) if matrix else 0
if len(matrix) > 64 or width > 64 or any(len(r) != width for r in matrix):
raise ValueError("matrix.shape")
if any(type(v) is not int for r in matrix for v in r):
raise ValueError("cell.integer")
widths.append(width)
if widths[0] != len(right):
raise ValueError("matrix.incompatible")
return [[sum(row[k] * right[k][j] for k in range(widths[0]))
for j in range(widths[1])] for row in left]The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.