numcodecs 0.13.1__cp311-cp311-macosx_11_0_arm64.whl → 0.14.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.

Files changed (46) hide show
  1. numcodecs/__init__.py +12 -6
  2. numcodecs/_shuffle.cpython-311-darwin.so +0 -0
  3. numcodecs/abc.py +2 -1
  4. numcodecs/bitround.py +2 -1
  5. numcodecs/blosc.cpython-311-darwin.so +0 -0
  6. numcodecs/checksum32.py +86 -10
  7. numcodecs/compat.py +2 -4
  8. numcodecs/compat_ext.cpython-311-darwin.so +0 -0
  9. numcodecs/delta.py +5 -1
  10. numcodecs/fletcher32.cpython-311-darwin.so +0 -0
  11. numcodecs/jenkins.cpython-311-darwin.so +0 -0
  12. numcodecs/lz4.cpython-311-darwin.so +0 -0
  13. numcodecs/lzma.py +5 -2
  14. numcodecs/ndarray_like.py +1 -1
  15. numcodecs/packbits.py +0 -3
  16. numcodecs/pcodec.py +2 -3
  17. numcodecs/registry.py +9 -8
  18. numcodecs/tests/test_bitround.py +3 -3
  19. numcodecs/tests/test_blosc.py +2 -2
  20. numcodecs/tests/test_checksum32.py +113 -17
  21. numcodecs/tests/test_compat.py +3 -0
  22. numcodecs/tests/test_delta.py +1 -0
  23. numcodecs/tests/test_entrypoints.py +1 -1
  24. numcodecs/tests/test_entrypoints_backport.py +3 -2
  25. numcodecs/tests/test_fixedscaleoffset.py +13 -5
  26. numcodecs/tests/test_json.py +1 -1
  27. numcodecs/tests/test_lzma.py +4 -0
  28. numcodecs/tests/test_msgpacks.py +4 -1
  29. numcodecs/tests/test_pcodec.py +1 -1
  30. numcodecs/tests/test_registry.py +12 -10
  31. numcodecs/tests/test_shuffle.py +3 -3
  32. numcodecs/tests/test_zarr3.py +246 -0
  33. numcodecs/tests/test_zarr3_import.py +13 -0
  34. numcodecs/tests/test_zfpy.py +6 -0
  35. numcodecs/version.py +2 -2
  36. numcodecs/vlen.cpython-311-darwin.so +0 -0
  37. numcodecs/zarr3.py +379 -0
  38. numcodecs/zfpy.py +4 -2
  39. numcodecs/zstd.cpython-311-darwin.so +0 -0
  40. {numcodecs-0.13.1.dist-info → numcodecs-0.14.1.dist-info}/METADATA +20 -19
  41. numcodecs-0.14.1.dist-info/RECORD +78 -0
  42. {numcodecs-0.13.1.dist-info → numcodecs-0.14.1.dist-info}/WHEEL +1 -1
  43. numcodecs-0.14.1.dist-info/entry_points.txt +22 -0
  44. numcodecs-0.13.1.dist-info/RECORD +0 -74
  45. {numcodecs-0.13.1.dist-info → numcodecs-0.14.1.dist-info}/LICENSE.txt +0 -0
  46. {numcodecs-0.13.1.dist-info → numcodecs-0.14.1.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,7 @@
1
1
  import itertools
2
2
  import unittest
3
+ from types import ModuleType
4
+ from typing import cast
3
5
 
4
6
  import numpy as np
5
7
  import pytest
@@ -20,6 +22,8 @@ from numcodecs.tests.common import (
20
22
  check_repr,
21
23
  )
22
24
 
25
+ _lzma = cast(ModuleType, _lzma)
26
+
23
27
  codecs = [
24
28
  LZMA(),
25
29
  LZMA(preset=1),
@@ -55,8 +55,11 @@ def test_backwards_compatibility():
55
55
  check_backwards_compatibility(codec.codec_id, arrays, [codec])
56
56
 
57
57
 
58
+ @pytest.mark.filterwarnings(
59
+ "ignore:Creating an ndarray from ragged nested sequences .* is deprecated.*"
60
+ )
58
61
  @pytest.mark.parametrize(
59
- "input_data, dtype",
62
+ ("input_data", "dtype"),
60
63
  [
61
64
  ([0, 1], None),
62
65
  ([[0, 1], [2, 3]], None),
@@ -57,8 +57,8 @@ def test_config():
57
57
 
58
58
 
59
59
  def test_invalid_config_error():
60
+ codec = PCodec(mode_spec='bogus')
60
61
  with pytest.raises(ValueError):
61
- codec = PCodec(mode_spec='bogus')
62
62
  check_encode_decode_array_to_bytes(arrays[0], codec)
63
63
 
64
64
 
@@ -26,15 +26,17 @@ def test_all_classes_registered():
26
26
 
27
27
  see #346 for more info
28
28
  """
29
- missing = set()
30
- for _name, submod in inspect.getmembers(numcodecs, inspect.ismodule):
31
- for _name, obj in inspect.getmembers(submod):
32
- if inspect.isclass(obj):
33
- if issubclass(obj, numcodecs.abc.Codec):
34
- if obj.codec_id not in numcodecs.registry.codec_registry:
35
- missing.add(obj.codec_id)
36
-
37
- # remove `None``
38
- missing.remove(None)
29
+ missing = set(
30
+ obj.codec_id
31
+ for _, submod in inspect.getmembers(numcodecs, inspect.ismodule)
32
+ for _, obj in inspect.getmembers(submod)
33
+ if (
34
+ inspect.isclass(obj)
35
+ and issubclass(obj, numcodecs.abc.Codec)
36
+ and obj.codec_id not in numcodecs.registry.codec_registry
37
+ and obj.codec_id is not None # remove `None`
38
+ )
39
+ )
40
+
39
41
  if missing:
40
42
  raise Exception(f"these codecs are missing: {missing}") # pragma: no cover
@@ -89,7 +89,7 @@ def _decode_worker(enc):
89
89
  return data
90
90
 
91
91
 
92
- @pytest.mark.parametrize('pool', (Pool, ThreadPool))
92
+ @pytest.mark.parametrize('pool', [Pool, ThreadPool])
93
93
  def test_multiprocessing(pool):
94
94
  data = np.arange(1000000)
95
95
  enc = _encode_worker(data)
@@ -162,7 +162,7 @@ def test_expected_result():
162
162
 
163
163
 
164
164
  def test_incompatible_elementsize():
165
+ arr = np.arange(1001, dtype='u1')
166
+ codec = Shuffle(elementsize=4)
165
167
  with pytest.raises(ValueError):
166
- arr = np.arange(1001, dtype='u1')
167
- codec = Shuffle(elementsize=4)
168
168
  codec.encode(arr)
@@ -0,0 +1,246 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ import numpy as np
6
+ import pytest
7
+
8
+ if TYPE_CHECKING: # pragma: no cover
9
+ import zarr
10
+ else:
11
+ zarr = pytest.importorskip("zarr")
12
+
13
+ import zarr.storage
14
+ from zarr.core.common import JSON
15
+
16
+ import numcodecs.zarr3
17
+
18
+ pytestmark = [
19
+ pytest.mark.skipif(zarr.__version__ < "3.0.0", reason="zarr 3.0.0 or later is required"),
20
+ pytest.mark.filterwarnings("ignore:Codec 'numcodecs.*' not configured in config.*:UserWarning"),
21
+ pytest.mark.filterwarnings(
22
+ "ignore:Numcodecs codecs are not in the Zarr version 3 specification and may not be supported by other zarr implementations."
23
+ ),
24
+ ]
25
+
26
+ get_codec_class = zarr.registry.get_codec_class
27
+ Array = zarr.Array
28
+ BytesCodec = zarr.codecs.BytesCodec
29
+ Store = zarr.abc.store.Store
30
+ MemoryStore = zarr.storage.MemoryStore
31
+ StorePath = zarr.storage.StorePath
32
+
33
+
34
+ EXPECTED_WARNING_STR = "Numcodecs codecs are not in the Zarr version 3.*"
35
+
36
+
37
+ @pytest.fixture
38
+ def store() -> StorePath:
39
+ return StorePath(MemoryStore(read_only=False))
40
+
41
+
42
+ ALL_CODECS = [getattr(numcodecs.zarr3, cls_name) for cls_name in numcodecs.zarr3.__all__]
43
+
44
+
45
+ @pytest.mark.parametrize("codec_class", ALL_CODECS)
46
+ def test_entry_points(codec_class: type[numcodecs.zarr3._NumcodecsCodec]):
47
+ codec_name = codec_class.codec_name
48
+ assert get_codec_class(codec_name) == codec_class
49
+
50
+
51
+ @pytest.mark.parametrize("codec_class", ALL_CODECS)
52
+ def test_docstring(codec_class: type[numcodecs.zarr3._NumcodecsCodec]):
53
+ assert "See :class:`numcodecs." in codec_class.__doc__ # type: ignore[operator]
54
+
55
+
56
+ @pytest.mark.parametrize(
57
+ "codec_class",
58
+ [
59
+ numcodecs.zarr3.Blosc,
60
+ numcodecs.zarr3.LZ4,
61
+ numcodecs.zarr3.Zstd,
62
+ numcodecs.zarr3.Zlib,
63
+ numcodecs.zarr3.GZip,
64
+ numcodecs.zarr3.BZ2,
65
+ numcodecs.zarr3.LZMA,
66
+ numcodecs.zarr3.Shuffle,
67
+ ],
68
+ )
69
+ def test_generic_codec_class(store: StorePath, codec_class: type[numcodecs.zarr3._NumcodecsCodec]):
70
+ data = np.arange(0, 256, dtype="uint16").reshape((16, 16))
71
+
72
+ with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
73
+ a = Array.create(
74
+ store / "generic",
75
+ shape=data.shape,
76
+ chunk_shape=(16, 16),
77
+ dtype=data.dtype,
78
+ fill_value=0,
79
+ codecs=[BytesCodec(), codec_class()],
80
+ )
81
+
82
+ a[:, :] = data.copy()
83
+ np.testing.assert_array_equal(data, a[:, :])
84
+
85
+
86
+ @pytest.mark.parametrize(
87
+ ("codec_class", "codec_config"),
88
+ [
89
+ (numcodecs.zarr3.Delta, {"dtype": "float32"}),
90
+ (numcodecs.zarr3.FixedScaleOffset, {"offset": 0, "scale": 25.5}),
91
+ (numcodecs.zarr3.FixedScaleOffset, {"offset": 0, "scale": 51, "astype": "uint16"}),
92
+ (numcodecs.zarr3.AsType, {"encode_dtype": "float32", "decode_dtype": "float64"}),
93
+ ],
94
+ ids=[
95
+ "delta",
96
+ "fixedscaleoffset",
97
+ "fixedscaleoffset2",
98
+ "astype",
99
+ ],
100
+ )
101
+ def test_generic_filter(
102
+ store: StorePath,
103
+ codec_class: type[numcodecs.zarr3._NumcodecsCodec],
104
+ codec_config: dict[str, JSON],
105
+ ):
106
+ data = np.linspace(0, 10, 256, dtype="float32").reshape((16, 16))
107
+
108
+ with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
109
+ a = Array.create(
110
+ store / "generic",
111
+ shape=data.shape,
112
+ chunk_shape=(16, 16),
113
+ dtype=data.dtype,
114
+ fill_value=0,
115
+ codecs=[
116
+ codec_class(**codec_config),
117
+ BytesCodec(),
118
+ ],
119
+ )
120
+
121
+ a[:, :] = data.copy()
122
+ a = Array.open(store / "generic")
123
+ np.testing.assert_array_equal(data, a[:, :])
124
+
125
+
126
+ def test_generic_filter_bitround(store: StorePath):
127
+ data = np.linspace(0, 1, 256, dtype="float32").reshape((16, 16))
128
+
129
+ with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
130
+ a = Array.create(
131
+ store / "generic_bitround",
132
+ shape=data.shape,
133
+ chunk_shape=(16, 16),
134
+ dtype=data.dtype,
135
+ fill_value=0,
136
+ codecs=[numcodecs.zarr3.BitRound(keepbits=3), BytesCodec()],
137
+ )
138
+
139
+ a[:, :] = data.copy()
140
+ a = Array.open(store / "generic_bitround")
141
+ assert np.allclose(data, a[:, :], atol=0.1)
142
+
143
+
144
+ def test_generic_filter_quantize(store: StorePath):
145
+ data = np.linspace(0, 10, 256, dtype="float32").reshape((16, 16))
146
+
147
+ with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
148
+ a = Array.create(
149
+ store / "generic_quantize",
150
+ shape=data.shape,
151
+ chunk_shape=(16, 16),
152
+ dtype=data.dtype,
153
+ fill_value=0,
154
+ codecs=[numcodecs.zarr3.Quantize(digits=3), BytesCodec()],
155
+ )
156
+
157
+ a[:, :] = data.copy()
158
+ a = Array.open(store / "generic_quantize")
159
+ assert np.allclose(data, a[:, :], atol=0.001)
160
+
161
+
162
+ def test_generic_filter_packbits(store: StorePath):
163
+ data = np.zeros((16, 16), dtype="bool")
164
+ data[0:4, :] = True
165
+
166
+ with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
167
+ a = Array.create(
168
+ store / "generic_packbits",
169
+ shape=data.shape,
170
+ chunk_shape=(16, 16),
171
+ dtype=data.dtype,
172
+ fill_value=0,
173
+ codecs=[numcodecs.zarr3.PackBits(), BytesCodec()],
174
+ )
175
+
176
+ a[:, :] = data.copy()
177
+ a = Array.open(store / "generic_packbits")
178
+ np.testing.assert_array_equal(data, a[:, :])
179
+
180
+ with pytest.raises(ValueError, match=".*requires bool dtype.*"):
181
+ Array.create(
182
+ store / "generic_packbits_err",
183
+ shape=data.shape,
184
+ chunk_shape=(16, 16),
185
+ dtype="uint32",
186
+ fill_value=0,
187
+ codecs=[numcodecs.zarr3.PackBits(), BytesCodec()],
188
+ )
189
+
190
+
191
+ @pytest.mark.parametrize(
192
+ "codec_class",
193
+ [
194
+ numcodecs.zarr3.CRC32,
195
+ numcodecs.zarr3.CRC32C,
196
+ numcodecs.zarr3.Adler32,
197
+ numcodecs.zarr3.Fletcher32,
198
+ numcodecs.zarr3.JenkinsLookup3,
199
+ ],
200
+ )
201
+ def test_generic_checksum(store: StorePath, codec_class: type[numcodecs.zarr3._NumcodecsCodec]):
202
+ data = np.linspace(0, 10, 256, dtype="float32").reshape((16, 16))
203
+
204
+ with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
205
+ a = Array.create(
206
+ store / "generic_checksum",
207
+ shape=data.shape,
208
+ chunk_shape=(16, 16),
209
+ dtype=data.dtype,
210
+ fill_value=0,
211
+ codecs=[BytesCodec(), codec_class()],
212
+ )
213
+
214
+ a[:, :] = data.copy()
215
+ a = Array.open(store / "generic_checksum")
216
+ np.testing.assert_array_equal(data, a[:, :])
217
+
218
+
219
+ @pytest.mark.parametrize("codec_class", [numcodecs.zarr3.PCodec, numcodecs.zarr3.ZFPY])
220
+ def test_generic_bytes_codec(store: StorePath, codec_class: type[numcodecs.zarr3._NumcodecsCodec]):
221
+ try:
222
+ codec_class()._codec # noqa: B018
223
+ except ValueError as e:
224
+ if "codec not available" in str(e):
225
+ pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
226
+ else:
227
+ raise # pragma: no cover
228
+ except ImportError as e:
229
+ pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
230
+
231
+ data = np.arange(0, 256, dtype="float32").reshape((16, 16))
232
+
233
+ with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
234
+ a = Array.create(
235
+ store / "generic",
236
+ shape=data.shape,
237
+ chunk_shape=(16, 16),
238
+ dtype=data.dtype,
239
+ fill_value=0,
240
+ codecs=[
241
+ codec_class(),
242
+ ],
243
+ )
244
+
245
+ a[:, :] = data.copy()
246
+ np.testing.assert_array_equal(data, a[:, :])
@@ -0,0 +1,13 @@
1
+ from __future__ import annotations
2
+
3
+ import pytest
4
+
5
+
6
+ def test_zarr3_import():
7
+ ERROR_MESSAGE_MATCH = "zarr 3.0.0 or later.*"
8
+
9
+ try:
10
+ import zarr # noqa: F401
11
+ except ImportError: # pragma: no cover
12
+ with pytest.raises(ImportError, match=ERROR_MESSAGE_MATCH):
13
+ import numcodecs.zarr3 # noqa: F401
@@ -1,3 +1,6 @@
1
+ from types import ModuleType
2
+ from typing import cast
3
+
1
4
  import numpy as np
2
5
  import pytest
3
6
 
@@ -17,6 +20,9 @@ from numcodecs.tests.common import (
17
20
  check_repr,
18
21
  )
19
22
 
23
+ _zfpy = cast(ModuleType, _zfpy)
24
+
25
+
20
26
  codecs = [
21
27
  ZFPY(mode=_zfpy.mode_fixed_rate, rate=-1),
22
28
  ZFPY(),
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.1'
16
- __version_tuple__ = version_tuple = (0, 13, 1)
15
+ __version__ = version = '0.14.1'
16
+ __version_tuple__ = version_tuple = (0, 14, 1)
Binary file