Skip to content

Commit d0d5e92

Browse files
committed
make numcodecs codecs backwards compatible
1 parent af6eef9 commit d0d5e92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2569
-703
lines changed

src/zarr/codecs/blosc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def parse_shuffle(data: object) -> BloscShuffle:
170170
return data
171171
if data in BLOSC_SHUFFLE:
172172
return BloscShuffle[data] # type: ignore[misc]
173+
if data in range(len(BLOSC_SHUFFLE)):
174+
return BloscShuffle.from_int(data) # type: ignore[arg-type]
173175
raise TypeError(f"Value must be one of {BLOSC_SHUFFLE}. Got {data} instead.")
174176

175177

src/zarr/codecs/gzip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def to_json(self, zarr_format: ZarrFormat) -> GZipJSON_V2 | GZipJSON_V3:
8080
) # pragma: no cover
8181

8282
@classmethod
83-
def _check_json_v2(cls, data: CodecJSON) -> TypeGuard[GZipJSON_V2]:
83+
def _check_json_v2(cls, data: object) -> TypeGuard[GZipJSON_V2]:
8484
return (
8585
isinstance(data, Mapping)
8686
and set(data.keys()) == {"id", "level"}
@@ -89,7 +89,7 @@ def _check_json_v2(cls, data: CodecJSON) -> TypeGuard[GZipJSON_V2]:
8989
)
9090

9191
@classmethod
92-
def _check_json_v3(cls, data: CodecJSON) -> TypeGuard[GZipJSON_V3]:
92+
def _check_json_v3(cls, data: object) -> TypeGuard[GZipJSON_V3]:
9393
return (
9494
isinstance(data, Mapping)
9595
and set(data.keys()) == {"name", "configuration"}

src/zarr/codecs/numcodecs/__init__.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33
from typing import Final
44

55
from zarr.codecs.numcodecs._codecs import (
6-
BZ2,
7-
CRC32,
8-
CRC32C,
9-
LZ4,
10-
LZMA,
11-
ZFPY,
12-
Adler32,
13-
BitRound,
14-
Blosc,
15-
Fletcher32,
16-
GZip,
17-
JenkinsLookup3,
18-
PackBits,
19-
PCodec,
20-
Quantize,
21-
Shuffle,
22-
Zlib,
23-
Zstd,
246
_NumcodecsArrayArrayCodec,
257
_NumcodecsArrayBytesCodec,
268
_NumcodecsBytesBytesCodec,
279
_NumcodecsCodec,
2810
)
11+
from zarr.codecs.numcodecs.adler32 import Adler32
2912
from zarr.codecs.numcodecs.astype import AsType
13+
from zarr.codecs.numcodecs.bitround import BitRound
14+
from zarr.codecs.numcodecs.blosc import Blosc
15+
from zarr.codecs.numcodecs.bz2 import BZ2
16+
from zarr.codecs.numcodecs.crc32 import CRC32
17+
from zarr.codecs.numcodecs.crc32c import CRC32C
3018
from zarr.codecs.numcodecs.delta import Delta
3119
from zarr.codecs.numcodecs.fixed_scale_offset import FixedScaleOffset
20+
from zarr.codecs.numcodecs.fletcher32 import Fletcher32
21+
from zarr.codecs.numcodecs.gzip import GZip
22+
from zarr.codecs.numcodecs.jenkins_lookup3 import JenkinsLookup3
23+
from zarr.codecs.numcodecs.lz4 import LZ4
24+
from zarr.codecs.numcodecs.lzma import LZMA
25+
from zarr.codecs.numcodecs.packbits import PackBits
26+
from zarr.codecs.numcodecs.pcodec import PCodec
27+
from zarr.codecs.numcodecs.quantize import Quantize
28+
from zarr.codecs.numcodecs.shuffle import Shuffle
29+
from zarr.codecs.numcodecs.zfpy import ZFPY
30+
from zarr.codecs.numcodecs.zlib import Zlib
31+
from zarr.codecs.numcodecs.zstd import Zstd
3232

3333
# This is a fixed dictionary of numcodecs codecs for which we have pre-made Zarr V3 wrappers
3434
NUMCODECS_WRAPPERS: Final[dict[str, type[_NumcodecsCodec]]] = {

0 commit comments

Comments
 (0)