Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indexing with bools #1968

Merged
merged 23 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
38578dd
test z[selection] for orthogonal selection
brokkoli71 Jun 15, 2024
7b6470f
include boolean indexing in is_pure_orthogonal_indexing
brokkoli71 Jun 15, 2024
badf818
Revert "test z[selection] for orthogonal selection"
brokkoli71 Jun 15, 2024
dd764e2
add test_indexing_equals_numpy
brokkoli71 Jun 15, 2024
26b920c
extend _test_get_mask_selection for square bracket notation
brokkoli71 Jun 15, 2024
782a712
fix is_pure_fancy_indexing for mask selection
brokkoli71 Jun 15, 2024
a94b995
add test_orthogonal_bool_indexing_like_numpy_ix
brokkoli71 Jun 15, 2024
97a06f0
fix for mypy
brokkoli71 Jun 15, 2024
85ca73f
ruff format
brokkoli71 Jun 17, 2024
46a2d4b
fix is_pure_orthogonal_indexing
brokkoli71 Jun 17, 2024
9e7b53c
fix is_pure_orthogonal_indexing
brokkoli71 Jun 17, 2024
b1a2ccf
replace deprecated ~ by not
brokkoli71 Jun 17, 2024
7849f41
restrict is_integer to not bool
brokkoli71 Jun 17, 2024
d52b9d0
correct typing
brokkoli71 Jun 19, 2024
b18697f
Merge branch 'zarr-developers:v3' into fix-indexing-with-bools
brokkoli71 Jun 19, 2024
1b27e65
correct typing
brokkoli71 Jun 19, 2024
ea6eddb
check if bool list has only bools
brokkoli71 Jun 19, 2024
31c1e7a
check if bool list has only bools
brokkoli71 Jun 19, 2024
d525d7f
fix list unpacking in test for python3.10
brokkoli71 Jun 19, 2024
ef7492b
Apply spelling suggestions from code review
brokkoli71 Jun 24, 2024
3355a02
Merge branch 'v3' into fix-indexing-with-bools
brokkoli71 Jun 24, 2024
4f0321f
fix mypy
brokkoli71 Jun 27, 2024
6812f73
Merge branch 'refs/heads/master' into fix-indexing-with-bools
brokkoli71 Jun 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix is_pure_fancy_indexing for mask selection
  • Loading branch information
brokkoli71 committed Jun 15, 2024
commit 782a712619d77022fbaf2ea31e35031380503207
9 changes: 7 additions & 2 deletions src/zarr/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def is_scalar(value: Any, dtype: np.dtype[Any]) -> bool:


def is_pure_fancy_indexing(selection: Any, ndim: int) -> bool:
"""Check whether a selection contains only scalars or integer array-likes.
"""Check whether a selection contains only scalars or integer/bool array-likes.

Parameters
----------
Expand All @@ -171,9 +171,14 @@ def is_pure_fancy_indexing(selection: Any, ndim: int) -> bool:
True if the selection is a pure fancy indexing expression (ie not mixed
with boolean or slices).
"""
if is_bool_array(selection):
# is mask selection
return True

if ndim == 1:
if is_integer_list(selection) or is_integer_array(selection):
if is_integer_list(selection) or is_integer_array(selection) or is_bool_list(selection):
return True

# if not, we go through the normal path below, because a 1-tuple
# of integers is also allowed.
no_slicing = (
Expand Down
2 changes: 1 addition & 1 deletion tests/v3/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ def test_accessed_chunks(shape, chunks, ops):
[
# basic selection
...,
1, ...,
(1, ...),
slice(None),
(1,3),
([1, 2, 3],9),
Expand Down