Skip to content

Commit a0fb5f0

Browse files
committed
more complex oindex test
1 parent 3902b9b commit a0fb5f0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/zarr/testing/strategies.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,20 @@ def orthogonal_indices(
205205
npst.integer_array_indices(
206206
shape=(size,), result_shape=npst.array_shapes(min_side=1, max_side=size, max_dims=1)
207207
)
208-
# | npst.basic_indices(shape=(size,), allow_ellipsis=False)
208+
| basic_indices(shape=(size,), allow_ellipsis=False).map(
209+
lambda x: (x,) if not isinstance(x, tuple) else x
210+
)
209211
)
212+
if isinstance(idxr, int):
213+
idxr = np.array([idxr])
210214
zindexer.append(idxr)
211-
if isinstance(idxr, np.ndarray):
212-
newshape = [1] * ndim
213-
newshape[axis] = idxr.size
214-
idxr = idxr.reshape(newshape)
215-
npindexer.append(idxr)
215+
if isinstance(idxr, slice):
216+
idxr = np.arange(*idxr.indices(size))
217+
elif isinstance(idxr, (tuple, int)):
218+
idxr = np.array(idxr)
219+
newshape = [1] * ndim
220+
newshape[axis] = idxr.size
221+
npindexer.append(idxr.reshape(newshape))
216222
return tuple(zindexer), np.broadcast_arrays(*npindexer)
217223

218224

0 commit comments

Comments
 (0)