numcodecs 0.16.1__cp313-cp313-win_amd64.whl → 0.16.3__cp313-cp313-win_amd64.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.
Files changed (31) hide show
  1. numcodecs/_shuffle.cp313-win_amd64.pyd +0 -0
  2. numcodecs/abc.py +1 -2
  3. numcodecs/blosc.cp313-win_amd64.pyd +0 -0
  4. numcodecs/checksum32.py +2 -2
  5. numcodecs/compat_ext.cp313-win_amd64.pyd +0 -0
  6. numcodecs/fletcher32.cp313-win_amd64.pyd +0 -0
  7. numcodecs/jenkins.cp313-win_amd64.pyd +0 -0
  8. numcodecs/lz4.cp313-win_amd64.pyd +0 -0
  9. numcodecs/lzma.py +1 -2
  10. numcodecs/tests/test_pyzstd.py +77 -0
  11. numcodecs/tests/test_zarr3.py +12 -12
  12. numcodecs/tests/test_zstd.py +72 -6
  13. numcodecs/version.py +16 -3
  14. numcodecs/vlen.cp313-win_amd64.pyd +0 -0
  15. numcodecs/zarr3.py +42 -12
  16. numcodecs/zfpy.py +1 -2
  17. numcodecs/zstd.cp313-win_amd64.pyd +0 -0
  18. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/METADATA +2 -1
  19. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/RECORD +31 -30
  20. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/WHEEL +1 -1
  21. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/entry_points.txt +0 -0
  22. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/licenses/LICENSE.txt +0 -0
  23. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/licenses/c-blosc/LICENSE.txt +0 -0
  24. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/licenses/c-blosc/LICENSES/BITSHUFFLE.txt +0 -0
  25. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/licenses/c-blosc/LICENSES/FASTLZ.txt +0 -0
  26. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/licenses/c-blosc/LICENSES/LZ4.txt +0 -0
  27. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/licenses/c-blosc/LICENSES/SNAPPY.txt +0 -0
  28. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/licenses/c-blosc/LICENSES/STDINT.txt +0 -0
  29. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/licenses/c-blosc/LICENSES/ZLIB-NG.txt +0 -0
  30. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.dist-info}/licenses/c-blosc/LICENSES/ZLIB.txt +0 -0
  31. {numcodecs-0.16.1.dist-info → numcodecs-0.16.3.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: Optional[str] = None
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, Optional
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: Optional[ModuleType] = None
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
@@ -1,7 +1,6 @@
1
1
  from types import ModuleType
2
- from typing import Optional
3
2
 
4
- _lzma: Optional[ModuleType] = None
3
+ _lzma: ModuleType | None = None
5
4
  try:
6
5
  import lzma as _lzma
7
6
  except ImportError: # pragma: no cover
@@ -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)
@@ -122,8 +122,8 @@ def test_generic_filter(
122
122
  ],
123
123
  )
124
124
 
125
- a[:, :] = data.copy()
126
- a = zarr.open_array(store / "generic", mode="r")
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
- a[:, :] = data.copy()
144
- a = zarr.open_array(store / "generic_bitround", mode="r")
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
- a[:, :] = data.copy()
162
- a = zarr.open_array(store / "generic_quantize", mode="r")
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
- a[:, :] = data.copy()
181
- a = zarr.open_array(store / "generic_packbits", mode="r")
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
- a[:, :] = data.copy()
221
- a = zarr.open_array(store / "generic_checksum", mode="r")
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
- a[:, :] = data.copy()
271
- a = zarr.open_array(store / "generic", mode="r")
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
 
@@ -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
@@ -1,7 +1,14 @@
1
1
  # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
3
 
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
5
12
 
6
13
  TYPE_CHECKING = False
7
14
  if TYPE_CHECKING:
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
9
16
  from typing import Union
10
17
 
11
18
  VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
12
20
  else:
13
21
  VERSION_TUPLE = object
22
+ COMMIT_ID = object
14
23
 
15
24
  version: str
16
25
  __version__: str
17
26
  __version_tuple__: VERSION_TUPLE
18
27
  version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
19
30
 
20
- __version__ = version = '0.16.1'
21
- __version_tuple__ = version_tuple = (0, 16, 1)
31
+ __version__ = version = '0.16.3'
32
+ __version_tuple__ = version_tuple = (0, 16, 3)
33
+
34
+ __commit_id__ = commit_id = 'g878d2b385'
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.__version__ < "3.0.0": # pragma: no cover
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
- return Shuffle(**{**self.codec_config, "elementsize": array_spec.dtype.itemsize})
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
- return replace(chunk_spec, dtype=np.dtype(astype)) # type: ignore[call-overload]
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
- return replace(chunk_spec, dtype=np.dtype(astype)) # type: ignore[call-overload]
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
- return FixedScaleOffset(**{**self.codec_config, "dtype": str(array_spec.dtype)})
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
- return Quantize(**{**self.codec_config, "dtype": str(array_spec.dtype)})
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
- def validate(self, *, dtype: np.dtype[Any], **_kwargs) -> None:
274
- if dtype != np.dtype("bool"):
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
- return replace(chunk_spec, dtype=np.dtype(self.codec_config["encode_dtype"])) # type: ignore[arg-type]
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
- return AsType(**{**self.codec_config, "decode_dtype": str(array_spec.dtype)})
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: Optional[ModuleType] = None
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.1
3
+ Version: 0.16.3
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,24 +1,24 @@
1
1
  numcodecs/__init__.py,sha256=zcO3_tRbWzdbtZQniKvnleQ8U6wZcLtNLRXvzYjESAg,3250
2
- numcodecs/_shuffle.cp313-win_amd64.pyd,sha256=ZlVBfQ1ITh6lNgmKAwpVZrOMXLpTbfHbEaRH79zHaE0,125952
3
- numcodecs/abc.py,sha256=WWOjzavsAAcAxu-POPfiojYFfl94u9xE4RWAcRdRCbw,4631
2
+ numcodecs/_shuffle.cp313-win_amd64.pyd,sha256=qUdW_nc2Dp7z7Hmbfou7qYbi17HW8X0S47UGjyRsZ5I,125440
3
+ numcodecs/abc.py,sha256=1Mm2CS0eVE5yAM3xps2v8a_hYnMFPe_AuPoCAz1EoSE,4599
4
4
  numcodecs/astype.py,sha256=ZoI9ev-r2Q5Xw7NZN1xoZ9tYhq80XoeL-F15KfJhDIA,2171
5
5
  numcodecs/base64.py,sha256=Da-KRfgXZ5j5Dn5AjidclQp9BXcAdx_ZR_a60FzFPWQ,778
6
6
  numcodecs/bitround.py,sha256=m9gysWTzZH_MA0H7oI3dfBIZh66yxHM4gik8aq6xA_0,2925
7
- numcodecs/blosc.cp313-win_amd64.pyd,sha256=5Y8pIVqf2ukbHjAEmk3hZAKdGFMUD8qGQbSfBvgUH8w,566784
7
+ numcodecs/blosc.cp313-win_amd64.pyd,sha256=iFTOz3AQQlWVDb0PcSpb3hVoB9HfGgjbgeB8lLt4kaA,573952
8
8
  numcodecs/bz2.py,sha256=bS0L4XqzJDw6pU4MUuEF8UgFOHw6mErnqCXZVg8TEiI,1219
9
9
  numcodecs/categorize.py,sha256=jwx8H_EXMEY3CSSWjYt5wzoduFwv-44v_Kjqxe-jo4Q,3046
10
- numcodecs/checksum32.py,sha256=FAA1N6agDIxE8OMcyusjqGLFy5vyxzsxnARsfhOXeTQ,5909
10
+ numcodecs/checksum32.py,sha256=lqqNiNKMtGZYu4D_Q_MziRYHMYJT0skydqxtLBVin10,5896
11
11
  numcodecs/compat.py,sha256=ghz0-UpxV0q_mAaiZLZv6BBhJNNLeLTDGirO4Oda_ZM,6711
12
- numcodecs/compat_ext.cp313-win_amd64.pyd,sha256=PPe7B-cHP5XAtTAwDMxTo8UxJLN6DDqhkP_mHuo50lY,22016
12
+ numcodecs/compat_ext.cp313-win_amd64.pyd,sha256=VLlHeA-4dBT-aGb6_TRgEd-UykBiWvkqA9JzhSwO9q4,22016
13
13
  numcodecs/delta.py,sha256=cSU6M1hT6q_ZNdyW3zkbcPsyviZsc9OJ5nZLBOpnwxc,2885
14
14
  numcodecs/errors.py,sha256=Acfi3-rFKs93QM3-fcS7vo2qGvocLXwWnA0HhuOwGqk,689
15
15
  numcodecs/fixedscaleoffset.py,sha256=mjIakyHT5cY38o7gE-9f99SjPJRVAxYkyOJ0h9OnyKE,4318
16
- numcodecs/fletcher32.cp313-win_amd64.pyd,sha256=IQ5JiCK1nqaIfdX7kZI3QjrdRgBElxOafbFHhheeYSg,146432
16
+ numcodecs/fletcher32.cp313-win_amd64.pyd,sha256=g0-9M0G-SkM_WiYXbafEZYbThFKRXMMIUsuT9eGLE-Y,146944
17
17
  numcodecs/gzip.py,sha256=w7TpS4sorX36J7L4Izs8BszU7ZH-Mks455Ai-QHWZrs,1486
18
- numcodecs/jenkins.cp313-win_amd64.pyd,sha256=4gBKcMFfrtTOy6dZY-jePtvhJ8H3qxQn9WoCjDD2Ft8,138752
18
+ numcodecs/jenkins.cp313-win_amd64.pyd,sha256=ypx4zfs-eEXFsybqj1XS8GTsPxJjScUqIrIPluIRtWw,139776
19
19
  numcodecs/json.py,sha256=dFoZcpBSY3fU-4p4x1DjI3mtr-reRlsMSJ7Aiwy_sgI,3500
20
- numcodecs/lz4.cp313-win_amd64.pyd,sha256=Qcre1JZ2gWWB-W3zNGAPQDyJUCYSiFcIOxgen0BcKCw,67072
21
- numcodecs/lzma.py,sha256=N01IBcCZKiMS0fPB75157inIhuZkVNFcW3Xf96mmWJ8,2329
20
+ numcodecs/lz4.cp313-win_amd64.pyd,sha256=lesIzTlzcjyjHZZ-2jTR28oBqrvj8Kl5ZWQDXpSw_jU,67072
21
+ numcodecs/lzma.py,sha256=8HK654P8HmS32UX_E8LJyEDfIM-uNUx8Q0O_8U6HCfw,2297
22
22
  numcodecs/msgpacks.py,sha256=a6do5fvFqnSXOadxajtw-uq7UdcUsWUY-hTDv8HCx08,2705
23
23
  numcodecs/ndarray_like.py,sha256=M6n00SC1h_SgN0enXClkKMFeE4z-AewLAYVbq56Vl2A,1948
24
24
  numcodecs/packbits.py,sha256=hEaOSpjUxOTlNAXFvDp5Djo7wwqwuFGaRfEDrB07bDY,2075
@@ -27,12 +27,12 @@ numcodecs/pickles.py,sha256=Yh8hCg-ETdLWM5MjCy5vPW8E8_3DCjyvOPoKtvbr1ZU,1345
27
27
  numcodecs/quantize.py,sha256=hHzsMgFtJGDHrYRjdFqNBJ2wit9I45y59Uqc5pUjIWQ,3114
28
28
  numcodecs/registry.py,sha256=IlPYY8RlVZgRid2j-S7SxnhCMq4y9cxQwQMGCy7lgbI,1938
29
29
  numcodecs/shuffle.py,sha256=ty-NJ1bIgsErwmTyJtspSgrrJ4PspQjp6Hb-U2M17hY,1636
30
- numcodecs/version.py,sha256=Q-sQEcpO0WIsA4KgY99KmzTgmRvvelk-5dmyYTgdykY,534
31
- numcodecs/vlen.cp313-win_amd64.pyd,sha256=9a0mJ_yjS1qOviuUfuhfnvBSdnGT5Ckz1DWD4QbhBxo,189440
32
- numcodecs/zarr3.py,sha256=tkziYhdg427GAzEaeLnvgyL-uXAcvvFpYoaxN8aFoCM,12234
33
- numcodecs/zfpy.py,sha256=SP6zPdXwSrZzu_iuudoSZGBuE6IvXWdvJri1fgz-4nY,4013
30
+ numcodecs/version.py,sha256=GJrBZ0l8TtQly1NnFabOJR0Bta_CWgSL9aiCcFh--4E,748
31
+ numcodecs/vlen.cp313-win_amd64.pyd,sha256=9LyD63betrCSX98-pPgCbOLeHvTb8Cq9c7Un360jwLk,187904
32
+ numcodecs/zarr3.py,sha256=zkxDOmY1RVpwsTLGK_AX2zaFX3NmzCG7ARCsiAieiGI,13492
33
+ numcodecs/zfpy.py,sha256=0B-F2-aWnv6SltNNAM5w1H_LNQZStCLi1jrXyQqDcXI,3981
34
34
  numcodecs/zlib.py,sha256=C5TO2qRPyG6SY25lmB9qeFh6yr4IRAqHz0v4RaPvygE,1091
35
- numcodecs/zstd.cp313-win_amd64.pyd,sha256=lDCZlcxpkKY9HiVtOUazRlMhDIRoqH8QCEzmQm8YIKw,442880
35
+ numcodecs/zstd.cp313-win_amd64.pyd,sha256=FS77ue9YYw8mjMjlzlZX1UfmcxEko92aDF9F-xWzhSg,452608
36
36
  numcodecs/tests/__init__.py,sha256=W7MDbDAXcjl7fVmolo3U_30rFkOCb6mWQ8vcByUpu8g,75
37
37
  numcodecs/tests/common.py,sha256=oOBW3lYM9TKG7PQjeK_CKBtg2o1oA3pLA_8npHwV5vY,9592
38
38
  numcodecs/tests/test_astype.py,sha256=m-l8k4q8jSZrIqviASKxYsaPzzuBG_Y4tUNlIigYbco,2441
@@ -58,30 +58,31 @@ numcodecs/tests/test_ndarray_like.py,sha256=GXx-XTSKK8wGLlEeuvrgdFDQ3uGtV55-fKKj
58
58
  numcodecs/tests/test_packbits.py,sha256=UWXpYyaHLybqOHgZgVTP_5VeibGO09CyJyKSO_mTCeI,1028
59
59
  numcodecs/tests/test_pcodec.py,sha256=_CO8siS_90LNlhmH9ln0o-lraoptpL_T7dFZ5yK7aJY,2590
60
60
  numcodecs/tests/test_pickles.py,sha256=zhmZPPiCgW3uFArYvixgiMPWXdmKjnCj0JThUDt8nn4,1740
61
+ numcodecs/tests/test_pyzstd.py,sha256=86pgfjGxwGP01TmfQPB06L_ylVDliM0iPtzPzQ_tpN4,2691
61
62
  numcodecs/tests/test_quantize.py,sha256=muD4zwQSa4XM4jPO3qXu8rMdoU4eHCpVfQ8z0G7Zh-U,2227
62
63
  numcodecs/tests/test_registry.py,sha256=Ar_Op6MIEm8MTxzBPgjtMrWXA5EhYm7JnM-Yab79zrY,1159
63
64
  numcodecs/tests/test_shuffle.py,sha256=25AOv67ip0EroQyufgWZXPYueA4p4HZcctwTTFeT5Q0,4825
64
65
  numcodecs/tests/test_vlen_array.py,sha256=sUwLaza31Yo0IMnmKCGykRPaB3ha7i0ImiCY9yvHS9o,2574
65
66
  numcodecs/tests/test_vlen_bytes.py,sha256=ujYHFkBn7EultxVkEepbmFriQfO_pJxfh7dEfTxCCco,2566
66
67
  numcodecs/tests/test_vlen_utf8.py,sha256=X0nBvLv1hVDHGz3pIRMP4rVs75lAkXGUb0cRcfZM1Ss,2565
67
- numcodecs/tests/test_zarr3.py,sha256=72s8pRMtvZEw_6NQLDe3f-6cHORN3etHMFJkT4Kn2sQ,9732
68
+ numcodecs/tests/test_zarr3.py,sha256=SPBbz7epgyjOkFr2fBkKeVuJu1_SEpnwE3F8XJKFh-w,9684
68
69
  numcodecs/tests/test_zarr3_import.py,sha256=enI8IqSnTynihEQ2mh95UdTZ5Gb8m9Wock6gbg3iLYs,345
69
70
  numcodecs/tests/test_zfpy.py,sha256=lSkKcpGg437poMRQ88EDYdbQVIqKmF0Il-ASdlYkkIY,2866
70
71
  numcodecs/tests/test_zlib.py,sha256=SxgYIyH2bH_eIX7k-9kgPUOXCHEllGPoLSUSn0Qk5rg,2633
71
- numcodecs/tests/test_zstd.py,sha256=P-wHnm0wOuclHOoX7danVEvufxKNM3GwYBgHBchzILE,2702
72
+ numcodecs/tests/test_zstd.py,sha256=1IXbaOxbNtpwpCKx22XyBDpnO0HevTUmAJLLU1Fi_ro,5768
72
73
  numcodecs/tests/package_with_entrypoint/__init__.py,sha256=j0h1AHePXH8ONfd-TMGwKsMW4gBqbgiGOuGP25S9hLE,223
73
- numcodecs-0.16.1.dist-info/licenses/LICENSE.txt,sha256=IxxTq7WTy9_G9AbShWjbBcg6x2G3pDlJEIBJN2o95ks,1145
74
- numcodecs-0.16.1.dist-info/licenses/c-blosc/LICENSE.txt,sha256=O7ymticiBIDDnp1Qz4k3YxL84kZcC9Anjw8LcRxPOi4,1675
75
- numcodecs-0.16.1.dist-info/licenses/c-blosc/LICENSES/BITSHUFFLE.txt,sha256=KlmZr2WeErTRwZ6evuOiOyon5Lzx3q_5r6Ia77DpIJQ,1169
76
- numcodecs-0.16.1.dist-info/licenses/c-blosc/LICENSES/FASTLZ.txt,sha256=FYqEiOTbader3aeXp85aD6aVA90BFKUDRJpEPu_8w-8,1155
77
- numcodecs-0.16.1.dist-info/licenses/c-blosc/LICENSES/LZ4.txt,sha256=rRc2s37unSWbyuYw_OWvM97RJrWSfYjQ3pcrcU9N6io,1337
78
- numcodecs-0.16.1.dist-info/licenses/c-blosc/LICENSES/SNAPPY.txt,sha256=J-aF3rkomek7rPuKYzRPUOrIUgGnoqoNhXndJ3q8QMI,1503
79
- numcodecs-0.16.1.dist-info/licenses/c-blosc/LICENSES/STDINT.txt,sha256=DjS3TKOVRT0V_QC6Bf4u9IQWvXgfwnLmvPxsFdUGRqM,1597
80
- numcodecs-0.16.1.dist-info/licenses/c-blosc/LICENSES/ZLIB-NG.txt,sha256=PqsweFGCCDpkeUrFcwoGvQ_PPc3ZcGNNqSSR0bdSJwk,910
81
- numcodecs-0.16.1.dist-info/licenses/c-blosc/LICENSES/ZLIB.txt,sha256=GNvTfwqxdcN4d-kFP_hwp94oCaPpuWc7JpaqUAkmRjg,1024
82
- numcodecs-0.16.1.dist-info/METADATA,sha256=aDxoAuL6CVsjhuF3ejRTFsHFEKvi_oSKK0NORq0aMfQ,3324
83
- numcodecs-0.16.1.dist-info/WHEEL,sha256=bs-xhrmTp6GOYHnarwiqzzaLhy3P3WRx2sA2M-7RxtA,101
84
- numcodecs-0.16.1.dist-info/entry_points.txt,sha256=3W3FHKrwE52X3fLq8KdioOtf93lh5KaoGV5t2D10DBI,919
85
- numcodecs-0.16.1.dist-info/top_level.txt,sha256=JkHllzt6IuVudg4Tk--wF-yfPPsdVOiMTag1tjGIihw,10
74
+ numcodecs-0.16.3.dist-info/licenses/LICENSE.txt,sha256=IxxTq7WTy9_G9AbShWjbBcg6x2G3pDlJEIBJN2o95ks,1145
75
+ numcodecs-0.16.3.dist-info/licenses/c-blosc/LICENSE.txt,sha256=O7ymticiBIDDnp1Qz4k3YxL84kZcC9Anjw8LcRxPOi4,1675
76
+ numcodecs-0.16.3.dist-info/licenses/c-blosc/LICENSES/BITSHUFFLE.txt,sha256=KlmZr2WeErTRwZ6evuOiOyon5Lzx3q_5r6Ia77DpIJQ,1169
77
+ numcodecs-0.16.3.dist-info/licenses/c-blosc/LICENSES/FASTLZ.txt,sha256=FYqEiOTbader3aeXp85aD6aVA90BFKUDRJpEPu_8w-8,1155
78
+ numcodecs-0.16.3.dist-info/licenses/c-blosc/LICENSES/LZ4.txt,sha256=rRc2s37unSWbyuYw_OWvM97RJrWSfYjQ3pcrcU9N6io,1337
79
+ numcodecs-0.16.3.dist-info/licenses/c-blosc/LICENSES/SNAPPY.txt,sha256=J-aF3rkomek7rPuKYzRPUOrIUgGnoqoNhXndJ3q8QMI,1503
80
+ numcodecs-0.16.3.dist-info/licenses/c-blosc/LICENSES/STDINT.txt,sha256=DjS3TKOVRT0V_QC6Bf4u9IQWvXgfwnLmvPxsFdUGRqM,1597
81
+ numcodecs-0.16.3.dist-info/licenses/c-blosc/LICENSES/ZLIB-NG.txt,sha256=PqsweFGCCDpkeUrFcwoGvQ_PPc3ZcGNNqSSR0bdSJwk,910
82
+ numcodecs-0.16.3.dist-info/licenses/c-blosc/LICENSES/ZLIB.txt,sha256=GNvTfwqxdcN4d-kFP_hwp94oCaPpuWc7JpaqUAkmRjg,1024
83
+ numcodecs-0.16.3.dist-info/METADATA,sha256=4N7wZx69QWrcue6f8ls3L6xhCRqzU-l5hzl6tvtu4yw,3364
84
+ numcodecs-0.16.3.dist-info/WHEEL,sha256=qV0EIPljj1XC_vuSatRWjn02nZIz3N1t8jsZz7HBr2U,101
85
+ numcodecs-0.16.3.dist-info/entry_points.txt,sha256=3W3FHKrwE52X3fLq8KdioOtf93lh5KaoGV5t2D10DBI,919
86
+ numcodecs-0.16.3.dist-info/top_level.txt,sha256=JkHllzt6IuVudg4Tk--wF-yfPPsdVOiMTag1tjGIihw,10
86
87
  numcodecs/tests/package_with_entrypoint-0.1.dist-info/entry_points.txt,sha256=COk3sfJsTt3T00bA2bcUMCuWEhwkQvf4lPHcBDk34qA,62
87
- numcodecs-0.16.1.dist-info/RECORD,,
88
+ numcodecs-0.16.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp313-cp313-win_amd64
5
5