Skip to content

Regression in 2.18.x with size-1 slicing not resolved #1931

Closed
@i-jey

Description

@i-jey

Zarr version

v2.17.0, 2.18.x

Numcodecs version

v0.12.1

Python Version

3.10.0

Operating System

Linux/Mac

Installation

Using pip3 in a venv

Description

There appears to be a regression from v0.17.x to v0.18.0 that was not resolved in v0.18.1 or v0.18.2 when indexing a zarr array with size-1 dimensions.

Steps to reproduce

The below works on zarr==2.17.0, breaks on zarr==2.18.1

def min_example():
    import zarr
    import numpy as np

    store = zarr.ZipStore("temp.zip", mode="w")
    arr = zarr.zeros(shape=(100, 200, 10), chunks=(100, 200, 1), compressor=None, store=store, dtype='u1')
    arr[:, :, :] = np.random.randint(0, 255, (100, 200, 10))
    store.close()

    zf = zarr.open("temp.zip", "r")
    print(zf[:, :, 1])

Additional output

The error on 2.18.1 is:

ValueError: could not broadcast input array from shape (100,200,1) into shape (100,200)

Metadata

Metadata

Assignees

No one assigned

    Labels

    V2Affects the v2 branchbugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions