Closed
Description
I noticed two issues:
- Zarr raises an exception when attempting to create an array with a structured dtype that contains an object.
>>> import numcodecs
>>> import zarr
>>> foo = zarr.open('foo')
>>> foo.create('bar', dtype=[('x', float), ('y',object)], shape=(10, 20), object_codec=numcodecs.Pickle())
TypeError Traceback (most recent call last)
...
MetadataError: error decoding metadata: Cannot change data-type for object array.
I think that the issue is in the functions encode_fill_value
and decode_fill_value
. A structured dtype that contains an object reports its kind as 'V' so zarr encodes it using standard_b64encode, but if dtype.has_object
is true then it should first pickle the fill_value and only then encode it.
- This is a related problem to item 1. zarr essentially only supports fill-values of
None
for object arrays:
>>> import numpy
>>> import zarr
>>> x = zarr.open('x')
>>> y = x.create('y', shape=(2, 2), dtype='O', fill_value=zarr.Blosc, object_codec=numcodecs.Pickle())
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
...
TypeError: Object of type type is not JSON serializable
- Value of
zarr.__version__
: 2.8.3 - Value of
numcodecs.__version__
: 0.6.4 -- 0.8.0 - Version of Python interpreter: 3.7.4 -- 3.9.6
- Operating system (Linux/Windows/Mac): Mac/Linux
- How Zarr was installed (e.g., "using pip into virtual environment", or "using conda"): pip or conda
Edit: I cleaned up the second example (I copied and pasted an incorrect reproducer here).
Metadata
Metadata
Assignees
Labels
No labels