|
11 | 11 | from zarr import Array, zeros |
12 | 12 | from zarr.abc.codec import CodecInput, CodecOutput, CodecPipeline |
13 | 13 | from zarr.abc.store import ByteSetter, Store |
14 | | -from zarr.codecs import BloscCodec, BytesCodec, Crc32cCodec, ShardingCodec |
| 14 | +from zarr.codecs import BloscCodec, BytesCodec, Crc32cCodec, ShardingCodec, TransposeCodec, GzipCodec, VLenBytesCodec, \ |
| 15 | + VLenUTF8Codec |
15 | 16 | from zarr.core.array_spec import ArraySpec |
16 | 17 | from zarr.core.buffer import NDBuffer |
17 | 18 | from zarr.core.codec_pipeline import BatchedCodecPipeline |
@@ -239,3 +240,18 @@ def test_config_buffer_implementation() -> None: |
239 | 240 | ) |
240 | 241 | arr_Crc32c[:] = data2d |
241 | 242 | assert np.array_equal(arr_Crc32c[:], data2d) |
| 243 | + |
| 244 | +@pytest.mark.parametrize("dtype", ["int", "bytes", "str"]) |
| 245 | +def test_default_codecs(dtype:str) -> None: |
| 246 | + with config.set({"array.v3_default_codecs": { |
| 247 | + "numeric": ["bytes", "gzip"], # test setting non-standard codecs |
| 248 | + "string": ["vlen-utf8"], |
| 249 | + "bytes": ["vlen-bytes"], |
| 250 | + }}): |
| 251 | + arr = zeros(shape=(100), store=StoreExpectingTestBuffer(), dtype=dtype) |
| 252 | + if dtype == "int": |
| 253 | + assert arr.metadata.codecs == [BytesCodec(), GzipCodec()] |
| 254 | + elif dtype == "bytes": |
| 255 | + assert arr.metadata.codecs == [VLenBytesCodec()] |
| 256 | + elif dtype == "str": |
| 257 | + assert arr.metadata.codecs == [VLenUTF8Codec()] |
0 commit comments