Skip to content

Commit ce9182c

Browse files
committed
enforce dtype int
1 parent 3a6a0d8 commit ce9182c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

zarr/indexing.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def __iter__(self):
472472
yield ChunkDimProjection(dim_chunk_ix, dim_chunk_sel, dim_out_sel)
473473

474474

475-
def slice_to_range(s, l): # noqa: E741
475+
def slice_to_range(s: slice, l: int): # noqa: E741
476476
return range(*s.indices(l))
477477

478478

@@ -916,8 +916,9 @@ def __init__(self, selection, arr_shape):
916916

917917
chunk_loc_slices = []
918918
last_dim_slice = None if selection[-1].step > 1 else selection.pop()
919-
for arr_shape_i, sl in zip(selection, arr_shape):
919+
for arr_shape_i, sl in zip(arr_shape, selection):
920920
dim_chunk_loc_slices = []
921+
assert isinstance(sl, slice)
921922
for x in slice_to_range(sl, arr_shape_i):
922923
dim_chunk_loc_slices.append(slice(x, x + 1, 1))
923924
chunk_loc_slices.append(dim_chunk_loc_slices)
@@ -928,12 +929,10 @@ def __init__(self, selection, arr_shape):
928929
def __iter__(self):
929930
chunk1 = self.chunk_loc_slices[0]
930931
nitems = (chunk1[-1].stop - chunk1[-1].start) * np.prod(
931-
self.arr_shape[len(chunk1) :]
932+
self.arr_shape[len(chunk1) :], dtype=int
932933
)
933934
for chunk_selection in self.chunk_loc_slices:
934935
start = 0
935936
for i, sl in enumerate(chunk_selection):
936-
start += sl.start * np.prod(self.arr_shape[i + 1 :])
937-
assert isinstance(start, int)
938-
assert isinstance(nitems, int)
937+
start += sl.start * np.prod(self.arr_shape[i + 1 :], dtype=int)
939938
yield start, nitems, chunk_selection

0 commit comments

Comments
 (0)