Skip to content

Commit b063054

Browse files
committed
Turn some enumeration + getitem into zip()
+ add some assertion instead of casting to int.
1 parent 3033817 commit b063054

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

zarr/indexing.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -916,9 +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 i, sl in enumerate(selection):
919+
for arr_shape_i, sl in zip(selection, arr_shape):
920920
dim_chunk_loc_slices = []
921-
for i, x in enumerate(slice_to_range(sl, arr_shape[i])):
921+
for x in slice_to_range(sl, self.arr_shape_i):
922922
dim_chunk_loc_slices.append(slice(x, x + 1, 1))
923923
chunk_loc_slices.append(dim_chunk_loc_slices)
924924
if last_dim_slice:
@@ -934,4 +934,6 @@ def __iter__(self):
934934
start = 0
935935
for i, sl in enumerate(chunk_selection):
936936
start += sl.start * np.prod(self.arr_shape[i + 1 :])
937-
yield int(start), int(nitems), chunk_selection
937+
assert isinstance(start, int)
938+
assert isinstance(nitems, int)
939+
yield start, nitems, chunk_selection

0 commit comments

Comments
 (0)