Skip to content

Commit c2283f3

Browse files
authored
Only use oindex for advanced indexing (int arrays) (#440)
This change means that more of the array API is supported for storage backends that don't have oindex (e.g. the new Zarr v3 implementation).
1 parent 7b4f7e2 commit c2283f3

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

cubed/core/ops.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ def merged_chunk_len_for_indexer(s):
489489
extra_projected_mem=extra_projected_mem,
490490
target_chunks=target_chunks,
491491
selection=selection,
492+
advanced_indexing=len(where_list) > 0,
492493
)
493494

494495
# merge chunks for any dims with step > 1 so they are
@@ -509,10 +510,19 @@ def merged_chunk_len_for_indexer(s):
509510
return out
510511

511512

512-
def _read_index_chunk(x, *arrays, target_chunks=None, selection=None, block_id=None):
513-
array = arrays[0]
513+
def _read_index_chunk(
514+
x,
515+
*arrays,
516+
target_chunks=None,
517+
selection=None,
518+
advanced_indexing=None,
519+
block_id=None,
520+
):
521+
array = arrays[0].zarray
522+
if advanced_indexing:
523+
array = array.oindex
514524
idx = block_id
515-
out = array.zarray.oindex[_target_chunk_selection(target_chunks, idx, selection)]
525+
out = array[_target_chunk_selection(target_chunks, idx, selection)]
516526
out = numpy_array_to_backend_array(out)
517527
return out
518528

0 commit comments

Comments
 (0)