Skip to content

Commit 09738fd

Browse files
committed
fix: restore attrs del functionality
1 parent 38a2417 commit 09738fd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/zarr/core/attributes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __setitem__(self, key: str, value: JSON) -> None:
2828
def __delitem__(self, key: str) -> None:
2929
new_attrs = dict(self._obj.metadata.attributes)
3030
del new_attrs[key]
31-
self._obj = self._obj.update_attributes(new_attrs)
31+
self.put(new_attrs)
3232

3333
def __iter__(self) -> Iterator[str]:
3434
return iter(self._obj.metadata.attributes)

tests/test_attributes.py

+9
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ def test_update_no_changes() -> None:
5959

6060
z.update_attributes({})
6161
assert dict(z.attrs) == {"a": [], "b": 3}
62+
63+
64+
def test_del_works() -> None:
65+
store = zarr.storage.MemoryStore()
66+
z = zarr.create(10, store=store, overwrite=True)
67+
assert dict(z.attrs) == {}
68+
z.update_attributes({"a": [3, 4], "c": 4})
69+
del z.attrs["a"]
70+
assert "c" in z.attrs

0 commit comments

Comments
 (0)