@@ -305,12 +305,43 @@ def test_fancy_indexing_fallback_on_get_setitem():
305
305
np .testing .assert_array_equal (
306
306
z [1 , [1 , 2 , 3 ]], [1 , 0 , 0 ]
307
307
)
308
+ # test 1D fancy indexing
309
+ z2 = zarr .zeros (5 )
310
+ z2 [[1 , 2 , 3 ]] = 1
311
+ np .testing .assert_array_equal (
312
+ z2 , [0 , 1 , 1 , 1 , 0 ]
313
+ )
308
314
309
315
310
316
def test_fancy_indexing_doesnt_mix_with_slicing ():
311
317
z = zarr .zeros ((20 , 20 ))
312
318
with pytest .raises (IndexError ):
313
319
z [[1 , 2 , 3 ], :] = 2
320
+ with pytest .raises (IndexError ):
321
+ np .testing .assert_array_equal (
322
+ z [[1 , 2 , 3 ], :], 0
323
+ )
324
+
325
+ def test_fancy_indexing_doesnt_mix_with_implicit_slicing ():
326
+ z2 = zarr .zeros ((5 , 5 , 5 ))
327
+ with pytest .raises (IndexError ):
328
+ z2 [[1 , 2 , 3 ], [1 , 2 , 3 ]] = 2
329
+ with pytest .raises (IndexError ):
330
+ np .testing .assert_array_equal (
331
+ z2 [[1 , 2 , 3 ], [1 , 2 , 3 ]], 0
332
+ )
333
+ with pytest .raises (IndexError ):
334
+ z2 [[1 , 2 , 3 ]] = 2
335
+ with pytest .raises (IndexError ):
336
+ np .testing .assert_array_equal (
337
+ z2 [[1 , 2 , 3 ]], 0
338
+ )
339
+ with pytest .raises (IndexError ):
340
+ z2 [..., [1 , 2 , 3 ]] = 2
341
+ with pytest .raises (IndexError ):
342
+ np .testing .assert_array_equal (
343
+ z2 [..., [1 , 2 , 3 ]], 0
344
+ )
314
345
315
346
316
347
def test_set_basic_selection_0d ():
0 commit comments