5
5
import numpy as np
6
6
import pytest
7
7
8
- from zarr .codecs import Blosc , Delta , Pickle , Zlib
8
+ from zarr .codecs import Blosc , Delta , Pickle , Zlib , Zstd
9
9
from zarr .errors import MetadataError
10
10
from zarr .meta import (
11
11
ZARR_FORMAT ,
@@ -268,17 +268,23 @@ def test_encode_decode_array_dtype_shape():
268
268
assert meta_dec ["filters" ] is None
269
269
270
270
271
- def test_encode_decode_array_dtype_shape_v3 ():
271
+ @pytest .mark .parametrize ("cname" , ["zlib" , "zstd" ])
272
+ def test_encode_decode_array_dtype_shape_v3 (cname ):
273
+ if cname == "zlib" :
274
+ compressor = Zlib (1 )
275
+ elif cname == "zstd" :
276
+ compressor = Zstd (1 )
272
277
meta = dict (
273
278
shape = (100 ,),
274
279
chunk_grid = dict (type = "regular" , chunk_shape = (10 ,), separator = ("/" )),
275
280
data_type = np .dtype ("(10, 10)<f8" ),
276
- compressor = Zlib ( 1 ) ,
281
+ compressor = compressor ,
277
282
fill_value = None ,
278
283
chunk_memory_layout = "C" ,
279
284
)
280
285
281
- meta_json = """{
286
+ meta_json = (
287
+ """{
282
288
"attributes": {},
283
289
"chunk_grid": {
284
290
"chunk_shape": [10],
@@ -287,7 +293,11 @@ def test_encode_decode_array_dtype_shape_v3():
287
293
},
288
294
"chunk_memory_layout": "C",
289
295
"compressor": {
290
- "codec": "https://purl.org/zarr/spec/codec/zlib/1.0",
296
+ """
297
+ + f"""
298
+ "codec": "https://purl.org/zarr/spec/codec/{ cname } /1.0",
299
+ """
300
+ + """
291
301
"configuration": {
292
302
"level": 1
293
303
}
@@ -297,6 +307,7 @@ def test_encode_decode_array_dtype_shape_v3():
297
307
"fill_value": null,
298
308
"shape": [100, 10, 10 ]
299
309
}"""
310
+ )
300
311
301
312
# test encoding
302
313
meta_enc = Metadata3 .encode_array_metadata (meta )
@@ -315,7 +326,7 @@ def test_encode_decode_array_dtype_shape_v3():
315
326
assert "filters" not in meta_dec
316
327
317
328
318
- @pytest .mark .parametrize ("comp_id" , ["gzip" , "zlib" , "blosc" , "bz2" , "lz4" , "lzma" ])
329
+ @pytest .mark .parametrize ("comp_id" , ["gzip" , "zlib" , "blosc" , "bz2" , "lz4" , "lzma" , "zstd" ])
319
330
def test_decode_metadata_implicit_compressor_config_v3 (comp_id ):
320
331
meta = {
321
332
"attributes" : {},
0 commit comments