Skip to content

Commit 5f06c9e

Browse files
committed
fix tests
1 parent 0183eb5 commit 5f06c9e

File tree

5 files changed

+372
-4
lines changed

5 files changed

+372
-4
lines changed

src/zarr/codecs/_numcodecs.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from zarr.core.common import JSON, parse_named_configuration, product
4141
from zarr.dtype import UInt8, ZDType, parse_dtype
4242
from zarr.errors import ZarrUserWarning
43-
from zarr.registry import get_numcodec
43+
from zarr.registry import get_numcodec, register_codec
4444

4545
if TYPE_CHECKING:
4646
from zarr.abc.numcodec import Numcodec
@@ -326,6 +326,29 @@ class ZFPY(_NumcodecsArrayBytesCodec, codec_name="zfpy"):
326326
pass
327327

328328

329+
# TODO: move the codec registration outside this module
330+
register_codec("numcodecs.bz2", BZ2)
331+
register_codec("numcodecs.crc32", CRC32)
332+
register_codec("numcodecs.crc32c", CRC32C)
333+
register_codec("numcodecs.lz4", LZ4)
334+
register_codec("numcodecs.lzma", LZMA)
335+
register_codec("numcodecs.zfpy", ZFPY)
336+
register_codec("numcodecs.adler32", Adler32)
337+
register_codec("numcodecs.astype", AsType)
338+
register_codec("numcodecs.bitround", BitRound)
339+
register_codec("numcodecs.blosc", Blosc)
340+
register_codec("numcodecs.delta", Delta)
341+
register_codec("numcodecs.fixedscaleoffset", FixedScaleOffset)
342+
register_codec("numcodecs.fletcher32", Fletcher32)
343+
register_codec("numcodecs.gzip", GZip)
344+
register_codec("numcodecs.jenkins_lookup3", JenkinsLookup3)
345+
register_codec("numcodecs.pcodec", PCodec)
346+
register_codec("numcodecs.packbits", PackBits)
347+
register_codec("numcodecs.quantize", Quantize)
348+
register_codec("numcodecs.shuffle", Shuffle)
349+
register_codec("numcodecs.zlib", Zlib)
350+
register_codec("numcodecs.zstd", Zstd)
351+
329352
__all__ = [
330353
"BZ2",
331354
"CRC32",

src/zarr/core/config.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@ def enable_gpu(self) -> ConfigSet:
125125
"transpose": "zarr.codecs.transpose.TransposeCodec",
126126
"vlen-utf8": "zarr.codecs.vlen_utf8.VLenUTF8Codec",
127127
"vlen-bytes": "zarr.codecs.vlen_utf8.VLenBytesCodec",
128+
"numcodecs.bz2": "zarr.codecs._numcodecs.BZ2",
129+
"numcodecs.crc32": "zarr.codecs._numcodecs.CRC32",
130+
"numcodecs.crc32c": "zarr.codecs._numcodecs.CRC32C",
131+
"numcodecs.lz4": "zarr.codecs._numcodecs.LZ4",
132+
"numcodecs.lzma": "zarr.codecs._numcodecs.LZMA",
133+
"numcodecs.zfpy": "zarr.codecs._numcodecs.ZFPY",
134+
"numcodecs.adler32": "zarr.codecs._numcodecs.Adler32",
135+
"numcodecs.astype": "zarr.codecs._numcodecs.AsType",
136+
"numcodecs.bitround": "zarr.codecs._numcodecs.BitRound",
137+
"numcodecs.blosc": "zarr.codecs._numcodecs.Blosc",
138+
"numcodecs.delta": "zarr.codecs._numcodecs.Delta",
139+
"numcodecs.fixedscaleoffset": "zarr.codecs._numcodecs.FixedScaleOffset",
140+
"numcodecs.fletcher32": "zarr.codecs._numcodecs.Fletcher32",
141+
"numcodecs.gZip": "zarr.codecs._numcodecs.GZip",
142+
"numcodecs.jenkins_lookup3": "zarr.codecs._numcodecs.JenkinsLookup3",
143+
"numcodecs.pcodec": "zarr.codecs._numcodecs.PCodec",
144+
"numcodecs.packbits": "zarr.codecs._numcodecs.PackBits",
145+
"numcodecs.shuffle": "zarr.codecs._numcodecs.Shuffle",
146+
"numcodecs.quantize": "zarr.codecs._numcodecs.Quantize",
147+
"numcodecs.zlib": "zarr.codecs._numcodecs.Zlib",
148+
"numcodecs.zstd": "zarr.codecs._numcodecs.Zstd",
128149
},
129150
"buffer": "zarr.buffer.cpu.Buffer",
130151
"ndbuffer": "zarr.buffer.cpu.NDBuffer",

src/zarr/registry.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ def get_codec_class(key: str, reload_config: bool = False) -> type[Codec]:
155155
codec_classes = __codec_registries[key]
156156
if not codec_classes:
157157
raise KeyError(key)
158-
159158
config_entry = config.get("codecs", {}).get(key)
160159
if config_entry is None:
161160
if len(codec_classes) == 1:

tests/test_array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ def test_roundtrip_numcodecs() -> None:
17131713
# Create the array with the correct codecs
17141714
root = zarr.group(store)
17151715
warn_msg = "Numcodecs codecs are not in the Zarr version 3 specification and may not be supported by other zarr implementations."
1716-
with pytest.warns(UserWarning, match=warn_msg):
1716+
with pytest.warns(ZarrUserWarning, match=warn_msg):
17171717
root.create_array(
17181718
"test",
17191719
shape=(720, 1440),
@@ -1728,7 +1728,7 @@ def test_roundtrip_numcodecs() -> None:
17281728
BYTES_CODEC = {"name": "bytes", "configuration": {"endian": "little"}}
17291729
# Read in the array again and check compressor config
17301730
root = zarr.open_group(store)
1731-
with pytest.warns(UserWarning, match=warn_msg):
1731+
with pytest.warns(ZarrUserWarning, match=warn_msg):
17321732
metadata = root["test"].metadata.to_dict()
17331733
expected = (*filters, BYTES_CODEC, *compressors)
17341734
assert metadata["codecs"] == expected

0 commit comments

Comments
 (0)