We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 713d67b commit 4ac2047Copy full SHA for 4ac2047
2 files changed
cubed/core/indexing.py
@@ -87,7 +87,8 @@ def merged_chunk_len_for_indexer(ia, c):
87
# empty output case
88
from cubed.array_api.creation_functions import empty
89
90
- out = empty(shape, dtype=x.dtype, chunks=x.chunksize, spec=x.spec)
+ chunks = tuple(c for c in x.chunksize if c > 0)
91
+ out = empty(shape, dtype=x.dtype, chunks=chunks, spec=x.spec)
92
else:
93
dtype = x.dtype
94
chunks = tuple(
cubed/tests/test_array_api.py
@@ -357,6 +357,21 @@ def test_index_2d_step(spec, shape, chunks, ind, new_chunks_expected):
357
assert b.chunks == new_chunks_expected
358
359
360
+@pytest.mark.parametrize(
361
+ ("shape", "chunks", "ind"),
362
+ [
363
+ ((0, 2), (0, 2), (slice(None), 0)),
364
+ ((0, 2), (1, 2), (slice(None), 0)),
365
+ ((2, 0), (2, 0), (0, slice(None))),
366
+ ((2, 0), (2, 1), (0, slice(None))),
367
+ ],
368
+)
369
+def test_index_zero_dim(shape, chunks, ind):
370
+ a = xp.ones(shape, chunks=chunks)
371
+ b = a[ind]
372
+ assert_array_equal(b.compute(), np.ones(shape)[ind])
373
+
374
375
def test_index_slice_unsupported_step(spec):
376
a = xp.arange(12, chunks=(4,), spec=spec)
377
with pytest.raises(NotImplementedError):
0 commit comments