You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When updating attributes via the z.update_attributes function, existing attributes get deleted instead of merged.
This is wrongly stated by the docs.
See code in zarr.core.array.py -> AsyncArray.update_attributes:
...
Notes------Thismethodisasynchronousandshouldbeawaited.
-Theupdatedattributeswillbemergedwithexistingattributes, andanyconflictswillbeoverwrittenbythenewvalues.
"""
# metadata.attributes is "frozen" so we simply clear and update the dict
self.metadata.attributes.clear()
self.metadata.attributes.update(new_attributes)
# Write new metadata
await self._save_metadata(self.metadata)
return self
I think self.metadata.attributes.clear() just delete everything from the dictionary
Looks like the tests fixed in and some of the comments removed in #2870 suggest this behavior was intended. Kind of seems like an oversight though, because that isn't consistent across update_attributes implementations from what I saw
Zarr version
v3.0.2
Numcodecs version
v.0.15.1
Python Version
3.13
Operating System
Linux
Installation
uv add zarr
Description
When updating attributes via the
z.update_attributes
function, existing attributes get deleted instead of merged.This is wrongly stated by the docs.
See code in zarr.core.array.py -> AsyncArray.update_attributes:
I think
self.metadata.attributes.clear()
just delete everything from the dictionarySteps to reproduce
Outputs:
Additional output
No response
The text was updated successfully, but these errors were encountered: