Open
Description
This works with V2 data:
zarr.create(shape=10, dtype=">i2", zarr_version=2)
# -> <Array memory://4413530368 shape=(10,) dtype=>i2>
But raises for V3
zarr.create(shape=10, dtype=">i2", zarr_version=3)
File ~/gh/zarr-developers/zarr-python/src/zarr/codecs/__init__.py:40, in _get_default_array_bytes_codec(np_dtype)
37 def _get_default_array_bytes_codec(
38 np_dtype: np.dtype[Any],
39 ) -> BytesCodec | VLenUTF8Codec | VLenBytesCodec:
---> 40 dtype = DataType.from_numpy(np_dtype)
41 if dtype == DataType.string:
42 return VLenUTF8Codec()
File ~/gh/zarr-developers/zarr-python/src/zarr/core/metadata/v3.py:599, in DataType.from_numpy(cls, dtype)
581 return DataType.bytes
582 dtype_to_data_type = {
583 "|b1": "bool",
584 "bool": "bool",
(...)
597 "<c16": "complex128",
598 }
--> 599 return DataType[dtype_to_data_type[dtype.str]]
KeyError: '>i2'
In the V3 spec, endianness is now handled by a codec: https://zarr-specs.readthedocs.io/en/latest/v3/codecs/bytes/v1.0.html
Xarray tests create data with big endian dtypes, and Zarr needs to know how to handle them.