2121 ZDType ,
2222 data_type_registry ,
2323 get_data_type_from_json ,
24+ parse_data_type ,
2425 parse_dtype ,
2526)
2627
@@ -174,7 +175,7 @@ def test_entrypoint_dtype(zarr_format: ZarrFormat) -> None:
174175@pytest .mark .parametrize ("data_type" , zdtype_examples , ids = str )
175176def test_parse_data_type (data_type : ZDType [Any , Any ], zarr_format : ZarrFormat ) -> None :
176177 """
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
178179 those inputs to the expected ZDType instance.
179180 """
180181 dtype_spec : Any
@@ -189,3 +190,26 @@ def test_parse_data_type(data_type: ZDType[Any, Any], zarr_format: ZarrFormat) -
189190 else :
190191 observed = parse_dtype (dtype_spec , zarr_format = zarr_format )
191192 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