-
-
Notifications
You must be signed in to change notification settings - Fork 371
Open
Labels
documentationImprovements to the documentationImprovements to the documentation
Description
Minimal, reproducible code sample, a copy-pastable example if possible
import zarr
import numcodecs
import numpy as np
store = zarr.DirectoryStore('example.zarr')
g = zarr.group(store=store, overwrite=True)
d = g.create_dataset('foo', shape=0, chunks=10, dtype=np.int64)
d = g.create_dataset('bar', shape=0, chunks=10, dtype=object, object_codec=numcodecs.JSON())
g['foo'].append([1, 2, 3, 4])
g['bar'].append(["a", "b", "c", "d"])
b = np.array([1,0,0,1], dtype=bool)
g['foo'] = g['foo'][:][b] # Works
g['bar'] = g['bar'][:][b] # Fails, because object_codec not specifiedProblem description
Can't use = to reassign into object arrays in a group. Error is ValueError: missing object_codec for object array, see https://stackoverflow.com/questions/58745967/how-to-cut-down-delete-a-zarr-array and below:
>>> g['bar'] = g['bar'][:][b]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/zarr/hierarchy.py", line 335, in __setitem__
self.array(item, value, overwrite=True)
File "/usr/local/lib/python3.7/site-packages/zarr/hierarchy.py", line 908, in array
return self._write_op(self._array_nosync, name, data, **kwargs)
File "/usr/local/lib/python3.7/site-packages/zarr/hierarchy.py", line 628, in _write_op
return f(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/zarr/hierarchy.py", line 915, in _array_nosync
**kwargs)
File "/usr/local/lib/python3.7/site-packages/zarr/creation.py", line 341, in array
z = create(**kwargs)
File "/usr/local/lib/python3.7/site-packages/zarr/creation.py", line 120, in create
chunk_store=chunk_store, filters=filters, object_codec=object_codec)
File "/usr/local/lib/python3.7/site-packages/zarr/storage.py", line 323, in init_array
object_codec=object_codec)
File "/usr/local/lib/python3.7/site-packages/zarr/storage.py", line 378, in _init_array_metadata
raise ValueError('missing object_codec for object array')
ValueError: missing object_codec for object array
Version and installation information
Please provide the following:
- Value of
zarr.__version__: '2.3.2' - Value of
numcodecs.__version__: '0.6.3' - Version of Python interpreter: Python 3.7.2 (default, Feb 12 2019, 08:15:36)
- Operating system: Mac
- How Zarr was installed: pip3 install zarr
Metadata
Metadata
Assignees
Labels
documentationImprovements to the documentationImprovements to the documentation