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

Unable to make a Zarr Array

Open me-her opened this issue 1 year ago • 2 comments

Zarr version

v2.18.3

Numcodecs version

v0.13.1

Python Version

3.10

Operating System

Linux

Installation

uv pip install zarr

Description

Unable to create a zarr array with numpy array as data. I tried to use zarr_array = zarr.array(data = data). It errors out saying, AttributeError: 'dict' object has no attribute 'encode'. Maybe we need to pass in the compressor as a dictionary.

Steps to reproduce

In [1]: import zarr

In [2]: import numpy as np

In [3]: data = np.ones([1,1])

In [4]: data
Out[4]: array([[1.]])

In [5]: zarr_array = zarr.array(data = data)

-----------------------------------------------
   2393 # compress
   2394 if self._compressor:
-> 2395     cdata = self._compressor.encode(chunk)
   2396 else:
   2397     cdata = chunk

AttributeError: 'dict' object has no attribute 'encode'

Additional output

Image

me-her avatar Dec 31 '24 13:12 me-her

Hi @me-her - sorry to hear you hit some trouble here. Would you mind trying with the lastest versions of Zarr and numcodecs. I'm not able to reproduce with today's release.

>>> import zarr
>>> zarr.__version__
'3.0.0'
>>> import numpy as np
>>> data = np.ones([1,1])
>>> zarr_array = zarr.array(data = data)
>>> zarr_array
<Array memory://4344350144 shape=(1, 1) dtype=float64>
>>> zarr_array[:]
array([[1.]])

jhamman avatar Jan 10 '25 05:01 jhamman

I am still on python 3.10, and zarr 2.18.4 needs 3.11. I will try it out with the new ones. Thank you. I was able to use zarr 2.18.2 and numcodecs 0.12.1. I haven't had any issue.

me-her avatar Jan 10 '25 15:01 me-her