Skip to content

Support combo of advanced and basic indexing #2486

Open
@ilan-gold

Description

@ilan-gold

Discussed in #2485

Originally posted by ilan-gold November 12, 2024
Hello,

I am not entirely clear about what is supported and what isn't in zarr indexing, especially in v3. I understand https://zarr.readthedocs.io/en/stable/tutorial.html#advanced-indexing as "the API is different because we explicitly implement oindex but otherwise the behavior should be the same as numpy."

In other words, it seems "coordinate indexing" -> vindex (or just normal bracket shortcutting on the array directly) and "orthogonal indexing" -> oindex.

But other than these things, I'm not sure I understand what is and isn't supported. For example

import tempfile
import numpy as np
import zarr
from zarr.storage import LocalStore

shape = (4, 4, 4)
chunks = (2, 2, 2)
fill_value = 32767

tmp = tempfile.TemporaryDirectory()
arr = zarr.create(
    shape,
    store=LocalStore(root=tmp.name, mode="w"),
    chunks=chunks,
    dtype=np.int16,
    fill_value=fill_value,
    codecs=[zarr.codecs.BytesCodec(), zarr.codecs.BloscCodec()],
)
index_tuple = (np.array([1, 2]), np.array([1, 2]), slice(None))
# works
np.arange(64).reshape(shape)[index_tuple]
# breaks
arr[index_tuple]

This is on zarr v3 3.0.0b1. Is this a bug? Is there any good documentation on this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features or improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions