21
21
ZDType ,
22
22
data_type_registry ,
23
23
get_data_type_from_json ,
24
+ parse_data_type ,
24
25
parse_dtype ,
25
26
)
26
27
@@ -174,7 +175,7 @@ def test_entrypoint_dtype(zarr_format: ZarrFormat) -> None:
174
175
@pytest .mark .parametrize ("data_type" , zdtype_examples , ids = str )
175
176
def test_parse_data_type (data_type : ZDType [Any , Any ], zarr_format : ZarrFormat ) -> None :
176
177
"""
177
- Test that parse_data_type accepts alternative representations of ZDType instances, and resolves
178
+ Test that parse_dtype accepts alternative representations of ZDType instances, and resolves
178
179
those inputs to the expected ZDType instance.
179
180
"""
180
181
dtype_spec : Any
@@ -189,3 +190,26 @@ def test_parse_data_type(data_type: ZDType[Any, Any], zarr_format: ZarrFormat) -
189
190
else :
190
191
observed = parse_dtype (dtype_spec , zarr_format = zarr_format )
191
192
assert observed == data_type
193
+
194
+
195
+ @pytest .mark .filterwarnings ("ignore::zarr.core.dtype.common.UnstableSpecificationWarning" )
196
+ @pytest .mark .parametrize ("data_type" , zdtype_examples , ids = str )
197
+ def test_parse_data_type_funcs (data_type : ZDType [Any , Any ], zarr_format : ZarrFormat ) -> None :
198
+ """
199
+ Test that parse_data_type generates the same output as parse_dtype.
200
+ """
201
+ dtype_spec : Any
202
+ if zarr_format == 2 :
203
+ dtype_spec = data_type .to_json (zarr_format = zarr_format )["name" ]
204
+ else :
205
+ dtype_spec = data_type .to_json (zarr_format = zarr_format )
206
+ if dtype_spec == "|O" :
207
+ msg = "Zarr data type resolution from object failed."
208
+ with pytest .raises (ValueError , match = msg ):
209
+ parse_dtype (dtype_spec , zarr_format = zarr_format )
210
+ with pytest .raises (ValueError , match = msg ):
211
+ parse_data_type (dtype_spec , zarr_format = zarr_format )
212
+ else :
213
+ assert parse_dtype (dtype_spec , zarr_format = zarr_format ) == parse_data_type (
214
+ dtype_spec , zarr_format = zarr_format
215
+ )
0 commit comments