Skip to content

Commit ea3ed12

Browse files
committed
fix bugs, refine structured data type json representation
1 parent d1be08c commit ea3ed12

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/zarr/core/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class from that dict. If the input is a metadata object, return it.
192192
"""
193193

194194
if isinstance(data, ArrayMetadata):
195-
raise
195+
return data
196196
else:
197197
zarr_format = data["zarr_format"]
198198
if zarr_format == 3:

src/zarr/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class GroupMetadataJSON_V3(TypedDict):
139139
zarr_format: Literal[3]
140140
node_type: Literal["group"]
141141
attributes: NotRequired[Mapping[str, JSON]]
142-
consolidated_metadata: NotRequired[ConsolidatedMetadata_JSON_V3]
142+
consolidated_metadata: NotRequired[ConsolidatedMetadata_JSON_V3 | None]
143143

144144

145145
# TODO: use just 1 generic class and parametrize the type of the value type of the metadata

src/zarr/core/dtype/npy/structured.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88

9-
from zarr.core.common import NamedRequiredConfig, StructuredName_V2
9+
from zarr.core.common import NamedConfig, NamedRequiredConfig, StructuredName_V2
1010
from zarr.core.dtype.common import (
1111
DataTypeValidationError,
1212
DTypeConfig_V2,
@@ -56,7 +56,10 @@ class StructuredJSON_V2(DTypeConfig_V2[StructuredName_V2, None]):
5656

5757

5858
class StructuredJSON_V3(
59-
NamedRequiredConfig[Literal["structured"], Mapping[str, Sequence[Sequence[str | DTypeJSON]]]]
59+
NamedRequiredConfig[
60+
Literal["structured"],
61+
Mapping[str, Sequence[list[str | NamedConfig[str, Mapping[str, object]]]]],
62+
]
6063
):
6164
"""
6265
A JSON representation of a structured data type in Zarr V3.

src/zarr/core/group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def from_dict(cls, data: GroupMetadataJSON_V2 | GroupMetadataJSON_V3) -> GroupMe
418418
"""
419419
Create an instance of GroupMetadata from a dict model of Zarr group metadata.
420420
"""
421-
if "consolidated_metadata" in data:
421+
if "consolidated_metadata" in data and data["consolidated_metadata"] is not None:
422422
consolidated_metadata = ConsolidatedMetadata.from_dict(data["consolidated_metadata"])
423423
else:
424424
consolidated_metadata = None

0 commit comments

Comments
 (0)