numcodecs 0.16.1__cp313-cp313-macosx_10_13_x86_64.whl → 0.16.2__cp313-cp313-macosx_10_13_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of numcodecs might be problematic. Click here for more details.
- numcodecs/_shuffle.cpython-313-darwin.so +0 -0
- numcodecs/abc.py +1 -2
- numcodecs/blosc.cpython-313-darwin.so +0 -0
- numcodecs/checksum32.py +2 -2
- numcodecs/compat_ext.cpython-313-darwin.so +0 -0
- numcodecs/fletcher32.cpython-313-darwin.so +0 -0
- numcodecs/jenkins.cpython-313-darwin.so +0 -0
- numcodecs/lz4.cpython-313-darwin.so +0 -0
- numcodecs/lzma.py +1 -2
- numcodecs/tests/test_pyzstd.py +77 -0
- numcodecs/tests/test_zarr3.py +12 -12
- numcodecs/tests/test_zstd.py +72 -6
- numcodecs/version.py +2 -2
- numcodecs/vlen.cpython-313-darwin.so +0 -0
- numcodecs/zarr3.py +42 -12
- numcodecs/zfpy.py +1 -2
- numcodecs/zstd.cpython-313-darwin.so +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/METADATA +2 -1
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/RECORD +31 -30
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/WHEEL +1 -1
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/entry_points.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/LICENSE.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSE.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/BITSHUFFLE.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/FASTLZ.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/LZ4.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/SNAPPY.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/STDINT.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/ZLIB-NG.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/ZLIB.txt +0 -0
- {numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/top_level.txt +0 -0
|
Binary file
|
numcodecs/abc.py
CHANGED
|
@@ -29,14 +29,13 @@ other and vice versa.
|
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
31
|
from abc import ABC, abstractmethod
|
|
32
|
-
from typing import Optional
|
|
33
32
|
|
|
34
33
|
|
|
35
34
|
class Codec(ABC):
|
|
36
35
|
"""Codec abstract base class."""
|
|
37
36
|
|
|
38
37
|
# override in sub-class
|
|
39
|
-
codec_id:
|
|
38
|
+
codec_id: str | None = None
|
|
40
39
|
"""Codec identifier."""
|
|
41
40
|
|
|
42
41
|
@abstractmethod
|
|
Binary file
|
numcodecs/checksum32.py
CHANGED
|
@@ -3,7 +3,7 @@ import struct
|
|
|
3
3
|
import zlib
|
|
4
4
|
from contextlib import suppress
|
|
5
5
|
from types import ModuleType
|
|
6
|
-
from typing import Literal
|
|
6
|
+
from typing import Literal
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
from typing_extensions import Buffer
|
|
@@ -12,7 +12,7 @@ from .abc import Codec
|
|
|
12
12
|
from .compat import ensure_contiguous_ndarray, ndarray_copy
|
|
13
13
|
from .jenkins import jenkins_lookup3
|
|
14
14
|
|
|
15
|
-
_crc32c:
|
|
15
|
+
_crc32c: ModuleType | None = None
|
|
16
16
|
with suppress(ImportError):
|
|
17
17
|
import crc32c as _crc32c # type: ignore[no-redef, unused-ignore]
|
|
18
18
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
numcodecs/lzma.py
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Check Zstd against pyzstd package
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
import pyzstd
|
|
6
|
+
|
|
7
|
+
from numcodecs.zstd import Zstd
|
|
8
|
+
|
|
9
|
+
test_data = [
|
|
10
|
+
b"Hello World!",
|
|
11
|
+
np.arange(113).tobytes(),
|
|
12
|
+
np.arange(10, 15).tobytes(),
|
|
13
|
+
np.random.randint(3, 50, size=(53,), dtype=np.uint16).tobytes(),
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.mark.parametrize("input", test_data)
|
|
18
|
+
def test_pyzstd_simple(input):
|
|
19
|
+
"""
|
|
20
|
+
Test if Zstd.[decode, encode] can perform the inverse operation to
|
|
21
|
+
pyzstd.[compress, decompress] in the simple case.
|
|
22
|
+
"""
|
|
23
|
+
z = Zstd()
|
|
24
|
+
assert z.decode(pyzstd.compress(input)) == input
|
|
25
|
+
assert pyzstd.decompress(z.encode(input)) == input
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@pytest.mark.xfail
|
|
29
|
+
@pytest.mark.parametrize("input", test_data)
|
|
30
|
+
def test_pyzstd_simple_multiple_frames_decode(input):
|
|
31
|
+
"""
|
|
32
|
+
Test decompression of two concatenated frames of known sizes
|
|
33
|
+
|
|
34
|
+
numcodecs.zstd.Zstd currently fails because it only assesses the size of the
|
|
35
|
+
first frame. Rather, it should keep iterating through all the frames until
|
|
36
|
+
the end of the input buffer.
|
|
37
|
+
"""
|
|
38
|
+
z = Zstd()
|
|
39
|
+
assert pyzstd.decompress(pyzstd.compress(input) * 2) == input * 2
|
|
40
|
+
assert z.decode(pyzstd.compress(input) * 2) == input * 2
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@pytest.mark.parametrize("input", test_data)
|
|
44
|
+
def test_pyzstd_simple_multiple_frames_encode(input):
|
|
45
|
+
"""
|
|
46
|
+
Test if pyzstd can decompress two concatenated frames from Zstd.encode
|
|
47
|
+
"""
|
|
48
|
+
z = Zstd()
|
|
49
|
+
assert pyzstd.decompress(z.encode(input) * 2) == input * 2
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@pytest.mark.parametrize("input", test_data)
|
|
53
|
+
def test_pyzstd_streaming(input):
|
|
54
|
+
"""
|
|
55
|
+
Test if Zstd can decode a single frame and concatenated frames in streaming
|
|
56
|
+
mode where the decompressed size is not recorded in the frame header.
|
|
57
|
+
"""
|
|
58
|
+
pyzstd_c = pyzstd.ZstdCompressor()
|
|
59
|
+
pyzstd_d = pyzstd.ZstdDecompressor()
|
|
60
|
+
pyzstd_e = pyzstd.EndlessZstdDecompressor()
|
|
61
|
+
z = Zstd()
|
|
62
|
+
|
|
63
|
+
d_bytes = input
|
|
64
|
+
pyzstd_c.compress(d_bytes)
|
|
65
|
+
c_bytes = pyzstd_c.flush()
|
|
66
|
+
assert z.decode(c_bytes) == d_bytes
|
|
67
|
+
assert pyzstd_d.decompress(z.encode(d_bytes)) == d_bytes
|
|
68
|
+
|
|
69
|
+
# Test multiple streaming frames
|
|
70
|
+
assert z.decode(c_bytes * 2) == pyzstd_e.decompress(c_bytes * 2)
|
|
71
|
+
assert z.decode(c_bytes * 3) == pyzstd_e.decompress(c_bytes * 3)
|
|
72
|
+
assert z.decode(c_bytes * 4) == pyzstd_e.decompress(c_bytes * 4)
|
|
73
|
+
assert z.decode(c_bytes * 5) == pyzstd_e.decompress(c_bytes * 5)
|
|
74
|
+
assert z.decode(c_bytes * 7) == pyzstd_e.decompress(c_bytes * 7)
|
|
75
|
+
assert z.decode(c_bytes * 11) == pyzstd_e.decompress(c_bytes * 11)
|
|
76
|
+
assert z.decode(c_bytes * 13) == pyzstd_e.decompress(c_bytes * 13)
|
|
77
|
+
assert z.decode(c_bytes * 99) == pyzstd_e.decompress(c_bytes * 99)
|
numcodecs/tests/test_zarr3.py
CHANGED
|
@@ -122,8 +122,8 @@ def test_generic_filter(
|
|
|
122
122
|
],
|
|
123
123
|
)
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
a[:, :] = data.copy()
|
|
126
|
+
a = zarr.open_array(store / "generic", mode="r")
|
|
127
127
|
np.testing.assert_array_equal(data, a[:, :])
|
|
128
128
|
|
|
129
129
|
|
|
@@ -140,8 +140,8 @@ def test_generic_filter_bitround(store: StorePath):
|
|
|
140
140
|
filters=[numcodecs.zarr3.BitRound(keepbits=3)],
|
|
141
141
|
)
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
a[:, :] = data.copy()
|
|
144
|
+
a = zarr.open_array(store / "generic_bitround", mode="r")
|
|
145
145
|
assert np.allclose(data, a[:, :], atol=0.1)
|
|
146
146
|
|
|
147
147
|
|
|
@@ -158,8 +158,8 @@ def test_generic_filter_quantize(store: StorePath):
|
|
|
158
158
|
filters=[numcodecs.zarr3.Quantize(digits=3)],
|
|
159
159
|
)
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
a[:, :] = data.copy()
|
|
162
|
+
a = zarr.open_array(store / "generic_quantize", mode="r")
|
|
163
163
|
assert np.allclose(data, a[:, :], atol=0.001)
|
|
164
164
|
|
|
165
165
|
|
|
@@ -177,8 +177,8 @@ def test_generic_filter_packbits(store: StorePath):
|
|
|
177
177
|
filters=[numcodecs.zarr3.PackBits()],
|
|
178
178
|
)
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
a[:, :] = data.copy()
|
|
181
|
+
a = zarr.open_array(store / "generic_packbits", mode="r")
|
|
182
182
|
np.testing.assert_array_equal(data, a[:, :])
|
|
183
183
|
|
|
184
184
|
with pytest.raises(ValueError, match=".*requires bool dtype.*"):
|
|
@@ -217,8 +217,8 @@ def test_generic_checksum(
|
|
|
217
217
|
compressors=[codec_class()],
|
|
218
218
|
)
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
a[:, :] = data.copy()
|
|
221
|
+
a = zarr.open_array(store / "generic_checksum", mode="r")
|
|
222
222
|
np.testing.assert_array_equal(data, a[:, :])
|
|
223
223
|
|
|
224
224
|
|
|
@@ -267,8 +267,8 @@ def test_delta_astype(store: StorePath):
|
|
|
267
267
|
],
|
|
268
268
|
)
|
|
269
269
|
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
a[:, :] = data.copy()
|
|
271
|
+
a = zarr.open_array(store / "generic", mode="r")
|
|
272
272
|
np.testing.assert_array_equal(data, a[:, :])
|
|
273
273
|
|
|
274
274
|
|
numcodecs/tests/test_zstd.py
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import itertools
|
|
2
|
+
import subprocess
|
|
2
3
|
|
|
3
4
|
import numpy as np
|
|
4
5
|
import pytest
|
|
5
6
|
|
|
6
|
-
try:
|
|
7
|
-
from numcodecs.zstd import Zstd
|
|
8
|
-
except ImportError: # pragma: no cover
|
|
9
|
-
pytest.skip("numcodecs.zstd not available", allow_module_level=True)
|
|
10
|
-
|
|
11
|
-
|
|
12
7
|
from numcodecs.tests.common import (
|
|
13
8
|
check_backwards_compatibility,
|
|
14
9
|
check_config,
|
|
@@ -17,6 +12,7 @@ from numcodecs.tests.common import (
|
|
|
17
12
|
check_err_encode_object_buffer,
|
|
18
13
|
check_repr,
|
|
19
14
|
)
|
|
15
|
+
from numcodecs.zstd import Zstd
|
|
20
16
|
|
|
21
17
|
codecs = [
|
|
22
18
|
Zstd(),
|
|
@@ -90,3 +86,73 @@ def test_native_functions():
|
|
|
90
86
|
assert Zstd.default_level() == 3
|
|
91
87
|
assert Zstd.min_level() == -131072
|
|
92
88
|
assert Zstd.max_level() == 22
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_streaming_decompression():
|
|
92
|
+
# Test input frames with unknown frame content size
|
|
93
|
+
codec = Zstd()
|
|
94
|
+
|
|
95
|
+
# If the zstd command line interface is available, check the bytes
|
|
96
|
+
cli = zstd_cli_available()
|
|
97
|
+
if cli:
|
|
98
|
+
view_zstd_streaming_bytes()
|
|
99
|
+
|
|
100
|
+
# Encode bytes directly that were the result of streaming compression
|
|
101
|
+
bytes_val = b'(\xb5/\xfd\x00Xa\x00\x00Hello World!'
|
|
102
|
+
dec = codec.decode(bytes_val)
|
|
103
|
+
dec_expected = b'Hello World!'
|
|
104
|
+
assert dec == dec_expected
|
|
105
|
+
if cli:
|
|
106
|
+
assert bytes_val == generate_zstd_streaming_bytes(dec_expected)
|
|
107
|
+
assert dec_expected == generate_zstd_streaming_bytes(bytes_val, decompress=True)
|
|
108
|
+
|
|
109
|
+
# Two consecutive frames given as input
|
|
110
|
+
bytes2 = bytes(bytearray(bytes_val * 2))
|
|
111
|
+
dec2 = codec.decode(bytes2)
|
|
112
|
+
dec2_expected = b'Hello World!Hello World!'
|
|
113
|
+
assert dec2 == dec2_expected
|
|
114
|
+
if cli:
|
|
115
|
+
assert dec2_expected == generate_zstd_streaming_bytes(bytes2, decompress=True)
|
|
116
|
+
|
|
117
|
+
# Single long frame that decompresses to a large output
|
|
118
|
+
bytes3 = b'(\xb5/\xfd\x00X$\x02\x00\xa4\x03ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz\x01\x00:\xfc\xdfs\x05\x05L\x00\x00\x08s\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08k\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08c\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08[\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08S\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08K\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08C\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08u\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08m\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08e\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08]\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08U\x01\x00\xfc\xff9\x10\x02L\x00\x00\x08M\x01\x00\xfc\xff9\x10\x02M\x00\x00\x08E\x01\x00\xfc\x7f\x1d\x08\x01'
|
|
119
|
+
dec3 = codec.decode(bytes3)
|
|
120
|
+
dec3_expected = b'ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz' * 1024 * 32
|
|
121
|
+
assert dec3 == dec3_expected
|
|
122
|
+
if cli:
|
|
123
|
+
assert bytes3 == generate_zstd_streaming_bytes(dec3_expected)
|
|
124
|
+
assert dec3_expected == generate_zstd_streaming_bytes(bytes3, decompress=True)
|
|
125
|
+
|
|
126
|
+
# Garbage input results in an error
|
|
127
|
+
bytes4 = bytes(bytearray([0, 0, 0, 0, 0, 0, 0, 0]))
|
|
128
|
+
with pytest.raises(RuntimeError, match='Zstd decompression error: invalid input data'):
|
|
129
|
+
codec.decode(bytes4)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def generate_zstd_streaming_bytes(input: bytes, *, decompress: bool = False) -> bytes:
|
|
133
|
+
"""
|
|
134
|
+
Use the zstd command line interface to compress or decompress bytes in streaming mode.
|
|
135
|
+
"""
|
|
136
|
+
if decompress:
|
|
137
|
+
args = ["-d"]
|
|
138
|
+
else:
|
|
139
|
+
args = []
|
|
140
|
+
|
|
141
|
+
p = subprocess.run(["zstd", "--no-check", *args], input=input, capture_output=True)
|
|
142
|
+
return p.stdout
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def view_zstd_streaming_bytes():
|
|
146
|
+
bytes_val = generate_zstd_streaming_bytes(b"Hello world!")
|
|
147
|
+
print(f" bytes_val = {bytes_val}")
|
|
148
|
+
|
|
149
|
+
bytes3 = generate_zstd_streaming_bytes(
|
|
150
|
+
b"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz" * 1024 * 32
|
|
151
|
+
)
|
|
152
|
+
print(f" bytes3 = {bytes3}")
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def zstd_cli_available() -> bool:
|
|
156
|
+
return not subprocess.run(
|
|
157
|
+
["zstd", "-V"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
|
158
|
+
).returncode
|
numcodecs/version.py
CHANGED
|
Binary file
|
numcodecs/zarr3.py
CHANGED
|
@@ -29,17 +29,19 @@ import asyncio
|
|
|
29
29
|
import math
|
|
30
30
|
from dataclasses import dataclass, replace
|
|
31
31
|
from functools import cached_property
|
|
32
|
+
from importlib.metadata import version
|
|
32
33
|
from typing import Any, Self
|
|
33
34
|
from warnings import warn
|
|
34
35
|
|
|
35
36
|
import numpy as np
|
|
37
|
+
from packaging.version import Version
|
|
36
38
|
|
|
37
39
|
import numcodecs
|
|
38
40
|
|
|
39
41
|
try:
|
|
40
|
-
import zarr
|
|
42
|
+
import zarr # noqa: F401
|
|
41
43
|
|
|
42
|
-
if zarr
|
|
44
|
+
if Version(version('zarr')) < Version("3.0.0"): # pragma: no cover
|
|
43
45
|
raise ImportError("zarr 3.0.0 or later is required to use the numcodecs zarr integration.")
|
|
44
46
|
except ImportError as e: # pragma: no cover
|
|
45
47
|
raise ImportError(
|
|
@@ -56,6 +58,23 @@ from zarr.core.common import JSON, parse_named_configuration, product
|
|
|
56
58
|
CODEC_PREFIX = "numcodecs."
|
|
57
59
|
|
|
58
60
|
|
|
61
|
+
def _from_zarr_dtype(dtype: Any) -> np.dtype:
|
|
62
|
+
"""
|
|
63
|
+
Get a numpy data type from an array spec, depending on the zarr version.
|
|
64
|
+
"""
|
|
65
|
+
if Version(version('zarr')) >= Version("3.1.0"):
|
|
66
|
+
return dtype.to_native_dtype()
|
|
67
|
+
return dtype # pragma: no cover
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _to_zarr_dtype(dtype: np.dtype) -> Any:
|
|
71
|
+
if Version(version('zarr')) >= Version("3.1.0"):
|
|
72
|
+
from zarr.dtype import parse_data_type
|
|
73
|
+
|
|
74
|
+
return parse_data_type(dtype, zarr_format=3)
|
|
75
|
+
return dtype # pragma: no cover
|
|
76
|
+
|
|
77
|
+
|
|
59
78
|
def _expect_name_prefix(codec_name: str) -> str:
|
|
60
79
|
if not codec_name.startswith(CODEC_PREFIX):
|
|
61
80
|
raise ValueError(
|
|
@@ -224,7 +243,8 @@ class LZMA(_NumcodecsBytesBytesCodec, codec_name="lzma"):
|
|
|
224
243
|
class Shuffle(_NumcodecsBytesBytesCodec, codec_name="shuffle"):
|
|
225
244
|
def evolve_from_array_spec(self, array_spec: ArraySpec) -> Shuffle:
|
|
226
245
|
if self.codec_config.get("elementsize") is None:
|
|
227
|
-
|
|
246
|
+
dtype = _from_zarr_dtype(array_spec.dtype)
|
|
247
|
+
return Shuffle(**{**self.codec_config, "elementsize": dtype.itemsize})
|
|
228
248
|
return self # pragma: no cover
|
|
229
249
|
|
|
230
250
|
|
|
@@ -232,7 +252,8 @@ class Shuffle(_NumcodecsBytesBytesCodec, codec_name="shuffle"):
|
|
|
232
252
|
class Delta(_NumcodecsArrayArrayCodec, codec_name="delta"):
|
|
233
253
|
def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
|
|
234
254
|
if astype := self.codec_config.get("astype"):
|
|
235
|
-
|
|
255
|
+
dtype = _to_zarr_dtype(np.dtype(astype)) # type: ignore[call-overload]
|
|
256
|
+
return replace(chunk_spec, dtype=dtype)
|
|
236
257
|
return chunk_spec
|
|
237
258
|
|
|
238
259
|
|
|
@@ -243,12 +264,14 @@ class BitRound(_NumcodecsArrayArrayCodec, codec_name="bitround"):
|
|
|
243
264
|
class FixedScaleOffset(_NumcodecsArrayArrayCodec, codec_name="fixedscaleoffset"):
|
|
244
265
|
def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
|
|
245
266
|
if astype := self.codec_config.get("astype"):
|
|
246
|
-
|
|
267
|
+
dtype = _to_zarr_dtype(np.dtype(astype)) # type: ignore[call-overload]
|
|
268
|
+
return replace(chunk_spec, dtype=dtype)
|
|
247
269
|
return chunk_spec
|
|
248
270
|
|
|
249
271
|
def evolve_from_array_spec(self, array_spec: ArraySpec) -> FixedScaleOffset:
|
|
250
272
|
if self.codec_config.get("dtype") is None:
|
|
251
|
-
|
|
273
|
+
dtype = _from_zarr_dtype(array_spec.dtype)
|
|
274
|
+
return FixedScaleOffset(**{**self.codec_config, "dtype": str(dtype)})
|
|
252
275
|
return self
|
|
253
276
|
|
|
254
277
|
|
|
@@ -258,7 +281,8 @@ class Quantize(_NumcodecsArrayArrayCodec, codec_name="quantize"):
|
|
|
258
281
|
|
|
259
282
|
def evolve_from_array_spec(self, array_spec: ArraySpec) -> Quantize:
|
|
260
283
|
if self.codec_config.get("dtype") is None:
|
|
261
|
-
|
|
284
|
+
dtype = _from_zarr_dtype(array_spec.dtype)
|
|
285
|
+
return Quantize(**{**self.codec_config, "dtype": str(dtype)})
|
|
262
286
|
return self
|
|
263
287
|
|
|
264
288
|
|
|
@@ -267,21 +291,27 @@ class PackBits(_NumcodecsArrayArrayCodec, codec_name="packbits"):
|
|
|
267
291
|
return replace(
|
|
268
292
|
chunk_spec,
|
|
269
293
|
shape=(1 + math.ceil(product(chunk_spec.shape) / 8),),
|
|
270
|
-
dtype=np.dtype("uint8"),
|
|
294
|
+
dtype=_to_zarr_dtype(np.dtype("uint8")),
|
|
271
295
|
)
|
|
272
296
|
|
|
273
|
-
|
|
274
|
-
|
|
297
|
+
# todo: remove this type: ignore when this class can be defined w.r.t.
|
|
298
|
+
# a single zarr dtype API
|
|
299
|
+
def validate(self, *, dtype: np.dtype[Any], **_kwargs) -> None: # type: ignore[override]
|
|
300
|
+
_dtype = _from_zarr_dtype(dtype)
|
|
301
|
+
if _dtype != np.dtype("bool"):
|
|
275
302
|
raise ValueError(f"Packbits filter requires bool dtype. Got {dtype}.")
|
|
276
303
|
|
|
277
304
|
|
|
278
305
|
class AsType(_NumcodecsArrayArrayCodec, codec_name="astype"):
|
|
279
306
|
def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
|
|
280
|
-
|
|
307
|
+
dtype = _to_zarr_dtype(np.dtype(self.codec_config["encode_dtype"])) # type: ignore[arg-type]
|
|
308
|
+
return replace(chunk_spec, dtype=dtype)
|
|
281
309
|
|
|
282
310
|
def evolve_from_array_spec(self, array_spec: ArraySpec) -> AsType:
|
|
283
311
|
if self.codec_config.get("decode_dtype") is None:
|
|
284
|
-
|
|
312
|
+
# TODO: remove these coverage exemptions the correct way, i.e. with tests
|
|
313
|
+
dtype = _from_zarr_dtype(array_spec.dtype) # pragma: no cover
|
|
314
|
+
return AsType(**{**self.codec_config, "decode_dtype": str(dtype)}) # pragma: no cover
|
|
285
315
|
return self
|
|
286
316
|
|
|
287
317
|
|
numcodecs/zfpy.py
CHANGED
|
@@ -2,9 +2,8 @@ import warnings
|
|
|
2
2
|
from contextlib import suppress
|
|
3
3
|
from importlib.metadata import PackageNotFoundError, version
|
|
4
4
|
from types import ModuleType
|
|
5
|
-
from typing import Optional
|
|
6
5
|
|
|
7
|
-
_zfpy:
|
|
6
|
+
_zfpy: ModuleType | None = None
|
|
8
7
|
|
|
9
8
|
_zfpy_version: tuple = ()
|
|
10
9
|
with suppress(PackageNotFoundError):
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: numcodecs
|
|
3
|
-
Version: 0.16.
|
|
3
|
+
Version: 0.16.2
|
|
4
4
|
Summary: A Python package providing buffer compression and transformation codecs for use in data storage and communication applications.
|
|
5
5
|
Maintainer-email: Alistair Miles <alimanfoo@googlemail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -39,6 +39,7 @@ Provides-Extra: test
|
|
|
39
39
|
Requires-Dist: coverage; extra == "test"
|
|
40
40
|
Requires-Dist: pytest; extra == "test"
|
|
41
41
|
Requires-Dist: pytest-cov; extra == "test"
|
|
42
|
+
Requires-Dist: pyzstd; extra == "test"
|
|
42
43
|
Provides-Extra: test-extras
|
|
43
44
|
Requires-Dist: importlib_metadata; extra == "test-extras"
|
|
44
45
|
Provides-Extra: msgpack
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
numcodecs-0.16.
|
|
2
|
-
numcodecs-0.16.
|
|
3
|
-
numcodecs-0.16.
|
|
4
|
-
numcodecs-0.16.
|
|
5
|
-
numcodecs-0.16.
|
|
6
|
-
numcodecs-0.16.
|
|
7
|
-
numcodecs-0.16.
|
|
8
|
-
numcodecs-0.16.
|
|
9
|
-
numcodecs-0.16.
|
|
10
|
-
numcodecs-0.16.
|
|
11
|
-
numcodecs-0.16.
|
|
12
|
-
numcodecs-0.16.
|
|
13
|
-
numcodecs-0.16.
|
|
14
|
-
numcodecs-0.16.
|
|
15
|
-
numcodecs/blosc.cpython-313-darwin.so,sha256=
|
|
16
|
-
numcodecs/lzma.py,sha256=
|
|
1
|
+
numcodecs-0.16.2.dist-info/RECORD,,
|
|
2
|
+
numcodecs-0.16.2.dist-info/WHEEL,sha256=0rn5ODYhsjI3KEHrk9RXNWLZT7Rowo6wA0Jh2iAIJLk,138
|
|
3
|
+
numcodecs-0.16.2.dist-info/entry_points.txt,sha256=3W3FHKrwE52X3fLq8KdioOtf93lh5KaoGV5t2D10DBI,919
|
|
4
|
+
numcodecs-0.16.2.dist-info/top_level.txt,sha256=JkHllzt6IuVudg4Tk--wF-yfPPsdVOiMTag1tjGIihw,10
|
|
5
|
+
numcodecs-0.16.2.dist-info/METADATA,sha256=cyWrDyPJ7I1bwRDkNHGz2pTcVj70KhsfM6VW0u2kJE4,3290
|
|
6
|
+
numcodecs-0.16.2.dist-info/licenses/LICENSE.txt,sha256=lJysaEeeE7bJeSRjUVC04e9eaXZq2eRy6oWgjBV2u5Y,1124
|
|
7
|
+
numcodecs-0.16.2.dist-info/licenses/c-blosc/LICENSE.txt,sha256=ImIxMam59qhqTca5vMux0q6zkN-GvKAPxyevJHNcL64,1644
|
|
8
|
+
numcodecs-0.16.2.dist-info/licenses/c-blosc/LICENSES/SNAPPY.txt,sha256=UiGjaoAbmB-9_ae4fbZM_yMaO4giOgZsMlQRtTnfeW8,1475
|
|
9
|
+
numcodecs-0.16.2.dist-info/licenses/c-blosc/LICENSES/FASTLZ.txt,sha256=z1KQnm7XcP6BURumLU6-4TGF0wo30P194rVmheKIqzg,1135
|
|
10
|
+
numcodecs-0.16.2.dist-info/licenses/c-blosc/LICENSES/ZLIB.txt,sha256=hF78d4V9SF2R-z4LiEqqkpNoxxeugYa2b-HtJJV1MkM,1002
|
|
11
|
+
numcodecs-0.16.2.dist-info/licenses/c-blosc/LICENSES/BITSHUFFLE.txt,sha256=7zV8IGHPZ9spj58VZVcu4imtkmNYKp-dDr_1CU9dEKw,1148
|
|
12
|
+
numcodecs-0.16.2.dist-info/licenses/c-blosc/LICENSES/ZLIB-NG.txt,sha256=-K03V7wq6fWmr3fhOzelchOXQhzlWrFuHaSeRikmTSw,893
|
|
13
|
+
numcodecs-0.16.2.dist-info/licenses/c-blosc/LICENSES/LZ4.txt,sha256=_m3B8n9o2d1rAZLjm-Go8fvtD-huE1QPYYpxM5cbELM,1312
|
|
14
|
+
numcodecs-0.16.2.dist-info/licenses/c-blosc/LICENSES/STDINT.txt,sha256=8q8D21YuiFOfAZsasIgYeO6C0MgPO85oxlAGRlLiXXs,1568
|
|
15
|
+
numcodecs/blosc.cpython-313-darwin.so,sha256=no-PYDxllRuX3EkYzR-AHeQEVEXKHQomZNclegfLlT0,3108392
|
|
16
|
+
numcodecs/lzma.py,sha256=AsIzH_VkKs6Uj3xoP908j82pdTugxiX3MjaRiqWQw8k,2226
|
|
17
17
|
numcodecs/astype.py,sha256=pfdFqjNvb-PETswa2_UxZm632O-y2Lex-g_68IJpiuk,2099
|
|
18
18
|
numcodecs/gzip.py,sha256=DJuc87g8neqn-SYEeCEQwPSdEN5oZGgDUan9MTI6Fb4,1436
|
|
19
|
-
numcodecs/lz4.cpython-313-darwin.so,sha256=
|
|
19
|
+
numcodecs/lz4.cpython-313-darwin.so,sha256=jrAJMv-_GGYNJw7lt_AlWmMyXftWLVVD83NPYY0bX0I,637200
|
|
20
20
|
numcodecs/base64.py,sha256=79BSqVvloKc8JYenUQfqdPm0a0JAZhd9Zld7k5Cp2lc,752
|
|
21
21
|
numcodecs/bz2.py,sha256=4Ups3IMVsjvBlXyaeYONPdE14TaK9V-4LH5LSNe7AGc,1174
|
|
22
|
-
numcodecs/version.py,sha256=
|
|
22
|
+
numcodecs/version.py,sha256=ypwallA3PYa0X5lB0jSGkU5P26m2Z-w7iRiaWdnAP9g,513
|
|
23
23
|
numcodecs/compat.py,sha256=JadagE6pTEcrX3V8wDml0n1tdkHvOWo6D21J3a4P0mw,6505
|
|
24
|
-
numcodecs/checksum32.py,sha256=
|
|
25
|
-
numcodecs/vlen.cpython-313-darwin.so,sha256=
|
|
24
|
+
numcodecs/checksum32.py,sha256=zQv20v5CFCRtB3Kk0LiJ5zfgeWkJW6HZ21Lp7cMw22Y,5713
|
|
25
|
+
numcodecs/vlen.cpython-313-darwin.so,sha256=_0MDTk0FVK_CxwMhdkMnX6qE7e2QzzO1lHoqyNI2eq0,395144
|
|
26
26
|
numcodecs/ndarray_like.py,sha256=fVupUg_K_rDZNRlUmTiRp53OmF6YHb-yNyixJNFR8ME,1883
|
|
27
27
|
numcodecs/quantize.py,sha256=4mPx4kWanv5wGa22HvEiP893xqG5dDDtN-oKChj6nfE,3016
|
|
28
28
|
numcodecs/registry.py,sha256=oRN9uJsWIosZbAZFkOWyUos3GZ-h_zq_cN-t_uPLk0A,1864
|
|
29
|
-
numcodecs/jenkins.cpython-313-darwin.so,sha256=
|
|
29
|
+
numcodecs/jenkins.cpython-313-darwin.so,sha256=LV21En5LF27sx2kJ9GFGYKrAScbK9uCBETdnWUcbVkg,288352
|
|
30
30
|
numcodecs/pickles.py,sha256=LtcMa6cK-V5TUYJNR4dRDsWWRmLfNv0syZddbrbRv3A,1290
|
|
31
|
-
numcodecs/zstd.cpython-313-darwin.so,sha256=
|
|
31
|
+
numcodecs/zstd.cpython-313-darwin.so,sha256=mmA4tX-wypYUfMgJWsYnPFcso38kr7NnC8kt7mDJU88,2359704
|
|
32
32
|
numcodecs/fixedscaleoffset.py,sha256=fQwP_H-P3Mq4_LXtMQw5CLYeMjCBUdTtV-AKWVAIzkY,4188
|
|
33
33
|
numcodecs/__init__.py,sha256=cgA3s5JGgVs9lAu6olFajOWgHpsCYtnLih10kMBBxS0,3104
|
|
34
34
|
numcodecs/bitround.py,sha256=4lei39ZG4G2GGkDxl12q29nR5_8a4Icx4T-OgP1A1D4,2845
|
|
35
|
-
numcodecs/_shuffle.cpython-313-darwin.so,sha256=
|
|
35
|
+
numcodecs/_shuffle.cpython-313-darwin.so,sha256=Rumdv5vDb1QKphaEUgq93mTEE0MoIk4ynd-NFe1kyqI,267400
|
|
36
36
|
numcodecs/zlib.py,sha256=gLPUICEQc5p6DICC_63nOsbUqxzJH_5ynuzenTQXzOQ,1049
|
|
37
37
|
numcodecs/shuffle.py,sha256=hYOFJOCEeDSNI-TqT1JrbQxbprkQD4R8VfSzD4IPI3I,1575
|
|
38
|
-
numcodecs/fletcher32.cpython-313-darwin.so,sha256=
|
|
39
|
-
numcodecs/compat_ext.cpython-313-darwin.so,sha256=
|
|
40
|
-
numcodecs/zarr3.py,sha256=
|
|
38
|
+
numcodecs/fletcher32.cpython-313-darwin.so,sha256=_aKEpBvdwcIY5-uaGuxeDkwVAVepZzGiYAYOzwIfETk,306672
|
|
39
|
+
numcodecs/compat_ext.cpython-313-darwin.so,sha256=MpLxmIvmMOmSZ9x0rZINmk9UUBTZc9Gpb2_gXMIIZFg,58928
|
|
40
|
+
numcodecs/zarr3.py,sha256=fcLc0w3YSxujquhvdABOoc0Z0QfO2rK8BwSLH0MFisM,13117
|
|
41
41
|
numcodecs/delta.py,sha256=x0PjNiuX48rmh9M6ZHoYkI9bKOq00Aiyz_jLrVlAq8w,2791
|
|
42
|
-
numcodecs/zfpy.py,sha256
|
|
42
|
+
numcodecs/zfpy.py,sha256=2GRLkDnDQf_VbxXYn34MQTYVZfrsTuGR4-_vWdpya00,3869
|
|
43
43
|
numcodecs/msgpacks.py,sha256=GkTcFJrhKdpWnwQn4-282q4_edqlzZFdJFux2LtNk30,2619
|
|
44
44
|
numcodecs/errors.py,sha256=IV0B9fw_Wn8k3fjLtXOOU_-0_Al-dWY_dizvqFiNwkk,663
|
|
45
45
|
numcodecs/packbits.py,sha256=L7gM-8AQQTPC2IOPbatzNp-tH67EUp0Tonx_JSYHje4,1993
|
|
46
46
|
numcodecs/categorize.py,sha256=jPipT6mVrpGSe9QuI-MeVzTZuUKAZWF0XN5Wj_8Ifng,2948
|
|
47
47
|
numcodecs/json.py,sha256=WQcDcDPVxAQm-sxUg_XD70InKLD4iyjQOBiHPn2N3VE,3393
|
|
48
|
-
numcodecs/abc.py,sha256=
|
|
48
|
+
numcodecs/abc.py,sha256=HGQVq7pPTByqylBqjbLhhDVE71OIAzMOfWnQ1MSTO2s,4473
|
|
49
49
|
numcodecs/pcodec.py,sha256=ZB2Hw5l7aOKi0hOQ3M7GOAwaTNCBRiNr_8IpJPdrcE4,4714
|
|
50
50
|
numcodecs/tests/test_categorize.py,sha256=ftL-LSVq63R-kGuQxUb96uL1e563mlF9CWAf3yQB-Bk,2756
|
|
51
51
|
numcodecs/tests/test_registry.py,sha256=9Wp-VxGtEtNvwj46Edv6R8Jc4WPu80yWP7mRZyxepJ4,1116
|
|
52
52
|
numcodecs/tests/test_vlen_utf8.py,sha256=H92YtqNY0kpO2Icu1Ey2iItK38ZhKMnJi_2FBwcKSvU,2474
|
|
53
53
|
numcodecs/tests/test_bitround.py,sha256=ayCuANNDA0cP3mqZkJ90QU9eI7ws4-lPRKU_gkflOlg,2349
|
|
54
54
|
numcodecs/tests/test_gzip.py,sha256=I685q0_vu3b_JibUz3nhW1mQtlLSQzGdgGD2twbGPXc,2925
|
|
55
|
-
numcodecs/tests/test_zarr3.py,sha256=
|
|
55
|
+
numcodecs/tests/test_zarr3.py,sha256=2d8P6iuJql3lmCVIcCKUQ-lKh7I2ahUNbk44Vy9-zRc,9366
|
|
56
56
|
numcodecs/tests/test_delta.py,sha256=1_XnV1JYMEnxO0iXDXVSzTltjRPtdoEb4Y8TpmllS-o,1636
|
|
57
57
|
numcodecs/tests/test_lzma.py,sha256=mPj5MebkWg1h0W4ClFF_34cJ0_Toje7z7JZ8gOMngzs,2723
|
|
58
58
|
numcodecs/tests/test_bz2.py,sha256=pefO_YlOLr-RIswHas8DAQ4j81jhqLT5XGEuQ2i8DtI,1889
|
|
@@ -72,11 +72,12 @@ numcodecs/tests/test_base64.py,sha256=QseE5-aDwz7yv5-0dAG_6vTjeN3OpFvgcg8IhklRA4
|
|
|
72
72
|
numcodecs/tests/test_shuffle.py,sha256=uFWTuBbdcqwnWbyh2knwc46klZ00VekzWh8Ya0I2HiE,4659
|
|
73
73
|
numcodecs/tests/test_fixedscaleoffset.py,sha256=3RclYFw3WFu36WUIciZ23gNIiBmzboXvrEugMw1311A,2536
|
|
74
74
|
numcodecs/tests/test_compat.py,sha256=YdaGiNsXgounzSX7uFXOz_7uh6Wf1n6kO0Ql6eICtIY,3728
|
|
75
|
+
numcodecs/tests/test_pyzstd.py,sha256=NQRPeMw_TqLK91faoedBfe2rvCB79cfNj4e9cwiYmnU,2614
|
|
75
76
|
numcodecs/tests/test_zlib.py,sha256=TFa-I15xHd4h2nNC2goChWdlB_xZLbK_vAL7s4upPWI,2539
|
|
76
77
|
numcodecs/tests/test_json.py,sha256=od5MZbSclKFWM_RjS2DsVWGIYlJXG6-wm0yQLdkBTh0,2292
|
|
77
78
|
numcodecs/tests/test_ndarray_like.py,sha256=Bh8wDqkbSL-yr_MDQqE5XUoWzZav5J_VzC8Lfv3BBlA,1273
|
|
78
79
|
numcodecs/tests/test_vlen_array.py,sha256=QaWVuflGxQUFToVcWVIzZHG_b8Vm4JJG6mBZVGNasK0,2477
|
|
79
|
-
numcodecs/tests/test_zstd.py,sha256=
|
|
80
|
+
numcodecs/tests/test_zstd.py,sha256=yca-1BY9kh82ini_gabj5THf3udeUhwxnzW23ZN4xBA,5610
|
|
80
81
|
numcodecs/tests/test_vlen_bytes.py,sha256=BpASj3-ap_ZjyK_nYP7YQSZg4gsECCh5DW_4pdNlhRs,2473
|
|
81
82
|
numcodecs/tests/test_entrypoints.py,sha256=zWbyosPRhbSevwp4grlfjfnEyIneny-u7XmMe1xcoLI,504
|
|
82
83
|
numcodecs/tests/test_zarr3_import.py,sha256=JBDyrL57lbZMI9axb9eA1OZnd_Lg-ppfsNV3VvxwVxk,332
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/BITSHUFFLE.txt
RENAMED
|
File without changes
|
{numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/FASTLZ.txt
RENAMED
|
File without changes
|
|
File without changes
|
{numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/SNAPPY.txt
RENAMED
|
File without changes
|
{numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/STDINT.txt
RENAMED
|
File without changes
|
{numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/ZLIB-NG.txt
RENAMED
|
File without changes
|
{numcodecs-0.16.1.dist-info → numcodecs-0.16.2.dist-info}/licenses/c-blosc/LICENSES/ZLIB.txt
RENAMED
|
File without changes
|
|
File without changes
|