Skip to content

bug(indexing): oindex with mixed numpy array and integer indexing fails #4315

Description

@d-v-b

this looks good, i'm going to approve + merge. there's a remaining bugged case that I will fix in a follow-up PR:

import numpy as np, zarr
from zarr.storage import MemoryStore
from zarr.codecs import ShardingCodec, BytesCodec

a = zarr.create_array(
    MemoryStore(), shape=(4, 4, 4), chunks=(2, 4, 4), dtype="int32",
    serializer=ShardingCodec(chunk_shape=(2, 2, 2), codecs=(BytesCodec(),)),
    compressors=None, fill_value=0,
)
a[:] = np.arange(64, dtype="int32").reshape(4, 4, 4)
a.oindex[np.array([3, 1, 2]), 1, np.array([0, 2])] = np.arange(6, dtype="int32").reshape(3, 2)
# ValueError: shape mismatch: value array of shape (1,2) could not be broadcast to indexing result of shape (1,)

Originally posted by @d-v-b in #4284 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions