Skip to content

Commit

Permalink
refactor(v3): Allow for incomplete codec metadata using numcodecs.get…
Browse files Browse the repository at this point in the history
…_codec
  • Loading branch information
jhamman committed Jun 27, 2023
1 parent 327b694 commit 0f1c596
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions zarr/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,26 +441,22 @@ def _decode_codec_metadata(cls, meta: Optional[Mapping]) -> Optional[Codec]:
uri = 'https://purl.org/zarr/spec/codec/'
conf = meta['configuration']
if meta['codec'].startswith(uri + 'gzip/'):
codec = numcodecs.GZip(level=conf['level'])
conf["id"] = "gzip"
elif meta['codec'].startswith(uri + 'zlib/'):
codec = numcodecs.Zlib(level=conf['level'])
conf["id"] = "zlib"
elif meta['codec'].startswith(uri + 'blosc/'):
codec = numcodecs.Blosc(clevel=conf['clevel'],
shuffle=conf['shuffle'],
blocksize=conf['blocksize'],
cname=conf['cname'])
conf["id"] = "blosc"
elif meta['codec'].startswith(uri + 'bz2/'):
codec = numcodecs.BZ2(level=conf['level'])
conf["id"] = "bz2"
elif meta['codec'].startswith(uri + 'lz4/'):
codec = numcodecs.LZ4(acceleration=conf['acceleration'])
conf["id"] = "lz4"
elif meta['codec'].startswith(uri + 'lzma/'):
codec = numcodecs.LZMA(format=conf['format'],
check=conf['check'],
preset=conf['preset'],
filters=conf['filters'])
conf["id"] = "lzma"
else:
raise NotImplementedError

codec = numcodecs.get_codec(conf)

return codec

@classmethod
Expand Down

0 comments on commit 0f1c596

Please sign in to comment.