Skip to content

fix: align indexing with other file backed ndarray implementations - #151

Merged
terraputix merged 4 commits into
mainfrom
fix/newaxis-indexing
Jul 21, 2026
Merged

terraputix merged 4 commits into
mainfrom
fix/newaxis-indexing

Conversation

@terraputix

@terraputix terraputix commented Jun 10, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes indexing to correctly handle clipped and empty slices across synchronous and asynchronous readers while preserving integer, slice, and ellipsis behavior. newaxis/None indexing was not correct and is removed entirely.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes NumPy-style None/np.newaxis indexing for OmFileReader (and the async reader) by tracking NewAxis positions during index parsing and re-inserting size-1 dimensions after applying integer-index squeezing. It also adds a suite of Python tests for basic indexing semantics.

Changes:

  • Extend ArrayIndex::get_ranges_and_squeeze_dims to return newaxis_dims in addition to read ranges and squeeze_dims.
  • Update sync/async readers to apply newaxis_dims when reshaping the returned ndarray.
  • Add Python indexing tests (integer/slice/ellipsis/negative slice/newaxis/mixed/errors) and additional Rust unit tests for NewAxis parsing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/test_read_write.py Adds comprehensive indexing tests and NewAxis-specific assertions.
src/reader.rs Plumbs newaxis_dims into array read/reshape path; updates an fsspec TypeError message.
src/reader_async.rs Mirrors sync reader changes by passing newaxis_dims into async reshape logic.
src/array_index.rs Enhances index parsing to track NewAxis positions and adjust squeeze/newaxis dims appropriately.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/array_index.rs Outdated
Comment thread tests/test_read_write.py Outdated
Comment thread tests/test_read_write.py
@terraputix terraputix changed the title fix: newaxis indexing fix: align indexing with other file backed ndarray implementations Jul 21, 2026
@terraputix
terraputix marked this pull request as ready for review July 21, 2026 13:42
@terraputix
terraputix merged commit f34c841 into main Jul 21, 2026
7 checks passed
@terraputix
terraputix deleted the fix/newaxis-indexing branch July 21, 2026 13:43
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.

2 participants