numcodecs 0.13.0__cp311-cp311-macosx_11_0_arm64.whl → 0.14.0__cp311-cp311-macosx_11_0_arm64.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.

Files changed (72) hide show
  1. numcodecs/__init__.py +11 -11
  2. numcodecs/_shuffle.cpython-311-darwin.so +0 -0
  3. numcodecs/abc.py +4 -5
  4. numcodecs/astype.py +2 -4
  5. numcodecs/bitround.py +2 -2
  6. numcodecs/blosc.cpython-311-darwin.so +0 -0
  7. numcodecs/bz2.py +1 -2
  8. numcodecs/categorize.py +5 -12
  9. numcodecs/checksum32.py +87 -13
  10. numcodecs/compat.py +4 -8
  11. numcodecs/compat_ext.cpython-311-darwin.so +0 -0
  12. numcodecs/delta.py +7 -4
  13. numcodecs/fixedscaleoffset.py +3 -9
  14. numcodecs/fletcher32.cpython-311-darwin.so +0 -0
  15. numcodecs/jenkins.cpython-311-darwin.so +0 -0
  16. numcodecs/json.py +7 -8
  17. numcodecs/lz4.cpython-311-darwin.so +0 -0
  18. numcodecs/lzma.py +7 -11
  19. numcodecs/msgpacks.py +2 -5
  20. numcodecs/ndarray_like.py +5 -5
  21. numcodecs/packbits.py +0 -4
  22. numcodecs/pcodec.py +2 -2
  23. numcodecs/pickles.py +1 -1
  24. numcodecs/quantize.py +4 -10
  25. numcodecs/registry.py +10 -9
  26. numcodecs/shuffle.py +4 -4
  27. numcodecs/tests/common.py +7 -11
  28. numcodecs/tests/test_astype.py +2 -4
  29. numcodecs/tests/test_base64.py +2 -5
  30. numcodecs/tests/test_bitround.py +3 -4
  31. numcodecs/tests/test_blosc.py +4 -7
  32. numcodecs/tests/test_bz2.py +3 -6
  33. numcodecs/tests/test_categorize.py +3 -5
  34. numcodecs/tests/test_checksum32.py +101 -24
  35. numcodecs/tests/test_compat.py +4 -3
  36. numcodecs/tests/test_delta.py +4 -5
  37. numcodecs/tests/test_entrypoints.py +1 -2
  38. numcodecs/tests/test_entrypoints_backport.py +4 -4
  39. numcodecs/tests/test_fixedscaleoffset.py +16 -11
  40. numcodecs/tests/test_gzip.py +3 -6
  41. numcodecs/tests/test_jenkins.py +33 -33
  42. numcodecs/tests/test_json.py +3 -3
  43. numcodecs/tests/test_lz4.py +3 -6
  44. numcodecs/tests/test_lzma.py +8 -7
  45. numcodecs/tests/test_msgpacks.py +8 -8
  46. numcodecs/tests/test_packbits.py +2 -4
  47. numcodecs/tests/test_pcodec.py +5 -6
  48. numcodecs/tests/test_pickles.py +2 -3
  49. numcodecs/tests/test_quantize.py +3 -6
  50. numcodecs/tests/test_registry.py +14 -12
  51. numcodecs/tests/test_shuffle.py +5 -8
  52. numcodecs/tests/test_vlen_array.py +5 -6
  53. numcodecs/tests/test_vlen_bytes.py +5 -6
  54. numcodecs/tests/test_vlen_utf8.py +5 -8
  55. numcodecs/tests/test_zarr3.py +248 -0
  56. numcodecs/tests/test_zarr3_import.py +13 -0
  57. numcodecs/tests/test_zfpy.py +8 -6
  58. numcodecs/tests/test_zlib.py +4 -7
  59. numcodecs/tests/test_zstd.py +6 -9
  60. numcodecs/version.py +2 -2
  61. numcodecs/vlen.cpython-311-darwin.so +0 -0
  62. numcodecs/zarr3.py +379 -0
  63. numcodecs/zfpy.py +13 -12
  64. numcodecs/zlib.py +1 -2
  65. numcodecs/zstd.cpython-311-darwin.so +0 -0
  66. {numcodecs-0.13.0.dist-info → numcodecs-0.14.0.dist-info}/METADATA +8 -6
  67. numcodecs-0.14.0.dist-info/RECORD +78 -0
  68. {numcodecs-0.13.0.dist-info → numcodecs-0.14.0.dist-info}/WHEEL +1 -1
  69. numcodecs-0.14.0.dist-info/entry_points.txt +22 -0
  70. numcodecs-0.13.0.dist-info/RECORD +0 -74
  71. {numcodecs-0.13.0.dist-info → numcodecs-0.14.0.dist-info}/LICENSE.txt +0 -0
  72. {numcodecs-0.13.0.dist-info → numcodecs-0.14.0.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,8 @@
1
1
  import itertools
2
2
 
3
-
4
3
  import numpy as np
5
4
  import pytest
6
5
 
7
-
8
6
  try:
9
7
  from numcodecs.zstd import Zstd
10
8
  except ImportError: # pragma: no cover
@@ -12,15 +10,14 @@ except ImportError: # pragma: no cover
12
10
 
13
11
 
14
12
  from numcodecs.tests.common import (
15
- check_encode_decode,
16
- check_config,
17
- check_repr,
18
13
  check_backwards_compatibility,
14
+ check_config,
15
+ check_encode_decode,
19
16
  check_err_decode_object_buffer,
20
17
  check_err_encode_object_buffer,
18
+ check_repr,
21
19
  )
22
20
 
23
-
24
21
  codecs = [
25
22
  Zstd(),
26
23
  Zstd(level=-1),
@@ -90,6 +87,6 @@ def test_checksum():
90
87
 
91
88
  def test_native_functions():
92
89
  # Note, these assertions might need to be changed for new versions of zstd
93
- assert Zstd.default_level == 3
94
- assert Zstd.min_level == -131072
95
- assert Zstd.max_level == 22
90
+ assert Zstd.default_level() == 3
91
+ assert Zstd.min_level() == -131072
92
+ assert Zstd.max_level() == 22
numcodecs/version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.13.0'
16
- __version_tuple__ = version_tuple = (0, 13, 0)
15
+ __version__ = version = '0.14.0'
16
+ __version_tuple__ = version_tuple = (0, 14, 0)
Binary file
numcodecs/zarr3.py ADDED
@@ -0,0 +1,379 @@
1
+ """
2
+ This module provides the compatibility for :py:mod:`numcodecs` in Zarr version 3.
3
+
4
+ A compatibility module is required because the codec handling in Zarr version 3 is different from Zarr version 2.
5
+
6
+ You can use codecs from :py:mod:`numcodecs` by constructing codecs from :py:mod:`numcodecs.zarr3` using the same parameters as the original codecs.
7
+
8
+ >>> import zarr
9
+ >>> import numcodecs.zarr3
10
+ >>>
11
+ >>> codecs = [zarr.codecs.BytesCodec(), numcodecs.zarr3.BZ2(level=5)]
12
+ >>> array = zarr.open(
13
+ ... "data.zarr", mode="w",
14
+ ... shape=(1024, 1024), chunks=(64, 64),
15
+ ... dtype="uint32",
16
+ ... codecs=codecs)
17
+ >>> array[:] = np.arange(*array.shape).astype(array.dtype)
18
+
19
+ .. note::
20
+
21
+ Please note that the codecs in :py:mod:`numcodecs.zarr3` are not part of the Zarr version 3 specification.
22
+ Using these codecs might cause interoperability issues with other Zarr implementations.
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ import asyncio
28
+ import math
29
+ from dataclasses import dataclass, replace
30
+ from functools import cached_property, partial
31
+ from typing import Any, Self, TypeVar
32
+ from warnings import warn
33
+
34
+ import numpy as np
35
+
36
+ import numcodecs
37
+
38
+ try:
39
+ import zarr
40
+
41
+ if zarr.__version__ < "3.0.0": # pragma: no cover
42
+ raise ImportError("zarr 3.0.0 or later is required to use the numcodecs zarr integration.")
43
+ except ImportError: # pragma: no cover
44
+ raise ImportError("zarr 3.0.0 or later is required to use the numcodecs zarr integration.")
45
+
46
+ from zarr.abc.codec import ArrayArrayCodec, ArrayBytesCodec, BytesBytesCodec
47
+ from zarr.abc.metadata import Metadata
48
+ from zarr.core.array_spec import ArraySpec
49
+ from zarr.core.buffer import Buffer, BufferPrototype, NDBuffer
50
+ from zarr.core.buffer.cpu import as_numpy_array_wrapper
51
+ from zarr.core.common import JSON, parse_named_configuration, product
52
+
53
+ CODEC_PREFIX = "numcodecs."
54
+
55
+
56
+ def _expect_name_prefix(codec_name: str) -> str:
57
+ if not codec_name.startswith(CODEC_PREFIX):
58
+ raise ValueError(
59
+ f"Expected name to start with '{CODEC_PREFIX}'. Got {codec_name} instead."
60
+ ) # pragma: no cover
61
+ return codec_name.removeprefix(CODEC_PREFIX)
62
+
63
+
64
+ def _parse_codec_configuration(data: dict[str, JSON]) -> dict[str, JSON]:
65
+ parsed_name, parsed_configuration = parse_named_configuration(data)
66
+ if not parsed_name.startswith(CODEC_PREFIX):
67
+ raise ValueError(
68
+ f"Expected name to start with '{CODEC_PREFIX}'. Got {parsed_name} instead."
69
+ ) # pragma: no cover
70
+ id = _expect_name_prefix(parsed_name)
71
+ return {"id": id, **parsed_configuration}
72
+
73
+
74
+ @dataclass(frozen=True)
75
+ class _NumcodecsCodec(Metadata):
76
+ codec_name: str
77
+ codec_config: dict[str, JSON]
78
+
79
+ def __init__(self, **codec_config: JSON) -> None:
80
+ if not self.codec_name:
81
+ raise ValueError(
82
+ "The codec name needs to be supplied through the `codec_name` attribute."
83
+ ) # pragma: no cover
84
+ unprefixed_codec_name = _expect_name_prefix(self.codec_name)
85
+
86
+ if "id" not in codec_config:
87
+ codec_config = {"id": unprefixed_codec_name, **codec_config}
88
+ elif codec_config["id"] != unprefixed_codec_name:
89
+ raise ValueError(
90
+ f"Codec id does not match {unprefixed_codec_name}. Got: {codec_config['id']}."
91
+ ) # pragma: no cover
92
+
93
+ object.__setattr__(self, "codec_config", codec_config)
94
+ warn(
95
+ "Numcodecs codecs are not in the Zarr version 3 specification and "
96
+ "may not be supported by other zarr implementations.",
97
+ category=UserWarning,
98
+ )
99
+
100
+ @cached_property
101
+ def _codec(self) -> numcodecs.abc.Codec:
102
+ return numcodecs.get_codec(self.codec_config)
103
+
104
+ @classmethod
105
+ def from_dict(cls, data: dict[str, JSON]) -> Self:
106
+ codec_config = _parse_codec_configuration(data)
107
+ return cls(**codec_config)
108
+
109
+ def to_dict(self) -> dict[str, JSON]:
110
+ codec_config = self.codec_config.copy()
111
+ return {
112
+ "name": self.codec_name,
113
+ "configuration": codec_config,
114
+ }
115
+
116
+ def compute_encoded_size(self, input_byte_length: int, chunk_spec: ArraySpec) -> int:
117
+ raise NotImplementedError # pragma: no cover
118
+
119
+
120
+ class _NumcodecsBytesBytesCodec(_NumcodecsCodec, BytesBytesCodec):
121
+ def __init__(self, **codec_config: JSON) -> None:
122
+ super().__init__(**codec_config)
123
+
124
+ async def _decode_single(self, chunk_bytes: Buffer, chunk_spec: ArraySpec) -> Buffer:
125
+ return await asyncio.to_thread(
126
+ as_numpy_array_wrapper,
127
+ self._codec.decode,
128
+ chunk_bytes,
129
+ chunk_spec.prototype,
130
+ )
131
+
132
+ def _encode(self, chunk_bytes: Buffer, prototype: BufferPrototype) -> Buffer:
133
+ encoded = self._codec.encode(chunk_bytes.as_array_like())
134
+ if isinstance(encoded, np.ndarray): # Required for checksum codecs
135
+ return prototype.buffer.from_bytes(encoded.tobytes())
136
+ return prototype.buffer.from_bytes(encoded)
137
+
138
+ async def _encode_single(self, chunk_bytes: Buffer, chunk_spec: ArraySpec) -> Buffer:
139
+ return await asyncio.to_thread(self._encode, chunk_bytes, chunk_spec.prototype)
140
+
141
+
142
+ class _NumcodecsArrayArrayCodec(_NumcodecsCodec, ArrayArrayCodec):
143
+ def __init__(self, **codec_config: JSON) -> None:
144
+ super().__init__(**codec_config)
145
+
146
+ async def _decode_single(self, chunk_array: NDBuffer, chunk_spec: ArraySpec) -> NDBuffer:
147
+ chunk_ndarray = chunk_array.as_ndarray_like()
148
+ out = await asyncio.to_thread(self._codec.decode, chunk_ndarray)
149
+ return chunk_spec.prototype.nd_buffer.from_ndarray_like(out.reshape(chunk_spec.shape))
150
+
151
+ async def _encode_single(self, chunk_array: NDBuffer, chunk_spec: ArraySpec) -> NDBuffer:
152
+ chunk_ndarray = chunk_array.as_ndarray_like()
153
+ out = await asyncio.to_thread(self._codec.encode, chunk_ndarray)
154
+ return chunk_spec.prototype.nd_buffer.from_ndarray_like(out)
155
+
156
+
157
+ class _NumcodecsArrayBytesCodec(_NumcodecsCodec, ArrayBytesCodec):
158
+ def __init__(self, **codec_config: JSON) -> None:
159
+ super().__init__(**codec_config)
160
+
161
+ async def _decode_single(self, chunk_buffer: Buffer, chunk_spec: ArraySpec) -> NDBuffer:
162
+ chunk_bytes = chunk_buffer.to_bytes()
163
+ out = await asyncio.to_thread(self._codec.decode, chunk_bytes)
164
+ return chunk_spec.prototype.nd_buffer.from_ndarray_like(out.reshape(chunk_spec.shape))
165
+
166
+ async def _encode_single(self, chunk_ndbuffer: NDBuffer, chunk_spec: ArraySpec) -> Buffer:
167
+ chunk_ndarray = chunk_ndbuffer.as_ndarray_like()
168
+ out = await asyncio.to_thread(self._codec.encode, chunk_ndarray)
169
+ return chunk_spec.prototype.buffer.from_bytes(out)
170
+
171
+
172
+ T = TypeVar("T", bound=_NumcodecsCodec)
173
+
174
+
175
+ def _add_docstring(cls: type[T], ref_class_name: str) -> type[T]:
176
+ cls.__doc__ = f"""
177
+ See :class:`{ref_class_name}` for more details and parameters.
178
+ """
179
+ return cls
180
+
181
+
182
+ def _add_docstring_wrapper(ref_class_name: str) -> partial:
183
+ return partial(_add_docstring, ref_class_name=ref_class_name)
184
+
185
+
186
+ def _make_bytes_bytes_codec(codec_name: str, cls_name: str) -> type[_NumcodecsBytesBytesCodec]:
187
+ # rename for class scope
188
+ _codec_name = CODEC_PREFIX + codec_name
189
+
190
+ class _Codec(_NumcodecsBytesBytesCodec):
191
+ codec_name = _codec_name
192
+
193
+ def __init__(self, **codec_config: JSON) -> None:
194
+ super().__init__(**codec_config)
195
+
196
+ _Codec.__name__ = cls_name
197
+ return _Codec
198
+
199
+
200
+ def _make_array_array_codec(codec_name: str, cls_name: str) -> type[_NumcodecsArrayArrayCodec]:
201
+ # rename for class scope
202
+ _codec_name = CODEC_PREFIX + codec_name
203
+
204
+ class _Codec(_NumcodecsArrayArrayCodec):
205
+ codec_name = _codec_name
206
+
207
+ def __init__(self, **codec_config: JSON) -> None:
208
+ super().__init__(**codec_config)
209
+
210
+ _Codec.__name__ = cls_name
211
+ return _Codec
212
+
213
+
214
+ def _make_array_bytes_codec(codec_name: str, cls_name: str) -> type[_NumcodecsArrayBytesCodec]:
215
+ # rename for class scope
216
+ _codec_name = CODEC_PREFIX + codec_name
217
+
218
+ class _Codec(_NumcodecsArrayBytesCodec):
219
+ codec_name = _codec_name
220
+
221
+ def __init__(self, **codec_config: JSON) -> None:
222
+ super().__init__(**codec_config)
223
+
224
+ _Codec.__name__ = cls_name
225
+ return _Codec
226
+
227
+
228
+ def _make_checksum_codec(codec_name: str, cls_name: str) -> type[_NumcodecsBytesBytesCodec]:
229
+ # rename for class scope
230
+ _codec_name = CODEC_PREFIX + codec_name
231
+
232
+ class _ChecksumCodec(_NumcodecsBytesBytesCodec):
233
+ codec_name = _codec_name
234
+
235
+ def __init__(self, **codec_config: JSON) -> None:
236
+ super().__init__(**codec_config)
237
+
238
+ def compute_encoded_size(self, input_byte_length: int, chunk_spec: ArraySpec) -> int:
239
+ return input_byte_length + 4 # pragma: no cover
240
+
241
+ _ChecksumCodec.__name__ = cls_name
242
+ return _ChecksumCodec
243
+
244
+
245
+ # bytes-to-bytes codecs
246
+ Blosc = _add_docstring(_make_bytes_bytes_codec("blosc", "Blosc"), "numcodecs.blosc.Blosc")
247
+ LZ4 = _add_docstring(_make_bytes_bytes_codec("lz4", "LZ4"), "numcodecs.lz4.LZ4")
248
+ Zstd = _add_docstring(_make_bytes_bytes_codec("zstd", "Zstd"), "numcodecs.zstd.Zstd")
249
+ Zlib = _add_docstring(_make_bytes_bytes_codec("zlib", "Zlib"), "numcodecs.zlib.Zlib")
250
+ GZip = _add_docstring(_make_bytes_bytes_codec("gzip", "GZip"), "numcodecs.gzip.GZip")
251
+ BZ2 = _add_docstring(_make_bytes_bytes_codec("bz2", "BZ2"), "numcodecs.bz2.BZ2")
252
+ LZMA = _add_docstring(_make_bytes_bytes_codec("lzma", "LZMA"), "numcodecs.lzma.LZMA")
253
+
254
+
255
+ @_add_docstring_wrapper("numcodecs.shuffle.Shuffle")
256
+ class Shuffle(_NumcodecsBytesBytesCodec):
257
+ codec_name = f"{CODEC_PREFIX}shuffle"
258
+
259
+ def __init__(self, **codec_config: JSON) -> None:
260
+ super().__init__(**codec_config)
261
+
262
+ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Shuffle:
263
+ if array_spec.dtype.itemsize != self.codec_config.get("elementsize"):
264
+ return Shuffle(**{**self.codec_config, "elementsize": array_spec.dtype.itemsize})
265
+ return self # pragma: no cover
266
+
267
+
268
+ # array-to-array codecs ("filters")
269
+ Delta = _add_docstring(_make_array_array_codec("delta", "Delta"), "numcodecs.delta.Delta")
270
+ BitRound = _add_docstring(
271
+ _make_array_array_codec("bitround", "BitRound"), "numcodecs.bitround.BitRound"
272
+ )
273
+
274
+
275
+ @_add_docstring_wrapper("numcodecs.fixedscaleoffset.FixedScaleOffset")
276
+ class FixedScaleOffset(_NumcodecsArrayArrayCodec):
277
+ codec_name = f"{CODEC_PREFIX}fixedscaleoffset"
278
+
279
+ def __init__(self, **codec_config: JSON) -> None:
280
+ super().__init__(**codec_config)
281
+
282
+ def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
283
+ if astype := self.codec_config.get("astype"):
284
+ return replace(chunk_spec, dtype=np.dtype(astype)) # type: ignore[arg-type]
285
+ return chunk_spec
286
+
287
+ def evolve_from_array_spec(self, array_spec: ArraySpec) -> FixedScaleOffset:
288
+ if str(array_spec.dtype) != self.codec_config.get("dtype"):
289
+ return FixedScaleOffset(**{**self.codec_config, "dtype": str(array_spec.dtype)})
290
+ return self
291
+
292
+
293
+ @_add_docstring_wrapper("numcodecs.quantize.Quantize")
294
+ class Quantize(_NumcodecsArrayArrayCodec):
295
+ codec_name = f"{CODEC_PREFIX}quantize"
296
+
297
+ def __init__(self, **codec_config: JSON) -> None:
298
+ super().__init__(**codec_config)
299
+
300
+ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Quantize:
301
+ if str(array_spec.dtype) != self.codec_config.get("dtype"):
302
+ return Quantize(**{**self.codec_config, "dtype": str(array_spec.dtype)})
303
+ return self
304
+
305
+
306
+ @_add_docstring_wrapper("numcodecs.packbits.PackBits")
307
+ class PackBits(_NumcodecsArrayArrayCodec):
308
+ codec_name = f"{CODEC_PREFIX}packbits"
309
+
310
+ def __init__(self, **codec_config: JSON) -> None:
311
+ super().__init__(**codec_config)
312
+
313
+ def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
314
+ return replace(
315
+ chunk_spec,
316
+ shape=(1 + math.ceil(product(chunk_spec.shape) / 8),),
317
+ dtype=np.dtype("uint8"),
318
+ )
319
+
320
+ def validate(self, *, dtype: np.dtype[Any], **_kwargs) -> None:
321
+ if dtype != np.dtype("bool"):
322
+ raise ValueError(f"Packbits filter requires bool dtype. Got {dtype}.")
323
+
324
+
325
+ @_add_docstring_wrapper("numcodecs.astype.AsType")
326
+ class AsType(_NumcodecsArrayArrayCodec):
327
+ codec_name = f"{CODEC_PREFIX}astype"
328
+
329
+ def __init__(self, **codec_config: JSON) -> None:
330
+ super().__init__(**codec_config)
331
+
332
+ def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
333
+ return replace(chunk_spec, dtype=np.dtype(self.codec_config["encode_dtype"])) # type: ignore[arg-type]
334
+
335
+ def evolve_from_array_spec(self, array_spec: ArraySpec) -> AsType:
336
+ decode_dtype = self.codec_config.get("decode_dtype")
337
+ if str(array_spec.dtype) != decode_dtype:
338
+ return AsType(**{**self.codec_config, "decode_dtype": str(array_spec.dtype)})
339
+ return self
340
+
341
+
342
+ # bytes-to-bytes checksum codecs
343
+ CRC32 = _add_docstring(_make_checksum_codec("crc32", "CRC32"), "numcodecs.checksum32.CRC32")
344
+ CRC32C = _add_docstring(_make_checksum_codec("crc32c", "CRC32C"), "numcodecs.checksum32.CRC32C")
345
+ Adler32 = _add_docstring(_make_checksum_codec("adler32", "Adler32"), "numcodecs.checksum32.Adler32")
346
+ Fletcher32 = _add_docstring(
347
+ _make_checksum_codec("fletcher32", "Fletcher32"), "numcodecs.fletcher32.Fletcher32"
348
+ )
349
+ JenkinsLookup3 = _add_docstring(
350
+ _make_checksum_codec("jenkins_lookup3", "JenkinsLookup3"), "numcodecs.checksum32.JenkinsLookup3"
351
+ )
352
+
353
+ # array-to-bytes codecs
354
+ PCodec = _add_docstring(_make_array_bytes_codec("pcodec", "PCodec"), "numcodecs.pcodec.PCodec")
355
+ ZFPY = _add_docstring(_make_array_bytes_codec("zfpy", "ZFPY"), "numcodecs.zfpy.ZFPY")
356
+
357
+ __all__ = [
358
+ "Blosc",
359
+ "LZ4",
360
+ "Zstd",
361
+ "Zlib",
362
+ "GZip",
363
+ "BZ2",
364
+ "LZMA",
365
+ "Shuffle",
366
+ "Delta",
367
+ "BitRound",
368
+ "FixedScaleOffset",
369
+ "Quantize",
370
+ "PackBits",
371
+ "AsType",
372
+ "CRC32",
373
+ "CRC32C",
374
+ "Adler32",
375
+ "Fletcher32",
376
+ "JenkinsLookup3",
377
+ "PCodec",
378
+ "ZFPY",
379
+ ]
numcodecs/zfpy.py CHANGED
@@ -1,8 +1,10 @@
1
+ import warnings
1
2
  from contextlib import suppress
2
3
  from importlib.metadata import PackageNotFoundError, version
3
- import warnings
4
+ from types import ModuleType
5
+ from typing import Optional
4
6
 
5
- _zfpy = None
7
+ _zfpy: Optional[ModuleType] = None
6
8
 
7
9
  _zfpy_version: tuple = ()
8
10
  with suppress(PackageNotFoundError):
@@ -17,16 +19,18 @@ if _zfpy_version:
17
19
  "NumPy version >= 2.0.0 detected. The zfpy library is incompatible with this version of NumPy. "
18
20
  "Please downgrade to NumPy < 2.0.0 or wait for an update from zfpy.",
19
21
  UserWarning,
22
+ stacklevel=2,
20
23
  )
21
24
  else:
22
25
  with suppress(ImportError):
23
- import zfpy as _zfpy
26
+ import zfpy as _zfpy # type: ignore[no-redef]
24
27
 
25
28
  if _zfpy:
26
- from .abc import Codec
27
- from .compat import ndarray_copy, ensure_contiguous_ndarray, ensure_bytes
28
29
  import numpy as np
29
30
 
31
+ from .abc import Codec
32
+ from .compat import ensure_bytes, ensure_contiguous_ndarray, ndarray_copy
33
+
30
34
  # noinspection PyShadowingBuiltins
31
35
  class ZFPY(Codec):
32
36
  """Codec providing compression using zfpy via the Python standard
@@ -102,11 +106,8 @@ if _zfpy:
102
106
  return dec
103
107
 
104
108
  def __repr__(self):
105
- r = "%s(mode=%r, tolerance=%s, rate=%s, precision=%s)" % (
106
- type(self).__name__,
107
- self.mode,
108
- self.tolerance,
109
- self.rate,
110
- self.precision,
109
+ return (
110
+ f"{type(self).__name__}(mode={self.mode!r}, "
111
+ f"tolerance={self.tolerance}, rate={self.rate}, "
112
+ f"precision={self.precision})"
111
113
  )
112
- return r
numcodecs/zlib.py CHANGED
@@ -1,8 +1,7 @@
1
1
  import zlib as _zlib
2
2
 
3
-
4
3
  from .abc import Codec
5
- from .compat import ndarray_copy, ensure_contiguous_ndarray
4
+ from .compat import ensure_contiguous_ndarray, ndarray_copy
6
5
 
7
6
 
8
7
  class Zlib(Codec):
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: numcodecs
3
- Version: 0.13.0
3
+ Version: 0.14.0
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: MIT
@@ -18,12 +18,14 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
18
  Classifier: Operating System :: Unix
19
19
  Classifier: Programming Language :: Python :: 3
20
20
  Classifier: Programming Language :: Python :: 3 :: Only
21
- Requires-Python: >=3.10
21
+ Requires-Python: >=3.11
22
22
  Description-Content-Type: text/x-rst
23
23
  License-File: LICENSE.txt
24
- Requires-Dist: numpy >=1.7
24
+ Requires-Dist: numpy >=1.24
25
+ Provides-Extra: crc32c
26
+ Requires-Dist: crc32c >=2.7 ; extra == 'crc32c'
25
27
  Provides-Extra: docs
26
- Requires-Dist: sphinx <7.0.0 ; extra == 'docs'
28
+ Requires-Dist: sphinx ; extra == 'docs'
27
29
  Requires-Dist: sphinx-issues ; extra == 'docs'
28
30
  Requires-Dist: pydata-sphinx-theme ; extra == 'docs'
29
31
  Requires-Dist: numpydoc ; extra == 'docs'
@@ -31,7 +33,7 @@ Requires-Dist: mock ; extra == 'docs'
31
33
  Provides-Extra: msgpack
32
34
  Requires-Dist: msgpack ; extra == 'msgpack'
33
35
  Provides-Extra: pcodec
34
- Requires-Dist: pcodec >=0.2.0 ; extra == 'pcodec'
36
+ Requires-Dist: pcodec <0.3,>=0.2 ; extra == 'pcodec'
35
37
  Provides-Extra: test
36
38
  Requires-Dist: coverage ; extra == 'test'
37
39
  Requires-Dist: pytest ; extra == 'test'
@@ -45,7 +47,7 @@ Requires-Dist: numpy <2.0.0 ; extra == 'zfpy'
45
47
  Numcodecs
46
48
  =========
47
49
 
48
- Numcodecs is a Python package providing buffer compression and transformation
50
+ Numcodecs is a Python package providing buffer compression and transformation
49
51
  codecs for use in data storage and communication applications.
50
52
 
51
53
  .. image:: https://readthedocs.org/projects/numcodecs/badge/?version=latest
@@ -0,0 +1,78 @@
1
+ numcodecs-0.14.0.dist-info/RECORD,,
2
+ numcodecs-0.14.0.dist-info/WHEEL,sha256=_QqtAaLoE5KabRyxEbihBVXZ2UYm7nzGTKq7KzoM3cQ,109
3
+ numcodecs-0.14.0.dist-info/entry_points.txt,sha256=3W3FHKrwE52X3fLq8KdioOtf93lh5KaoGV5t2D10DBI,919
4
+ numcodecs-0.14.0.dist-info/top_level.txt,sha256=JkHllzt6IuVudg4Tk--wF-yfPPsdVOiMTag1tjGIihw,10
5
+ numcodecs-0.14.0.dist-info/LICENSE.txt,sha256=lJysaEeeE7bJeSRjUVC04e9eaXZq2eRy6oWgjBV2u5Y,1124
6
+ numcodecs-0.14.0.dist-info/METADATA,sha256=sTRfpHqmugtMbGMkTSRf2XoBjGPiERfVOIaEk876DNE,3008
7
+ numcodecs/compat_ext.cpython-311-darwin.so,sha256=tNtHtvb_72WnW0X7TrxXNbp54ePFRS7OH2_iA4JLCxo,78720
8
+ numcodecs/lzma.py,sha256=T46qhtfl1910bMIbcat6bp6_XBcfP9u-3HElBwHiAOU,2241
9
+ numcodecs/fletcher32.cpython-311-darwin.so,sha256=2PDzQ96JzRy69-hDp7yQT1iZFd80lDsso6FdgJvAJ0w,206032
10
+ numcodecs/astype.py,sha256=0M9nV2Jb-8EwyoZGmOhCssaBvMej_B6hQ2p41VkmDdA,2137
11
+ numcodecs/gzip.py,sha256=7TyUzc9oliPqKA58VV7fNkCi_c9PP04MioAKG7a1oV0,1469
12
+ numcodecs/base64.py,sha256=i-WpnY7A-vT-71By_tVBvHi41O4DzuqYyB829eNd29E,784
13
+ numcodecs/bz2.py,sha256=4Ups3IMVsjvBlXyaeYONPdE14TaK9V-4LH5LSNe7AGc,1174
14
+ numcodecs/version.py,sha256=9XbM6DRatFmjNkeSNxF4a6enpQeo8nPyAy9RTPPwPpY,413
15
+ numcodecs/compat.py,sha256=JadagE6pTEcrX3V8wDml0n1tdkHvOWo6D21J3a4P0mw,6505
16
+ numcodecs/checksum32.py,sha256=CQACDazagg5bvM07XQUnpMFiWBfkVVP_u_SIOYdxRe4,5378
17
+ numcodecs/ndarray_like.py,sha256=Kl5O-oKpdvt_MsfYsD73d4dIr3WXaOJLdHUEsc6tIrc,1896
18
+ numcodecs/quantize.py,sha256=WNgbVPNR6CnaF58yBbVHIQ_jg1mBe8dirkZ2ErNpQOI,3037
19
+ numcodecs/registry.py,sha256=iGnnBJ1fuWBMQTvnLMMliXXMk2gmhaHq7o3m7i9kNsk,1833
20
+ numcodecs/pickles.py,sha256=qWNRLnWZnZ9nq_QhNNI2x-s1Uoq9Eq1lsgwCSRTTxJo,1288
21
+ numcodecs/fixedscaleoffset.py,sha256=3J5JWZcE13lAJz9axSEpTUpAC9H-yI2RBOX8oGhtwns,4196
22
+ numcodecs/__init__.py,sha256=fyEDQ93UsiZhacarMJ5YOUvmWZpvDi8-tWWF6S5tRFs,3207
23
+ numcodecs/bitround.py,sha256=4lei39ZG4G2GGkDxl12q29nR5_8a4Icx4T-OgP1A1D4,2845
24
+ numcodecs/zlib.py,sha256=gLPUICEQc5p6DICC_63nOsbUqxzJH_5ynuzenTQXzOQ,1049
25
+ numcodecs/shuffle.py,sha256=hYOFJOCEeDSNI-TqT1JrbQxbprkQD4R8VfSzD4IPI3I,1575
26
+ numcodecs/blosc.cpython-311-darwin.so,sha256=QJXM7vieXMfYAtWv7z56nyZ0IplwJLlqKz05BLINDu0,1058168
27
+ numcodecs/zarr3.py,sha256=yKajHAoBvJMWzGw59qiYrmhP9atPGzAlfNlpwcAIhac,13948
28
+ numcodecs/lz4.cpython-311-darwin.so,sha256=h3csnzvVvHpwu8xHayOchjKej_yj58LtXt1ACSz1mi8,248600
29
+ numcodecs/delta.py,sha256=XMETqU9gvhvf3O2GoBQottuOg87GJr1DeaFRGEJGxfE,2984
30
+ numcodecs/vlen.cpython-311-darwin.so,sha256=oOytzANsbTTov5fiR9L-Hf-pZqkkKdKS7EuE00aTWmw,261368
31
+ numcodecs/zfpy.py,sha256=ScGPw-w8t8CFHvijnwgE3pW4JIKD98QpSOH24sZsH60,3901
32
+ numcodecs/msgpacks.py,sha256=sd3uuMN1wQz9XecP8eZOQY-huqbjC6BlOzx4NsJ95kY,2611
33
+ numcodecs/jenkins.cpython-311-darwin.so,sha256=9Hkx-dslQ7ztCy64lDkTDWSWWAxSONaUVq8iFIi5e6g,187040
34
+ numcodecs/packbits.py,sha256=L7gM-8AQQTPC2IOPbatzNp-tH67EUp0Tonx_JSYHje4,1993
35
+ numcodecs/categorize.py,sha256=yUzeAuPTNbMiI2vhkPRcxpEi0yQnr1orFs_I_BVoEoo,2983
36
+ numcodecs/zstd.cpython-311-darwin.so,sha256=VGW8Vbq56DLVYQAqbRqreA85SvUM3ShfVdjaI8uhW_A,731272
37
+ numcodecs/json.py,sha256=Xu4dN-FydFaV-5jOewJxVBsV6rUfGUWIp4IncrjIR-E,3355
38
+ numcodecs/_shuffle.cpython-311-darwin.so,sha256=TcmEeNVPSduBU-HkEcnUC3Ymj0t-XEvByrPue6KeOJ0,182560
39
+ numcodecs/abc.py,sha256=a8EcPXbuKXaHuNfAj6CoeAVb6kphgKGoLsHcre2aXxg,4505
40
+ numcodecs/pcodec.py,sha256=7fOqhKUWURCbfbQFoEy8772UGna59F6v_6k_4QJrzZg,3079
41
+ numcodecs/tests/test_categorize.py,sha256=ftL-LSVq63R-kGuQxUb96uL1e563mlF9CWAf3yQB-Bk,2756
42
+ numcodecs/tests/test_registry.py,sha256=9eUhr3PDw_rj7mk5k8Gh4Szl3pUXbXXZuTfZXKW-ZPU,1052
43
+ numcodecs/tests/test_vlen_utf8.py,sha256=H92YtqNY0kpO2Icu1Ey2iItK38ZhKMnJi_2FBwcKSvU,2474
44
+ numcodecs/tests/test_bitround.py,sha256=ayCuANNDA0cP3mqZkJ90QU9eI7ws4-lPRKU_gkflOlg,2349
45
+ numcodecs/tests/test_gzip.py,sha256=I685q0_vu3b_JibUz3nhW1mQtlLSQzGdgGD2twbGPXc,2925
46
+ numcodecs/tests/test_zarr3.py,sha256=RqWJMvsCDKFfsCufptIyTCnypE0xEIPRCbCHo1hkYY8,7547
47
+ numcodecs/tests/test_delta.py,sha256=1_XnV1JYMEnxO0iXDXVSzTltjRPtdoEb4Y8TpmllS-o,1636
48
+ numcodecs/tests/test_lzma.py,sha256=VyepAqH5Bzne-_VdTIV8E8KHkGwK9QoLdrD-1iRX5p4,2721
49
+ numcodecs/tests/test_bz2.py,sha256=pefO_YlOLr-RIswHas8DAQ4j81jhqLT5XGEuQ2i8DtI,1889
50
+ numcodecs/tests/__init__.py,sha256=Q6sNFjGUjcEU3MvCUd-PDtmYcS79Yvys3wbWWXvU5qY,72
51
+ numcodecs/tests/test_pickles.py,sha256=p7LfH5qJp1mmJC0nRWJbyPVCvt46raS_A6pjOZYOXqY,1679
52
+ numcodecs/tests/test_quantize.py,sha256=KvOyoj-u4S_-z8pT4syR6yE4i1ftFGkRfCTmgafumGw,2151
53
+ numcodecs/tests/test_entrypoints_backport.py,sha256=3IVVH4VmXu6e1gzUpU5S8koCtR3X-3HAqAlPqdRlv6M,1108
54
+ numcodecs/tests/test_pcodec.py,sha256=cM0Knn6gzuqF8cMqn-aTspCAu6T45Dp53PfT4F_WejI,2024
55
+ numcodecs/tests/test_lz4.py,sha256=63bjnBmT-bHCduj9w_LRTkJKBvo8emBzwVpzoDC5-A0,2353
56
+ numcodecs/tests/test_msgpacks.py,sha256=03FEZBME1z7vRAzDTX-xdOQ-_ZMzn4R9GRMrsZeKI0s,3950
57
+ numcodecs/tests/test_astype.py,sha256=Wu1HtHZA6K_rW-JCxSWmU4Wwp9U83JUbUZ2ro9xDk9s,2367
58
+ numcodecs/tests/test_jenkins.py,sha256=DoOXdTLD25aXA0nwiO1zk_vG4N2UI6Wc3C72yqIByNc,4446
59
+ numcodecs/tests/test_fletcher32.py,sha256=hNf2zSAi16k4222qI2k-n5X4GgswVBfOqvKHSgSoRxQ,1456
60
+ numcodecs/tests/test_packbits.py,sha256=8B2sQnM-DiAEtehCEm5xm7fQ1xWm0rMk_z7Uk8OXvGI,989
61
+ numcodecs/tests/common.py,sha256=cLiS3SwUORLL0N8Yx4TjqgrB7Y9nwxx_5-T2qL0vqD0,12168
62
+ numcodecs/tests/test_base64.py,sha256=QseE5-aDwz7yv5-0dAG_6vTjeN3OpFvgcg8IhklRA4Y,2315
63
+ numcodecs/tests/test_shuffle.py,sha256=OH-3B3q6nY0wmBfR93jndtm0dNX4k8BQCHuQYPHvur0,4689
64
+ numcodecs/tests/test_fixedscaleoffset.py,sha256=3RclYFw3WFu36WUIciZ23gNIiBmzboXvrEugMw1311A,2536
65
+ numcodecs/tests/test_compat.py,sha256=YdaGiNsXgounzSX7uFXOz_7uh6Wf1n6kO0Ql6eICtIY,3728
66
+ numcodecs/tests/test_zlib.py,sha256=TFa-I15xHd4h2nNC2goChWdlB_xZLbK_vAL7s4upPWI,2539
67
+ numcodecs/tests/test_json.py,sha256=od5MZbSclKFWM_RjS2DsVWGIYlJXG6-wm0yQLdkBTh0,2292
68
+ numcodecs/tests/test_ndarray_like.py,sha256=Bh8wDqkbSL-yr_MDQqE5XUoWzZav5J_VzC8Lfv3BBlA,1273
69
+ numcodecs/tests/test_vlen_array.py,sha256=QaWVuflGxQUFToVcWVIzZHG_b8Vm4JJG6mBZVGNasK0,2477
70
+ numcodecs/tests/test_zstd.py,sha256=79R6VMhni-6kg9LmlmBzGe22HXhg0RvSVjw4jVNPMJQ,2610
71
+ numcodecs/tests/test_vlen_bytes.py,sha256=BpASj3-ap_ZjyK_nYP7YQSZg4gsECCh5DW_4pdNlhRs,2473
72
+ numcodecs/tests/test_entrypoints.py,sha256=zWbyosPRhbSevwp4grlfjfnEyIneny-u7XmMe1xcoLI,504
73
+ numcodecs/tests/test_zarr3_import.py,sha256=JBDyrL57lbZMI9axb9eA1OZnd_Lg-ppfsNV3VvxwVxk,332
74
+ numcodecs/tests/test_checksum32.py,sha256=IR1ZXf2XJFh0Vrpxyz4P7RFym2kxtagp-yYDZowicPc,4238
75
+ numcodecs/tests/test_zfpy.py,sha256=g_2txraHDbnBPtbymJXsgAiD6MBH44-JYRkNx9tttYw,2762
76
+ numcodecs/tests/test_blosc.py,sha256=VixIjcQNlzIdXrs1yvEMA1q7EMAu1jLy_VtRmgjcQU4,8866
77
+ numcodecs/tests/package_with_entrypoint-0.1.dist-info/entry_points.txt,sha256=wel2k9KStuNez__clm2tjAwrcXiP17De8yNScHYtQZU,60
78
+ numcodecs/tests/package_with_entrypoint/__init__.py,sha256=wLyrk73nqKO8rcFtA_sXlcC8PKMzdYbbBRY8eH8Xc10,212
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.3.0)
2
+ Generator: setuptools (75.5.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp311-cp311-macosx_11_0_arm64
5
5
 
@@ -0,0 +1,22 @@
1
+ [zarr.codecs]
2
+ numcodecs.adler32 = numcodecs.zarr3:Adler32
3
+ numcodecs.astype = numcodecs.zarr3:AsType
4
+ numcodecs.bitround = numcodecs.zarr3:BitRound
5
+ numcodecs.blosc = numcodecs.zarr3:Blosc
6
+ numcodecs.bz2 = numcodecs.zarr3:BZ2
7
+ numcodecs.crc32 = numcodecs.zarr3:CRC32
8
+ numcodecs.crc32c = numcodecs.zarr3:CRC32C
9
+ numcodecs.delta = numcodecs.zarr3:Delta
10
+ numcodecs.fixedscaleoffset = numcodecs.zarr3:FixedScaleOffset
11
+ numcodecs.fletcher32 = numcodecs.zarr3:Fletcher32
12
+ numcodecs.gzip = numcodecs.zarr3:GZip
13
+ numcodecs.jenkins_lookup3 = numcodecs.zarr3:JenkinsLookup3
14
+ numcodecs.lz4 = numcodecs.zarr3:LZ4
15
+ numcodecs.lzma = numcodecs.zarr3:LZMA
16
+ numcodecs.packbits = numcodecs.zarr3:PackBits
17
+ numcodecs.pcodec = numcodecs.zarr3:PCodec
18
+ numcodecs.quantize = numcodecs.zarr3:Quantize
19
+ numcodecs.shuffle = numcodecs.zarr3:Shuffle
20
+ numcodecs.zfpy = numcodecs.zarr3:ZFPY
21
+ numcodecs.zlib = numcodecs.zarr3:Zlib
22
+ numcodecs.zstd = numcodecs.zarr3:Zstd