-
-
Notifications
You must be signed in to change notification settings - Fork 363
Closed
Labels
bugPotential issues with the zarr-python libraryPotential issues with the zarr-python library
Description
Zarr version
v3
Numcodecs version
na
Python Version
na
Operating System
na
Installation
na
Description
data_type
is also affected. IIUC, these are called chunks
and dtype
in v2. We need to mark them as dataclasses.field(init=False)
or somehow handle renaming them on the way in.
Steps to reproduce
import numpy as np
from zarr.storage import MemoryStore, StorePath
from zarr import Array
store = 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})
raises with
---------------------------------------------------------------------------
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)
39 def put(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()
90 if isinstance(return_result, BaseException):
---> 91 raise return_result
92 else:
93 return return_result
File ~/gh/zarr-developers/zarr-python/src/zarr/core/sync.py:50, in _runner(coro)
45 """
46 Await a coroutine and return the result of running it. If awaiting the coroutine raises an
47 exception, the exception will be returned.
48 """
49 try:
---> 50 return await coro
51 except Exception as ex:
52 return ex
File ~/gh/zarr-developers/zarr-python/src/zarr/core/array.py:753, in AsyncArray.update_attributes(self, new_attributes)
752 async def update_attributes(self, new_attributes: dict[str, JSON]) -> AsyncArray:
--> 753 new_metadata = self.metadata.update_attributes(new_attributes)
755 # Write new metadata
756 await self._save_metadata(new_metadata)
File ~/gh/zarr-developers/zarr-python/src/zarr/core/metadata/v2.py:174, in ArrayV2Metadata.update_attributes(self, attributes)
173 def update_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'
Additional output
No response
Metadata
Metadata
Assignees
Labels
bugPotential issues with the zarr-python libraryPotential issues with the zarr-python library