importnumpyasnpfromzarr.storageimportMemoryStore, StorePathfromzarrimportArraystore=StorePath(MemoryStore(mode="w"), path="/")
data=np.arange(0, 8, dtype="uint16")
a=Array.create(
store/"simple_v2",
zarr_format=2,
shape=data.shape,
chunks=(4,),
dtype=data.dtype,
fill_value=0,
)
a.attrs.put({"key": 0})---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[10], line 10
1 data = np.arange(0, 8, dtype="uint16")
2 a = Array.create(
3 store,
4 zarr_format=2,
(...)
8 fill_value=0,
9 )
---> 10 a.attrs.put({"key": 0})
File ~/gh/zarr-developers/zarr-python/src/zarr/core/attributes.py:53, in Attributes.put(self, d)
39defput(self, d: dict[str, JSON]) -> None:
40"""41 Overwrite all attributes with the values from`d`.
42 (...)
51 {'a': 3, 'c': 4}
52"""
---> 53 self._obj = self._obj.update_attributes(d)
File ~/gh/zarr-developers/zarr-python/src/zarr/core/array.py:2318, in Array.update_attributes(self, new_attributes)
2316 def update_attributes(self, new_attributes: dict[str, JSON]) -> Array:
2317 return type(self)(
-> 2318 sync(
2319 self._async_array.update_attributes(new_attributes),
2320 )
2321 )
File ~/gh/zarr-developers/zarr-python/src/zarr/core/sync.py:91, in sync(coro, loop, timeout)
88 return_result =next(iter(finished)).result()
90ifisinstance(return_result, BaseException):
---> 91 raise return_result
92else:
93return return_result
File ~/gh/zarr-developers/zarr-python/src/zarr/core/sync.py:50, in _runner(coro)
45"""46 Await a coroutine andreturn the result of running it. If awaiting the coroutine raises an
47 exception, the exception will be returned.
48"""49try:
---> 50 return await coro
51exceptExceptionas ex:
52return ex
File ~/gh/zarr-developers/zarr-python/src/zarr/core/array.py:753, in AsyncArray.update_attributes(self, new_attributes)
752asyncdefupdate_attributes(self, new_attributes: dict[str, JSON]) -> AsyncArray:
--> 753 new_metadata = self.metadata.update_attributes(new_attributes)
755# Write new metadata756awaitself._save_metadata(new_metadata)
File ~/gh/zarr-developers/zarr-python/src/zarr/core/metadata/v2.py:174, in ArrayV2Metadata.update_attributes(self, attributes)
173defupdate_attributes(self, attributes: dict[str, JSON]) -> Self:
--> 174 return replace(self, attributes=attributes)
File ~/mambaforge/envs/python=3.12/lib/python3.12/dataclasses.py:1588, in replace(obj, **changes)
1581 changes[f.name] = getattr(obj, f.name)
1583 # Create the new object, which calls __init__() and
1584 # __post_init__() (if defined), using all of the init fields we've
1585 # added and/or left in 'changes'. If there are values supplied in
1586 # changes that aren't fields, this will correctly raise a
1587 # TypeError.
-> 1588 return obj.__class__(**changes)
TypeError: ArrayV2Metadata.__init__() got an unexpected keyword argument 'chunk_grid'
Zarr version
v3
Numcodecs version
na
Python Version
na
Operating System
na
Installation
na
Description
data_typeis also affected. IIUC, these are calledchunksanddtypein v2. We need to mark them asdataclasses.field(init=False)or somehow handle renaming them on the way in.Steps to reproduce
raises with
Additional output
No response