Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error reading object array #34

Open
dstansby opened this issue Dec 10, 2024 · 1 comment
Open

Error reading object array #34

dstansby opened this issue Dec 10, 2024 · 1 comment

Comments

@dstansby
Copy link
Collaborator

I'm not 100% sure if this is a valid zarr v2 metadata, but it's erroring with pydantic-zarr:

import tempfile
from pathlib import Path

import pydantic_zarr
import pydantic_zarr.v2
import zarr

zarray = """{
    "chunks": [
        2
    ],
    "compressor": {
        "blocksize": 0,
        "clevel": 5,
        "cname": "lz4",
        "id": "blosc",
        "shuffle": 1
    },
    "dtype": "|O",
    "fill_value": 0,
    "filters": [
        {
            "id": "vlen-utf8"
        }
    ],
    "order": "C",
    "shape": [
        2
    ],
    "zarr_format": 2
}"""
test_dir = Path(tempfile.gettempdir())
with open(test_dir / ".zarray", "w") as f:
    f.write(zarray)

arr = zarr.open(test_dir, mode="r")
pydantic_zarr.v2.ArraySpec.from_zarr(arr)
% python test.py
Traceback (most recent call last):
  File "/Users/dstansby/software/ome-zarr/ome-zarr-models-py/test.py", line 37, in <module>
    pydantic_zarr.v2.ArraySpec.from_zarr(arr)
  File "/Users/dstansby/software/ome-zarr/ome-zarr-models-py/.venv/lib/python3.12/site-packages/pydantic_zarr/v2.py", line 317, in from_zarr
    fill_value=array.dtype.type(array.fill_value).tolist(),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'tolist'
@d-v-b
Copy link
Collaborator

d-v-b commented Dec 10, 2024

oops! looks like I never tested with v2 object dtypes. i'm guessing this is a real bug :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants