Repository navigation
Transpose exchanges the first two levels of any array - #2090
Open
tombouctou wants to merge 4 commits into
Open
tombouctou wants to merge 4 commits into
tombouctou wants to merge 4 commits into
Conversation
Transpose[m] left a list of rank 3 unevaluated unless all its
dimensions were equal, and any list of rank 4 or more; rank 3 also went
through SymPy. As in WMA, the first two levels are now exchanged
whatever lies below them, as in the rows {{{1, 2}}, {a -> 1}} that
Combinatorica's SetGraphOptions transposes (SetEdgeWeights, Dijkstra).
Rows of different lengths give Transpose::nmtx.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rocky
reviewed
Oct 30, 2026
| #> Clear[matrix, matrix3D, square] | ||
| """ | ||
|
|
||
| messages = { |
Member
There was a problem hiding this comment.
Final please. Maybe there's a way to declare this in the class so we don't have to do all the duplication every time messages is set?
rocky
reviewed
Oct 30, 2026
| ("The first two levels of {{1, 2}, {3}} cannot be transposed.",), | ||
| "Transpose[{{1, 2}, {3}}]", | ||
| None, | ||
| ), |
Member
|
LGTM - decide whether you want to add a 4D test and add the Final type annotation. Merge when you want. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while running the examples of Skiena and Pemmaraju's Computational Discrete Mathematics with the Combinatorica package and comparing every result with WMA 15.
Transpose[m]left a list of rank 3 unevaluated unless all its dimensions were equal, and any list of rank 4 or more; rank 3 also went through SymPy. As in WMA, the first two levels are now exchanged, whatever lies below them.This includes rows like
{{{1, 2}}, {EdgeWeight -> 1}}, which Combinatorica'sSetGraphOptionstransposes. Because of this,SetEdgeWeightsgavePart::partwmessages, andDijkstraandMinimumSpanningTreeon weighted graphs hung.Rows of different lengths, as in
Transpose[{{1, 2}, {3}}], now giveTranspose::nmtx, as in WMA.All the fixes from this series together, merged on one branch: full pytest 4336 passed, 0 failed; doctests 4679 passed, 0 failed.
🤖 Generated with Claude Code