Skip to content

Fix matrix transpose reference construction - #462

Closed
mdhaber wants to merge 2 commits into
data-apis:masterfrom
mdhaber:fix-matrix-transpose-nested-arrays
Closed

Fix matrix transpose reference construction#462
mdhaber wants to merge 2 commits into
data-apis:masterfrom
mdhaber:fix-matrix-transpose-nested-arrays

Conversation

@mdhaber

@mdhaber mdhaber commented Sep 5, 2026

Copy link
Copy Markdown

_test_matrix_transpose constructs its expected result by passing nested lists of zero-dimensional arrays to asarray, although the standard only requires nested sequences of Python scalars. Construct the expected transpose by stacking the input rows along axis 1. For empty matrices, allocate the transposed shape explicitly with the input dtype and device, since stack requires a nonempty sequence. This also preserves both dimensions for empty matrices.

Add regression coverage that rejects non-Python-scalar sequence elements in asarray, covering rectangular matrices, stacks, and empty dimensions.

Validation with array-api-strict 2.6.1 on Python 3.14:

  • Confirmed the new regression cases fail before the fix (nested-array inputs and lost empty dimensions).
  • Both matrix transpose tests and all linalg meta-tests pass (8 passed).
  • Flake8 --select F on both changed files and git diff --check pass.

Fixes #461.

@mdhaber mdhaber closed this Sep 5, 2026
@mdhaber

mdhaber commented Sep 5, 2026

Copy link
Copy Markdown
Author

This is the ai slop version of gh-463, independently written and posted by GPT-6 Atra (medium effort) via Codex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_linalg.test_matrix_transpose() calls asarray on nested sequence of arrays

1 participant