numcodecs 0.15.0__cp311-cp311-macosx_11_0_arm64.whl → 0.15.1__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.

Binary file
Binary file
numcodecs/checksum32.py CHANGED
@@ -13,7 +13,7 @@ from .jenkins import jenkins_lookup3
13
13
 
14
14
  _crc32c: Optional[ModuleType] = None
15
15
  with suppress(ImportError):
16
- import crc32c as _crc32c # type: ignore[no-redef]
16
+ import crc32c as _crc32c # type: ignore[no-redef, unused-ignore]
17
17
 
18
18
  if TYPE_CHECKING: # pragma: no cover
19
19
  from typing_extensions import Buffer
Binary file
numcodecs/errors.py ADDED
@@ -0,0 +1,26 @@
1
+ """
2
+ This module defines custom exceptions that are raised in the `numcodecs` codebase.
3
+ """
4
+
5
+
6
+ class UnknownCodecError(ValueError):
7
+ """
8
+ An exception that is raised when trying to receive a codec that has not been registered.
9
+
10
+ Parameters
11
+ ----------
12
+ codec_id : str
13
+ Codec identifier.
14
+
15
+ Examples
16
+ ----------
17
+ >>> import numcodecs
18
+ >>> numcodecs.get_codec({"codec_id": "unknown"})
19
+ Traceback (most recent call last):
20
+ ...
21
+ UnknownCodecError: codec not available: 'unknown'
22
+ """
23
+
24
+ def __init__(self, codec_id: str):
25
+ self.codec_id = codec_id
26
+ super().__init__(f"codec not available: '{codec_id}'")
Binary file
Binary file
numcodecs/json.py CHANGED
@@ -68,7 +68,7 @@ class JSON(Codec):
68
68
  def encode(self, buf):
69
69
  try:
70
70
  buf = np.asarray(buf)
71
- except ValueError:
71
+ except ValueError: # pragma: no cover
72
72
  buf = np.asarray(buf, dtype=object)
73
73
  items = np.atleast_1d(buf).tolist()
74
74
  items.append(buf.dtype.str)
Binary file
numcodecs/quantize.py CHANGED
@@ -65,9 +65,9 @@ class Quantize(Codec):
65
65
  precision = 10.0**-self.digits
66
66
  exp = math.log10(precision)
67
67
  if exp < 0:
68
- exp = int(math.floor(exp))
68
+ exp = math.floor(exp)
69
69
  else:
70
- exp = int(math.ceil(exp))
70
+ exp = math.ceil(exp)
71
71
  bits = math.ceil(math.log2(10.0**-exp))
72
72
  scale = 2.0**bits
73
73
  enc = np.around(scale * arr) / scale
numcodecs/registry.py CHANGED
@@ -5,6 +5,7 @@ import logging
5
5
  from importlib.metadata import EntryPoints, entry_points
6
6
 
7
7
  from numcodecs.abc import Codec
8
+ from numcodecs.errors import UnknownCodecError
8
9
 
9
10
  logger = logging.getLogger("numcodecs")
10
11
  codec_registry: dict[str, Codec] = {}
@@ -50,7 +51,7 @@ def get_codec(config):
50
51
  register_codec(cls, codec_id=codec_id)
51
52
  if cls:
52
53
  return cls.from_config(config)
53
- raise ValueError(f'codec not available: {codec_id!r}')
54
+ raise UnknownCodecError(f"{codec_id!r}")
54
55
 
55
56
 
56
57
  def register_codec(cls, codec_id=None):
@@ -3,11 +3,12 @@ import inspect
3
3
  import pytest
4
4
 
5
5
  import numcodecs
6
+ from numcodecs.errors import UnknownCodecError
6
7
  from numcodecs.registry import get_codec
7
8
 
8
9
 
9
10
  def test_registry_errors():
10
- with pytest.raises(ValueError):
11
+ with pytest.raises(UnknownCodecError, match='foo'):
11
12
  get_codec({'id': 'foo'})
12
13
 
13
14
 
@@ -91,7 +91,7 @@ def test_generic_compressor(
91
91
  (numcodecs.zarr3.Delta, {"dtype": "float32"}),
92
92
  (numcodecs.zarr3.FixedScaleOffset, {"offset": 0, "scale": 25.5}),
93
93
  (numcodecs.zarr3.FixedScaleOffset, {"offset": 0, "scale": 51, "astype": "uint16"}),
94
- (numcodecs.zarr3.AsType, {"encode_dtype": "float32", "decode_dtype": "float64"}),
94
+ (numcodecs.zarr3.AsType, {"encode_dtype": "float32", "decode_dtype": "float32"}),
95
95
  ],
96
96
  ids=[
97
97
  "delta",
@@ -225,11 +225,11 @@ def test_generic_bytes_codec(
225
225
  ):
226
226
  try:
227
227
  codec_class()._codec # noqa: B018
228
- except ValueError as e:
228
+ except ValueError as e: # pragma: no cover
229
229
  if "codec not available" in str(e):
230
230
  pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
231
231
  else:
232
- raise # pragma: no cover
232
+ raise
233
233
  except ImportError as e: # pragma: no cover
234
234
  pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
235
235
 
@@ -272,3 +272,8 @@ def test_delta_astype(store: StorePath):
272
272
  def test_repr():
273
273
  codec = numcodecs.zarr3.LZ4(level=5)
274
274
  assert repr(codec) == "LZ4(codec_name='numcodecs.lz4', codec_config={'level': 5})"
275
+
276
+
277
+ def test_to_dict():
278
+ codec = numcodecs.zarr3.LZ4(level=5)
279
+ assert codec.to_dict() == {"name": "numcodecs.lz4", "configuration": {"level": 5}}
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.15.0'
16
- __version_tuple__ = version_tuple = (0, 15, 0)
15
+ __version__ = version = '0.15.1'
16
+ __version_tuple__ = version_tuple = (0, 15, 1)
Binary file
numcodecs/zarr3.py CHANGED
@@ -112,6 +112,7 @@ class _NumcodecsCodec(Metadata):
112
112
 
113
113
  def to_dict(self) -> dict[str, JSON]:
114
114
  codec_config = self.codec_config.copy()
115
+ codec_config.pop("id", None)
115
116
  return {
116
117
  "name": self.codec_name,
117
118
  "configuration": codec_config,
@@ -270,7 +271,7 @@ class Shuffle(_NumcodecsBytesBytesCodec):
270
271
  super().__init__(**codec_config)
271
272
 
272
273
  def evolve_from_array_spec(self, array_spec: ArraySpec) -> Shuffle:
273
- if array_spec.dtype.itemsize != self.codec_config.get("elementsize"):
274
+ if self.codec_config.get("elementsize", None) is None:
274
275
  return Shuffle(**{**self.codec_config, "elementsize": array_spec.dtype.itemsize})
275
276
  return self # pragma: no cover
276
277
 
@@ -307,7 +308,7 @@ class FixedScaleOffset(_NumcodecsArrayArrayCodec):
307
308
  return chunk_spec
308
309
 
309
310
  def evolve_from_array_spec(self, array_spec: ArraySpec) -> FixedScaleOffset:
310
- if str(array_spec.dtype) != self.codec_config.get("dtype"):
311
+ if self.codec_config.get("dtype", None) is None:
311
312
  return FixedScaleOffset(**{**self.codec_config, "dtype": str(array_spec.dtype)})
312
313
  return self
313
314
 
@@ -320,7 +321,7 @@ class Quantize(_NumcodecsArrayArrayCodec):
320
321
  super().__init__(**codec_config)
321
322
 
322
323
  def evolve_from_array_spec(self, array_spec: ArraySpec) -> Quantize:
323
- if str(array_spec.dtype) != self.codec_config.get("dtype"):
324
+ if self.codec_config.get("dtype", None) is None:
324
325
  return Quantize(**{**self.codec_config, "dtype": str(array_spec.dtype)})
325
326
  return self
326
327
 
@@ -355,8 +356,7 @@ class AsType(_NumcodecsArrayArrayCodec):
355
356
  return replace(chunk_spec, dtype=np.dtype(self.codec_config["encode_dtype"])) # type: ignore[arg-type]
356
357
 
357
358
  def evolve_from_array_spec(self, array_spec: ArraySpec) -> AsType:
358
- decode_dtype = self.codec_config.get("decode_dtype")
359
- if str(array_spec.dtype) != decode_dtype:
359
+ if self.codec_config.get("decode_dtype", None) is None:
360
360
  return AsType(**{**self.codec_config, "decode_dtype": str(array_spec.dtype)})
361
361
  return self
362
362
 
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: numcodecs
3
- Version: 0.15.0
3
+ Version: 0.15.1
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
@@ -1,49 +1,50 @@
1
- numcodecs-0.15.0.dist-info/RECORD,,
2
- numcodecs-0.15.0.dist-info/WHEEL,sha256=NW1RskY9zow1Y68W-gXg0oZyBRAugI1JHywIzAIai5o,109
3
- numcodecs-0.15.0.dist-info/entry_points.txt,sha256=3W3FHKrwE52X3fLq8KdioOtf93lh5KaoGV5t2D10DBI,919
4
- numcodecs-0.15.0.dist-info/top_level.txt,sha256=JkHllzt6IuVudg4Tk--wF-yfPPsdVOiMTag1tjGIihw,10
5
- numcodecs-0.15.0.dist-info/LICENSE.txt,sha256=lJysaEeeE7bJeSRjUVC04e9eaXZq2eRy6oWgjBV2u5Y,1124
6
- numcodecs-0.15.0.dist-info/METADATA,sha256=Ex3f5L-JE6Kr2Bm9v148Lu1xeLTFWkH7k0k9kbL2iGM,2934
7
- numcodecs/compat_ext.cpython-311-darwin.so,sha256=MPRCMp3ey6JuyLzx1QPBczhKlYtsJJ2wo4dGgEd0CtU,78720
1
+ numcodecs-0.15.1.dist-info/RECORD,,
2
+ numcodecs-0.15.1.dist-info/WHEEL,sha256=NW1RskY9zow1Y68W-gXg0oZyBRAugI1JHywIzAIai5o,109
3
+ numcodecs-0.15.1.dist-info/entry_points.txt,sha256=3W3FHKrwE52X3fLq8KdioOtf93lh5KaoGV5t2D10DBI,919
4
+ numcodecs-0.15.1.dist-info/top_level.txt,sha256=JkHllzt6IuVudg4Tk--wF-yfPPsdVOiMTag1tjGIihw,10
5
+ numcodecs-0.15.1.dist-info/LICENSE.txt,sha256=lJysaEeeE7bJeSRjUVC04e9eaXZq2eRy6oWgjBV2u5Y,1124
6
+ numcodecs-0.15.1.dist-info/METADATA,sha256=T3XwC0XFISSWpaQTIYlzENZDZN3F5scItBHMhsR2MLQ,2934
7
+ numcodecs/compat_ext.cpython-311-darwin.so,sha256=MiHYUdZqRwhUpiKV0RUE7Xb40Ky_xbRWUjjKeOsJ6kA,78720
8
8
  numcodecs/lzma.py,sha256=6XeJ-c-lTJN1EVrIOb5cEFEiMGlNHsS4c_OentmUox0,2257
9
- numcodecs/fletcher32.cpython-311-darwin.so,sha256=NHaXZLoCvqNow-GKy_wvEiyfadM6DAPBAE17rwshiWI,206032
9
+ numcodecs/fletcher32.cpython-311-darwin.so,sha256=nlDzz5RWYyXYd5DBkZswPzW5WtnFrU_uBMVsBgN8k1E,206032
10
10
  numcodecs/astype.py,sha256=pfdFqjNvb-PETswa2_UxZm632O-y2Lex-g_68IJpiuk,2099
11
11
  numcodecs/gzip.py,sha256=DJuc87g8neqn-SYEeCEQwPSdEN5oZGgDUan9MTI6Fb4,1436
12
12
  numcodecs/base64.py,sha256=79BSqVvloKc8JYenUQfqdPm0a0JAZhd9Zld7k5Cp2lc,752
13
13
  numcodecs/bz2.py,sha256=4Ups3IMVsjvBlXyaeYONPdE14TaK9V-4LH5LSNe7AGc,1174
14
- numcodecs/version.py,sha256=oHv-EAjiXbJma3jZ0Tq6UPimiWYyyw2Ao9S8zdq9uWs,413
14
+ numcodecs/version.py,sha256=po5_rvCFTU8xU9IC56wyK0-zfBgz_U4xX6CO2mv9Mzs,413
15
15
  numcodecs/compat.py,sha256=JadagE6pTEcrX3V8wDml0n1tdkHvOWo6D21J3a4P0mw,6505
16
- numcodecs/checksum32.py,sha256=L4BxbQZZ556EvJlYyxCQgZ3fvIZFxva_rycOx7FEBdY,5435
16
+ numcodecs/checksum32.py,sha256=iYJY1oAUQ71_Dk167uBuPh1wLOdozhGCbld7f7-qqhg,5450
17
17
  numcodecs/ndarray_like.py,sha256=fVupUg_K_rDZNRlUmTiRp53OmF6YHb-yNyixJNFR8ME,1883
18
- numcodecs/quantize.py,sha256=UcQPVsWvx7fHb5mWfOd7VvhCc-MI8C2B3afBG4KYUFM,3026
19
- numcodecs/registry.py,sha256=76qBMok0wR_eeffFZNNEiFxysjHNVI_76AxFGi9p5PI,1831
18
+ numcodecs/quantize.py,sha256=4mPx4kWanv5wGa22HvEiP893xqG5dDDtN-oKChj6nfE,3016
19
+ numcodecs/registry.py,sha256=oRN9uJsWIosZbAZFkOWyUos3GZ-h_zq_cN-t_uPLk0A,1864
20
20
  numcodecs/pickles.py,sha256=LtcMa6cK-V5TUYJNR4dRDsWWRmLfNv0syZddbrbRv3A,1290
21
21
  numcodecs/fixedscaleoffset.py,sha256=fQwP_H-P3Mq4_LXtMQw5CLYeMjCBUdTtV-AKWVAIzkY,4188
22
22
  numcodecs/__init__.py,sha256=LzVQQ8X8Mk7mXvOX9tu5tlwmQwIVhuhXMofXdFJJNjo,3103
23
23
  numcodecs/bitround.py,sha256=4lei39ZG4G2GGkDxl12q29nR5_8a4Icx4T-OgP1A1D4,2845
24
24
  numcodecs/zlib.py,sha256=gLPUICEQc5p6DICC_63nOsbUqxzJH_5ynuzenTQXzOQ,1049
25
25
  numcodecs/shuffle.py,sha256=hYOFJOCEeDSNI-TqT1JrbQxbprkQD4R8VfSzD4IPI3I,1575
26
- numcodecs/blosc.cpython-311-darwin.so,sha256=ULRtGklGXYe0Ow6fc7qcbhrVnRBN3TgX443bfBxY43I,1059688
27
- numcodecs/zarr3.py,sha256=lBBOVkoVmZ1YPU4z1RxdRHXaS4LXlD6ys_YobQ1gZM8,14712
28
- numcodecs/lz4.cpython-311-darwin.so,sha256=7GVZoI_QxpeDmgkISA6cIR1l7litar8AwyVymgdV17c,248600
26
+ numcodecs/blosc.cpython-311-darwin.so,sha256=hxFoqw8bpZDe_OVy1VQvZQTs5ebib9MgFjAFksqnyGw,1059688
27
+ numcodecs/zarr3.py,sha256=dfGgWL1yfB-YPwUzhlDQtfTuNziCeq6m9PvR-X-KlhQ,14665
28
+ numcodecs/lz4.cpython-311-darwin.so,sha256=mIg7dd_Rt5jOTJVgzhycHJne5MX4pikhafem1l6QqMs,248600
29
29
  numcodecs/delta.py,sha256=x0PjNiuX48rmh9M6ZHoYkI9bKOq00Aiyz_jLrVlAq8w,2791
30
- numcodecs/vlen.cpython-311-darwin.so,sha256=nasCAbLnpJwS6xpZ3fZG_L4IV6snWIZxeHA7_OZj8iY,261368
30
+ numcodecs/vlen.cpython-311-darwin.so,sha256=jmA1pWLOvR4naujO_IBbe5keUvcL_2crladvQERsInI,261368
31
31
  numcodecs/zfpy.py,sha256=--TCrXOsSJ-2uU_7d-0YwHpk8Hti98hofB4jht5helk,3900
32
32
  numcodecs/msgpacks.py,sha256=GkTcFJrhKdpWnwQn4-282q4_edqlzZFdJFux2LtNk30,2619
33
- numcodecs/jenkins.cpython-311-darwin.so,sha256=156LcgjZycPdf468b0twrTqKg4VTzejIow0OtW7yJKE,187040
33
+ numcodecs/errors.py,sha256=IV0B9fw_Wn8k3fjLtXOOU_-0_Al-dWY_dizvqFiNwkk,663
34
+ numcodecs/jenkins.cpython-311-darwin.so,sha256=yW_PI46UJEhWyT8wjnmFGoiwJIs-6mhO1zfO8HAeCZ0,187040
34
35
  numcodecs/packbits.py,sha256=L7gM-8AQQTPC2IOPbatzNp-tH67EUp0Tonx_JSYHje4,1993
35
36
  numcodecs/categorize.py,sha256=jPipT6mVrpGSe9QuI-MeVzTZuUKAZWF0XN5Wj_8Ifng,2948
36
- numcodecs/zstd.cpython-311-darwin.so,sha256=4U4APvzAUGzmf2CXBZd6gYuj-oW23k3Br7tvhfnybTU,731272
37
- numcodecs/json.py,sha256=mtzQE4a_vC3LJcVNnI3_HKqk96OPTebsMZLYye2Fbx4,3373
38
- numcodecs/_shuffle.cpython-311-darwin.so,sha256=ZHVyr5RcUL-tLpOB7VC1vE-RnwoPrYykzCxxVKXkb-M,182560
37
+ numcodecs/zstd.cpython-311-darwin.so,sha256=0uuWFE9Rmsm8Ro1HDIrrTt9tjNaU_jCQ-3z-mCAgEB8,731272
38
+ numcodecs/json.py,sha256=WQcDcDPVxAQm-sxUg_XD70InKLD4iyjQOBiHPn2N3VE,3393
39
+ numcodecs/_shuffle.cpython-311-darwin.so,sha256=dIsxqM9oUpYJchyYGjdklx1V6g5BcDlibU-RAY7jhHk,182560
39
40
  numcodecs/abc.py,sha256=13vRquZ-u_n1YqM9SYx8sBDseJlH9A_A57_Z2QE-4KY,4504
40
41
  numcodecs/pcodec.py,sha256=ZB2Hw5l7aOKi0hOQ3M7GOAwaTNCBRiNr_8IpJPdrcE4,4714
41
42
  numcodecs/tests/test_categorize.py,sha256=ftL-LSVq63R-kGuQxUb96uL1e563mlF9CWAf3yQB-Bk,2756
42
- numcodecs/tests/test_registry.py,sha256=RsxLV9oO37jpUOaj58L-RgNX9Brw_SjH2Pb1eJsYS6c,1049
43
+ numcodecs/tests/test_registry.py,sha256=9Wp-VxGtEtNvwj46Edv6R8Jc4WPu80yWP7mRZyxepJ4,1116
43
44
  numcodecs/tests/test_vlen_utf8.py,sha256=H92YtqNY0kpO2Icu1Ey2iItK38ZhKMnJi_2FBwcKSvU,2474
44
45
  numcodecs/tests/test_bitround.py,sha256=ayCuANNDA0cP3mqZkJ90QU9eI7ws4-lPRKU_gkflOlg,2349
45
46
  numcodecs/tests/test_gzip.py,sha256=I685q0_vu3b_JibUz3nhW1mQtlLSQzGdgGD2twbGPXc,2925
46
- numcodecs/tests/test_zarr3.py,sha256=b35dc1yZTM21TuVknJr7v_MS9ECNaLIdEt05vd8_fNM,8333
47
+ numcodecs/tests/test_zarr3.py,sha256=LbOuTVEn1XGhtLNx3Sv3wUu3gl0kV7ne_gE_cloUYIE,8483
47
48
  numcodecs/tests/test_delta.py,sha256=1_XnV1JYMEnxO0iXDXVSzTltjRPtdoEb4Y8TpmllS-o,1636
48
49
  numcodecs/tests/test_lzma.py,sha256=mPj5MebkWg1h0W4ClFF_34cJ0_Toje7z7JZ8gOMngzs,2723
49
50
  numcodecs/tests/test_bz2.py,sha256=pefO_YlOLr-RIswHas8DAQ4j81jhqLT5XGEuQ2i8DtI,1889