Skip to content

Commit 0f9e69e

Browse files
authored
Merge branch 'main' into fix/consistent-create-array-signature
2 parents 3fa6526 + ee60792 commit 0f9e69e

File tree

14 files changed

+133
-46
lines changed

14 files changed

+133
-46
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ci:
66
default_stages: [pre-commit, pre-push]
77
repos:
88
- repo: https://github.com/astral-sh/ruff-pre-commit
9-
rev: v0.9.4
9+
rev: v0.9.9
1010
hooks:
1111
- id: ruff
1212
args: ["--fix", "--show-fixes"]
@@ -22,7 +22,7 @@ repos:
2222
- id: check-yaml
2323
- id: trailing-whitespace
2424
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.14.1
25+
rev: v1.15.0
2626
hooks:
2727
- id: mypy
2828
files: src|tests

changes/2850.fix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed a bug where ``StorePath`` creation would not apply standard path normalization to the ``path`` parameter,
2+
which led to the creation of arrays and groups with invalid keys.

changes/2870.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prevent update_attributes calls from deleting old attributes

docs/user-guide/v3_migration.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,30 @@ The Store class
124124
The Store API has changed significant in Zarr-Python 3. The most notable changes to the
125125
Store API are:
126126

127+
Store Import Paths
128+
^^^^^^^^^^^^^^^^^^
129+
Several store implementations have moved from the top-level module to ``zarr.storage``:
130+
131+
.. code-block:: diff
132+
:caption: Store import changes from v2 to v3
133+
134+
# Before (v2)
135+
- from zarr import MemoryStore, DirectoryStore
136+
+ from zarr.storage import MemoryStore, LocalStore # LocalStore replaces DirectoryStore
137+
138+
Common replacements:
139+
140+
+-------------------------+------------------------------------+
141+
| v2 Import | v3 Import |
142+
+=========================+====================================+
143+
| ``zarr.MemoryStore`` | ``zarr.storage.MemoryStore`` |
144+
+-------------------------+------------------------------------+
145+
| ``zarr.DirectoryStore`` | ``zarr.storage.LocalStore`` |
146+
+-------------------------+------------------------------------+
147+
| ``zarr.TempStore`` | Use ``tempfile.TemporaryDirectory``|
148+
| | with ``LocalStore`` |
149+
+-------------------------+------------------------------------+
150+
127151
1. Replaced the ``MutableMapping`` base class in favor of a custom abstract base class
128152
(:class:`zarr.abc.store.Store`).
129153
2. Switched to an asynchronous interface for all store methods that result in IO. This

src/zarr/codecs/blosc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class BloscCname(Enum):
5555
zlib = "zlib"
5656

5757

58-
# See https://zarr.readthedocs.io/en/stable/tutorial.html#configuring-blosc
58+
# See https://zarr.readthedocs.io/en/stable/user-guide/performance.html#configuring-blosc
5959
numcodecs.blosc.use_threads = False
6060

6161

src/zarr/core/array.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,8 +1609,6 @@ async def update_attributes(self, new_attributes: dict[str, JSON]) -> Self:
16091609
- The updated attributes will be merged with existing attributes, and any conflicts will be
16101610
overwritten by the new values.
16111611
"""
1612-
# metadata.attributes is "frozen" so we simply clear and update the dict
1613-
self.metadata.attributes.clear()
16141612
self.metadata.attributes.update(new_attributes)
16151613

16161614
# Write new metadata

src/zarr/core/attributes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def put(self, d: dict[str, JSON]) -> None:
5050
>>> attrs
5151
{'a': 3, 'c': 4}
5252
"""
53+
self._obj.metadata.attributes.clear()
5354
self._obj = self._obj.update_attributes(d)
5455

5556
def asdict(self) -> dict[str, JSON]:

src/zarr/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import functools
55
import operator
66
import warnings
7-
from collections.abc import Iterable, Mapping
7+
from collections.abc import Iterable, Mapping, Sequence
88
from enum import Enum
99
from itertools import starmap
1010
from typing import (
@@ -37,7 +37,7 @@
3737
ChunkCoordsLike = Iterable[int]
3838
ZarrFormat = Literal[2, 3]
3939
NodeType = Literal["array", "group"]
40-
JSON = str | int | float | Mapping[str, "JSON"] | tuple["JSON", ...] | None
40+
JSON = str | int | float | Mapping[str, "JSON"] | Sequence["JSON"] | None
4141
MemoryOrder = Literal["C", "F"]
4242
AccessModeLiteral = Literal["r", "r+", "a", "w", "w-"]
4343

src/zarr/core/group.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,8 +1263,6 @@ async def update_attributes(self, new_attributes: dict[str, Any]) -> AsyncGroup:
12631263
-------
12641264
self : AsyncGroup
12651265
"""
1266-
# metadata.attributes is "frozen" so we simply clear and update the dict
1267-
self.metadata.attributes.clear()
12681266
self.metadata.attributes.update(new_attributes)
12691267

12701268
# Write new metadata

src/zarr/storage/_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class StorePath:
4141

4242
def __init__(self, store: Store, path: str = "") -> None:
4343
self.store = store
44-
self.path = path
44+
self.path = normalize_path(path)
4545

4646
@property
4747
def read_only(self) -> bool:

0 commit comments

Comments
 (0)