|
21 | 21 | from zarr.core.dtype.npy.complex import Complex64, Complex128 |
22 | 22 | from zarr.core.dtype.npy.float import Float16, Float32, Float64 |
23 | 23 | from zarr.core.dtype.npy.int import Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64 |
24 | | -from zarr.core.dtype.npy.structured import Structured, StructuredJSON_V2, StructuredJSON_V3 |
| 24 | +from zarr.core.dtype.npy.structured import ( |
| 25 | + Struct, |
| 26 | + StructJSON_V3, |
| 27 | + Structured, |
| 28 | + StructuredJSON_V2, |
| 29 | + StructuredJSON_V3, |
| 30 | +) |
25 | 31 | from zarr.core.dtype.npy.time import ( |
26 | 32 | DateTime64, |
27 | 33 | DateTime64JSON_V2, |
|
75 | 81 | "RawBytes", |
76 | 82 | "RawBytesJSON_V2", |
77 | 83 | "RawBytesJSON_V3", |
| 84 | + "Struct", |
| 85 | + "StructJSON_V3", |
78 | 86 | "Structured", |
79 | 87 | "StructuredJSON_V2", |
80 | 88 | "StructuredJSON_V3", |
|
125 | 133 | | StringDType |
126 | 134 | | BytesDType |
127 | 135 | | Structured |
| 136 | + | Struct |
128 | 137 | | TimeDType |
129 | 138 | | VariableLengthBytes |
130 | 139 | ) |
|
137 | 146 | *COMPLEX_FLOAT_DTYPE, |
138 | 147 | *STRING_DTYPE, |
139 | 148 | *BYTES_DTYPE, |
140 | | - Structured, |
| 149 | + Struct, |
141 | 150 | *TIME_DTYPE, |
142 | 151 | VariableLengthBytes, |
143 | 152 | ) |
|
155 | 164 | # mypy does not know that all the elements of ANY_DTYPE are subclasses of ZDType |
156 | 165 | data_type_registry.register(dtype._zarr_v3_name, dtype) # type: ignore[arg-type] |
157 | 166 |
|
| 167 | +# Register Structured for reading legacy "structured" format JSON, but don't include it in |
| 168 | +# ANY_DTYPE since it doesn't support native dtype matching (use Struct instead). |
| 169 | +data_type_registry.register(Structured._zarr_v3_name, Structured) |
| 170 | + |
158 | 171 |
|
159 | 172 | # TODO: find a better name for this function |
160 | 173 | def get_data_type_from_native_dtype(dtype: npt.DTypeLike) -> ZDType[TBaseDType, TBaseScalar]: |
@@ -268,7 +281,7 @@ def parse_dtype( |
268 | 281 | # First attempt to interpret the input as JSON |
269 | 282 | if isinstance(dtype_spec, Mapping | str | Sequence): |
270 | 283 | try: |
271 | | - return get_data_type_from_json(dtype_spec, zarr_format=zarr_format) # type: ignore[arg-type] |
| 284 | + return get_data_type_from_json(dtype_spec, zarr_format=zarr_format) |
272 | 285 | except ValueError: |
273 | 286 | # no data type matched this JSON-like input |
274 | 287 | pass |
|
0 commit comments