From 988f9df66d66719332f16c52c23ab0b62722403c Mon Sep 17 00:00:00 2001 From: Ryan Abernathey Date: Mon, 30 Sep 2024 22:09:55 -0400 Subject: [PATCH] fixed tests --- src/zarr/core/metadata/v3.py | 25 ++++++++++++++----------- tests/v3/test_config.py | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/zarr/core/metadata/v3.py b/src/zarr/core/metadata/v3.py index 818a27a7b..52bfdb241 100644 --- a/src/zarr/core/metadata/v3.py +++ b/src/zarr/core/metadata/v3.py @@ -530,14 +530,17 @@ def parse(cls, dtype: None | DataType | Any) -> DataType: return DataType.float64 if isinstance(dtype, DataType): return dtype - else: - try: - dtype = np.dtype(dtype) - except (ValueError, TypeError) as e: - raise ValueError(f"Invalid V3 data_type: {dtype}") from e - # check that this is a valid v3 data_type - try: - data_type = DataType.from_numpy_dtype(dtype) - except KeyError as e: - raise ValueError(f"Invalid V3 data_type: {dtype}") from e - return data_type + try: + return DataType(dtype) + except ValueError: + pass + try: + dtype = np.dtype(dtype) + except (ValueError, TypeError) as e: + raise ValueError(f"Invalid V3 data_type: {dtype}") from e + # check that this is a valid v3 data_type + try: + data_type = DataType.from_numpy_dtype(dtype) + except KeyError as e: + raise ValueError(f"Invalid V3 data_type: {dtype}") from e + return data_type diff --git a/tests/v3/test_config.py b/tests/v3/test_config.py index e324367b3..25b5b4fcd 100644 --- a/tests/v3/test_config.py +++ b/tests/v3/test_config.py @@ -58,6 +58,7 @@ def test_config_defaults_set() -> None: "crc32c": "zarr.codecs.crc32c_.Crc32cCodec", "sharding_indexed": "zarr.codecs.sharding.ShardingCodec", "transpose": "zarr.codecs.transpose.TransposeCodec", + "vlen-utf8": "zarr.codecs.legacy_vlen.VLenUTF8Codec", }, } ]