88import pytest
99
1010import zarr
11- from zarr import Array , zeros
12- from zarr .abc .codec import CodecInput , CodecOutput , CodecPipeline
11+ from zarr import Array , zeros , AsyncArray
12+ from zarr .abc .codec import CodecInput , CodecOutput , CodecPipeline , Codec
1313from zarr .abc .store import ByteSetter , Store
1414from zarr .codecs import (
1515 BloscCodec ,
2525from zarr .core .codec_pipeline import BatchedCodecPipeline
2626from zarr .core .config import BadConfigError , config
2727from zarr .core .indexing import SelectorTuple
28+ from zarr .core .strings import _STRING_DTYPE
2829from zarr .registry import (
2930 fully_qualified_name ,
3031 get_buffer_class ,
3637 register_ndbuffer ,
3738 register_pipeline ,
3839)
40+ from zarr .storage import MemoryStore
3941from zarr .testing .buffer import (
4042 NDBufferUsingTestNDArrayLike ,
4143 StoreExpectingTestBuffer ,
@@ -254,8 +256,14 @@ def test_config_buffer_implementation() -> None:
254256 assert np .array_equal (arr_Crc32c [:], data2d )
255257
256258
257- @pytest .mark .parametrize ("dtype" , ["int" , "bytes" , str ])
258- def test_default_codecs (dtype : str ) -> None :
259+ @pytest .mark .parametrize (("dtype" , "expected_codecs" ),
260+ [
261+ ("int" , [BytesCodec (), GzipCodec ()]),
262+ ("bytes" , [VLenBytesCodec ()]),
263+ ("str" , [VLenUTF8Codec ()]),
264+ ]
265+ )
266+ async def test_default_codecs (dtype : str , expected_codecs : list [Codec ]) -> None :
259267 with config .set (
260268 {
261269 "array.v3_default_codecs" : {
@@ -265,10 +273,5 @@ def test_default_codecs(dtype: str) -> None:
265273 }
266274 }
267275 ):
268- arr = zeros (shape = (100 ), dtype = np .dtype (dtype ), zarr_format = 3 )
269- if dtype == "int" :
270- assert arr .metadata .codecs == [BytesCodec (), GzipCodec ()]
271- elif dtype == "bytes" :
272- assert arr .metadata .codecs == [VLenBytesCodec ()]
273- elif dtype == "str" :
274- assert arr .metadata .codecs == [VLenUTF8Codec ()]
276+ arr = await AsyncArray .create (shape = (100 ,), chunk_shape = (100 ,),dtype = np .dtype (dtype ), zarr_format = 3 , store = MemoryStore ())
277+ assert arr .metadata .codecs == expected_codecs
0 commit comments