Open the context
Choose the project folder and name the files or behavior involved.
Transpose a rectangular matrix into newly allocated rows. Check a tall matrix, one row and zero-width input, rejecting ragged rows and confirming that editing the result does not change the source rows.
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 transpose(rows):
rows = [list(row) for row in rows]
if not rows:
return []
width = len(rows[0])
if any(len(row) != width for row in rows):
raise ValueError("matrix.ragged")
return [[row[column] for row in rows] for column in range(width)]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.