Repository navigation
Fix ndarray from_iterator for column-major input - #483
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #483 +/- ##
===========================================
+ Coverage 43.97% 85.44% +41.47%
===========================================
Files 85 96 +11
Lines 7281 9367 +2086
===========================================
+ Hits 3202 8004 +4802
+ Misses 4079 1363 -2716 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
Thank you! |
Mec-iS
approved these changes
Oct 12, 2026
3 tasks done
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.
Fixes #482
I've pulled this fix out of #480 so we can review and merge it on its own.
Current behaviour
The ndarray implementation of
from_iteratorfirst builds a row-major array, then reverses its axes and reshapes it for column-major input. That reshape can panic for rectangular matrices. For example,from_iterator(1..=6, 2, 3, 1)fails instead of producing[[1, 3, 5], [2, 4, 6]]. This also affects callers such ash_stack.New expected behaviour
The constructor uses the requested order directly: row-major for
axis = 0and column-major foraxis = 1. Column-major input now produces a column-major array with the expected values and dimensions.Change logs
h_stack. Both regression tests fail with the old implementation.Fixedentry to the changelog.Validation
I ran these checks locally with Rust 1.99.0:
cargo build --all-features cargo test --all-features cargo fmt --all -- --check cargo clippy --all-features -- -Drust-2018-idioms -Drust-2024-compatibility -DwarningsChecklist