Skip to content

Commit 0c67e37

Browse files
authored
Merge branch 'main' into extension-keyenc
2 parents 472899f + 62d1a6a commit 0c67e37

File tree

9 files changed

+24
-8
lines changed

9 files changed

+24
-8
lines changed

.github/workflows/check_changelogs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1313

1414
- name: Install uv
15-
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
15+
uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v6.7.0
1616

1717
- name: Check changelog entries
1818
run: uv run --no-sync python ci/check_changelog_entries.py

changes/3444.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Trying to open a group at a path were a array already exists now raises a helpful error.

docs/user-guide/config.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ This is the current default configuration::
6262
'numcodecs.delta': 'zarr.codecs.numcodecs.Delta',
6363
'numcodecs.fixedscaleoffset': 'zarr.codecs.numcodecs.FixedScaleOffset',
6464
'numcodecs.fletcher32': 'zarr.codecs.numcodecs.Fletcher32',
65-
'numcodecs.gZip': 'zarr.codecs.numcodecs.GZip',
65+
'numcodecs.gzip': 'zarr.codecs.numcodecs.GZip',
6666
'numcodecs.jenkins_lookup3': 'zarr.codecs.numcodecs.JenkinsLookup3',
6767
'numcodecs.lz4': 'zarr.codecs.numcodecs.LZ4',
6868
'numcodecs.lzma': 'zarr.codecs.numcodecs.LZMA',

src/zarr/codecs/numcodecs/_codecs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
These codecs were previously defined in :py:mod:`numcodecs`, and have now been moved to `zarr`.
55
6+
>>> import numpy as np
67
>>> import zarr
78
>>> import zarr.codecs.numcodecs as numcodecs
89
>>>
@@ -11,9 +12,9 @@
1112
... shape=(1024, 1024),
1213
... chunks=(64, 64),
1314
... dtype="uint32",
14-
... filters=[numcodecs.zarr3.Delta()],
15-
... compressors=[numcodecs.zarr3.BZ2(level=5)])
16-
>>> array[:] = np.arange(*array.shape).astype(array.dtype)
15+
... filters=[numcodecs.Delta(dtype="uint32")],
16+
... compressors=[numcodecs.BZ2(level=5)])
17+
>>> array[:] = np.arange(np.prod(array.shape), dtype=array.dtype).reshape(*array.shape)
1718
1819
.. note::
1920

src/zarr/core/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def enable_gpu(self) -> ConfigSet:
138138
"numcodecs.delta": "zarr.codecs.numcodecs.Delta",
139139
"numcodecs.fixedscaleoffset": "zarr.codecs.numcodecs.FixedScaleOffset",
140140
"numcodecs.fletcher32": "zarr.codecs.numcodecs.Fletcher32",
141-
"numcodecs.gZip": "zarr.codecs.numcodecs.GZip",
141+
"numcodecs.gzip": "zarr.codecs.numcodecs.GZip",
142142
"numcodecs.jenkins_lookup3": "zarr.codecs.numcodecs.JenkinsLookup3",
143143
"numcodecs.pcodec": "zarr.codecs.numcodecs.PCodec",
144144
"numcodecs.packbits": "zarr.codecs.numcodecs.PackBits",

src/zarr/core/group.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from zarr.errors import (
5454
ContainsArrayError,
5555
ContainsGroupError,
56+
GroupNotFoundError,
5657
MetadataValidationError,
5758
ZarrDeprecationWarning,
5859
ZarrUserWarning,
@@ -673,6 +674,13 @@ def from_dict(
673674
store_path: StorePath,
674675
data: dict[str, Any],
675676
) -> AsyncGroup:
677+
node_type = data.pop("node_type", None)
678+
if node_type == "array":
679+
msg = f"An array already exists in store {store_path.store} at path {store_path.path}."
680+
raise ContainsArrayError(msg)
681+
elif node_type not in ("group", None):
682+
msg = f"Node type in metadata ({node_type}) is not 'group'"
683+
raise GroupNotFoundError(msg)
676684
return cls(
677685
metadata=GroupMetadata.from_dict(data),
678686
store_path=store_path,

tests/test_codecs/test_numcodecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def codec_conf() -> Iterator[Any]:
3535
"numcodecs.delta": "zarr.codecs.numcodecs.Delta",
3636
"numcodecs.fixedscaleoffset": "zarr.codecs.numcodecs.FixedScaleOffset",
3737
"numcodecs.fletcher32": "zarr.codecs.numcodecs.Fletcher32",
38-
"numcodecs.gZip": "zarr.codecs.numcodecs.GZip",
38+
"numcodecs.gzip": "zarr.codecs.numcodecs.GZip",
3939
"numcodecs.jenkinslookup3": "zarr.codecs.numcodecs.JenkinsLookup3",
4040
"numcodecs.pcodec": "zarr.codecs.numcodecs.PCodec",
4141
"numcodecs.packbits": "zarr.codecs.numcodecs.PackBits",

tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_config_defaults_set() -> None:
8686
"numcodecs.delta": "zarr.codecs.numcodecs.Delta",
8787
"numcodecs.fixedscaleoffset": "zarr.codecs.numcodecs.FixedScaleOffset",
8888
"numcodecs.fletcher32": "zarr.codecs.numcodecs.Fletcher32",
89-
"numcodecs.gZip": "zarr.codecs.numcodecs.GZip",
89+
"numcodecs.gzip": "zarr.codecs.numcodecs.GZip",
9090
"numcodecs.jenkins_lookup3": "zarr.codecs.numcodecs.JenkinsLookup3",
9191
"numcodecs.pcodec": "zarr.codecs.numcodecs.PCodec",
9292
"numcodecs.packbits": "zarr.codecs.numcodecs.PackBits",

tests/test_group.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,3 +2234,9 @@ def test_get_roots(roots: tuple[str, ...]):
22342234
}
22352235
data = root_nodes | child_nodes
22362236
assert set(_get_roots(data)) == set(roots)
2237+
2238+
2239+
def test_open_array_as_group():
2240+
z = zarr.create_array(shape=(40, 50), chunks=(10, 10), dtype="f8", store={})
2241+
with pytest.raises(ContainsArrayError):
2242+
zarr.open_group(z.store)

0 commit comments

Comments
 (0)