Repository navigation
fix(indexing): treat an empty list as an empty integer selection - #4518
Open
XXXXXQ-0206 wants to merge 2 commits into
Open
XXXXXQ-0206 wants to merge 2 commits into
XXXXXQ-0206 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4518 +/- ##
=======================================
Coverage 94.71% 94.71%
=======================================
Files 94 94
Lines 13663 13665 +2
=======================================
+ Hits 12941 12943 +2
Misses 722 722
🚀 New features to boost your workflow:
|
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.
arr[[]]raisesIndexError: unsupported selection item for basic indexing, while the same selection as an empty integer array works and NumPy accepts it:Why it is wrong:
IntSequence(declared atsrc/zarr/core/indexing.py:42) includeslist[int], so an empty list is a valid selection.is_integer_arrayignores length) and returns(0, 4); only thelistform is rejected.[]as an empty integer selection.Cause:
is_integer_list(:233) andis_bool_list(:238) both requirelen(x) > 0, so an empty list falls through toBasicIndexer, which accepts only int and slice.The change drops
len(x) > 0fromis_integer_listonly and makesreplace_listsusenp.intpfor an empty list (it otherwise infers float64).is_bool_listkeeps its guard, so an empty list is an empty integer selection, not an empty mask, as in NumPy.The new test covers empty lists in bare, tuple,
oindexandvindexforms, plus the empty-array, boolean-list and write controls. It fails on the base revision (src blob8ea59eb9->2926551a);tests/test_indexing.py592 -> 594 passed. Repo-widepytest: 12527 passed, 1293 skipped, 4 xfailed (Windows, CPython 3.14.7, 24m);ruff check/format --checkclean.If you would rather keep an empty list raising, we are happy to adjust.
AI-assisted, prepared under the account owner's direction.