Skip to content

Commit c9229d1

Browse files
committed
fixup
1 parent 96b274c commit c9229d1

File tree

3 files changed

+8
-40
lines changed

3 files changed

+8
-40
lines changed

src/zarr/api/asynchronous.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ async def consolidate_metadata(
162162
163163
By default, the root node is used so all the metadata in the
164164
store is consolidated.
165+
zarr_format : {2, 3, None}, optional
166+
The zarr format of the hierarchy. By default the zarr format
167+
is inferred.
165168
166169
Returns
167170
-------
@@ -662,7 +665,7 @@ async def open_group(
662665
to users. Use `numpy.empty(())` by default.
663666
attributes : dict
664667
A dictionary of JSON-serializable values with user-defined attributes.
665-
use_consolidated : bool or str, default None
668+
use_consolidated : bool or str, default None
666669
Whether to use consolidated metadata.
667670
668671
By default, consolidated metadata is used if it's present in the

src/zarr/core/array.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@
7373
ArrayV3MetadataDict,
7474
T_ArrayMetadata,
7575
)
76+
from zarr.core.metadata.v3 import parse_node_type_array
7677
from zarr.core.sync import collect_aiterator, sync
77-
from zarr.errors import MetadataValidationError, NodeTypeValidationError
78+
from zarr.errors import MetadataValidationError
7879
from zarr.registry import get_pipeline_class
7980
from zarr.storage import StoreLike, make_store_path
8081
from zarr.storage.common import StorePath, ensure_no_existing_node
@@ -166,12 +167,8 @@ async def get_array_metadata(
166167
assert zarr_json_bytes is not None
167168
metadata_dict = json.loads(zarr_json_bytes.to_bytes())
168169

169-
node_type = metadata_dict.get("node_type")
170-
if node_type != "array":
171-
# This KeyError is load bearing for `open`. That currently tries
172-
# to open the node as an `array` and then falls back to opening
173-
# as a group.
174-
raise NodeTypeValidationError("node_type", "array", node_type)
170+
parse_node_type_array(metadata_dict.get("node_type"))
171+
175172
return metadata_dict
176173

177174

src/zarr/core/group.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
import logging
77
from collections import defaultdict
88
from dataclasses import asdict, dataclass, field, fields, replace
9-
from enum import Enum
109
from typing import TYPE_CHECKING, Literal, TypeVar, assert_never, cast, overload
1110

12-
import numcodecs.abc
1311
import numpy as np
1412
import numpy.typing as npt
1513
from typing_extensions import deprecated
@@ -99,36 +97,6 @@ def _parse_async_node(
9997
raise TypeError(f"Unknown node type, got {type(node)}")
10098

10199

102-
def _json_convert(o: object) -> Any:
103-
if isinstance(o, np.dtype):
104-
return str(o)
105-
if np.isscalar(o):
106-
out: Any
107-
if hasattr(o, "dtype") and o.dtype.kind == "M" and hasattr(o, "view"):
108-
# https://github.com/zarr-developers/zarr-python/issues/2119
109-
# `.item()` on a datetime type might or might not return an
110-
# integer, depending on the value.
111-
# Explicitly cast to an int first, and then grab .item()
112-
out = o.view("i8").item()
113-
else:
114-
# convert numpy scalar to python type, and pass
115-
# python types through
116-
out = getattr(o, "item", lambda: o)()
117-
if isinstance(out, complex):
118-
# python complex types are not JSON serializable, so we use the
119-
# serialization defined in the zarr v3 spec
120-
return [out.real, out.imag]
121-
return out
122-
if isinstance(o, Enum):
123-
return o.name
124-
# this serializes numcodecs compressors
125-
# todo: implement to_dict for codecs
126-
elif isinstance(o, numcodecs.abc.Codec):
127-
config: dict[str, Any] = o.get_config()
128-
return config
129-
raise TypeError
130-
131-
132100
@dataclass(frozen=True)
133101
class ConsolidatedMetadata:
134102
"""

0 commit comments

Comments
 (0)