zarr-python icon indicating copy to clipboard operation
zarr-python copied to clipboard

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

Open i-jey opened this issue 1 year ago • 1 comments

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)

i-jey avatar May 29 '24 17:05 i-jey

Thanks for the report here @i-jey. This is another regression from #1800. @dcherian -- care to take a look?

jhamman avatar Jun 01 '24 16:06 jhamman

This seems to have been fixed in #1947 and is not present in 3.0.0.

jhamman avatar Jan 10 '25 05:01 jhamman