numcodecs 0.13.0__cp312-cp312-win_amd64.whl → 0.14.0__cp312-cp312-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.
Potentially problematic release.
This version of numcodecs might be problematic. Click here for more details.
- numcodecs/__init__.py +11 -11
- numcodecs/_shuffle.cp312-win_amd64.pyd +0 -0
- numcodecs/abc.py +4 -5
- numcodecs/astype.py +2 -4
- numcodecs/bitround.py +2 -2
- numcodecs/blosc.cp312-win_amd64.pyd +0 -0
- numcodecs/bz2.py +1 -2
- numcodecs/categorize.py +5 -12
- numcodecs/checksum32.py +87 -13
- numcodecs/compat.py +4 -8
- numcodecs/compat_ext.cp312-win_amd64.pyd +0 -0
- numcodecs/delta.py +7 -4
- numcodecs/fixedscaleoffset.py +3 -9
- numcodecs/fletcher32.cp312-win_amd64.pyd +0 -0
- numcodecs/jenkins.cp312-win_amd64.pyd +0 -0
- numcodecs/json.py +7 -8
- numcodecs/lz4.cp312-win_amd64.pyd +0 -0
- numcodecs/lzma.py +7 -11
- numcodecs/msgpacks.py +2 -5
- numcodecs/ndarray_like.py +5 -5
- numcodecs/packbits.py +0 -4
- numcodecs/pcodec.py +2 -2
- numcodecs/pickles.py +1 -1
- numcodecs/quantize.py +4 -10
- numcodecs/registry.py +10 -9
- numcodecs/shuffle.py +4 -4
- numcodecs/tests/common.py +7 -11
- numcodecs/tests/test_astype.py +2 -4
- numcodecs/tests/test_base64.py +2 -5
- numcodecs/tests/test_bitround.py +3 -4
- numcodecs/tests/test_blosc.py +4 -7
- numcodecs/tests/test_bz2.py +3 -6
- numcodecs/tests/test_categorize.py +3 -5
- numcodecs/tests/test_checksum32.py +101 -24
- numcodecs/tests/test_compat.py +4 -3
- numcodecs/tests/test_delta.py +4 -5
- numcodecs/tests/test_entrypoints.py +1 -2
- numcodecs/tests/test_entrypoints_backport.py +4 -4
- numcodecs/tests/test_fixedscaleoffset.py +16 -11
- numcodecs/tests/test_gzip.py +3 -6
- numcodecs/tests/test_jenkins.py +33 -33
- numcodecs/tests/test_json.py +3 -3
- numcodecs/tests/test_lz4.py +3 -6
- numcodecs/tests/test_lzma.py +8 -7
- numcodecs/tests/test_msgpacks.py +8 -8
- numcodecs/tests/test_packbits.py +2 -4
- numcodecs/tests/test_pcodec.py +5 -6
- numcodecs/tests/test_pickles.py +2 -3
- numcodecs/tests/test_quantize.py +3 -6
- numcodecs/tests/test_registry.py +14 -12
- numcodecs/tests/test_shuffle.py +5 -8
- numcodecs/tests/test_vlen_array.py +5 -6
- numcodecs/tests/test_vlen_bytes.py +5 -6
- numcodecs/tests/test_vlen_utf8.py +5 -8
- numcodecs/tests/test_zarr3.py +248 -0
- numcodecs/tests/test_zarr3_import.py +13 -0
- numcodecs/tests/test_zfpy.py +8 -6
- numcodecs/tests/test_zlib.py +4 -7
- numcodecs/tests/test_zstd.py +6 -9
- numcodecs/version.py +2 -2
- numcodecs/vlen.cp312-win_amd64.pyd +0 -0
- numcodecs/zarr3.py +379 -0
- numcodecs/zfpy.py +13 -12
- numcodecs/zlib.py +1 -2
- numcodecs/zstd.cp312-win_amd64.pyd +0 -0
- {numcodecs-0.13.0.dist-info → numcodecs-0.14.0.dist-info}/METADATA +8 -6
- numcodecs-0.14.0.dist-info/RECORD +78 -0
- {numcodecs-0.13.0.dist-info → numcodecs-0.14.0.dist-info}/WHEEL +1 -1
- numcodecs-0.14.0.dist-info/entry_points.txt +22 -0
- numcodecs-0.13.0.dist-info/RECORD +0 -74
- {numcodecs-0.13.0.dist-info → numcodecs-0.14.0.dist-info}/LICENSE.txt +0 -0
- {numcodecs-0.13.0.dist-info → numcodecs-0.14.0.dist-info}/top_level.txt +0 -0
numcodecs/tests/test_lz4.py
CHANGED
|
@@ -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.lz4 import LZ4
|
|
10
8
|
except ImportError: # pragma: no cover
|
|
@@ -12,16 +10,15 @@ 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,
|
|
21
18
|
check_max_buffer_size,
|
|
19
|
+
check_repr,
|
|
22
20
|
)
|
|
23
21
|
|
|
24
|
-
|
|
25
22
|
codecs = [
|
|
26
23
|
LZ4(),
|
|
27
24
|
LZ4(acceleration=-1),
|
numcodecs/tests/test_lzma.py
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
import unittest
|
|
3
|
-
|
|
3
|
+
from types import ModuleType
|
|
4
|
+
from typing import cast
|
|
4
5
|
|
|
5
6
|
import numpy as np
|
|
6
7
|
import pytest
|
|
7
8
|
|
|
8
|
-
|
|
9
9
|
try:
|
|
10
10
|
# noinspection PyProtectedMember
|
|
11
11
|
from numcodecs.lzma import LZMA, _lzma
|
|
12
|
-
except ImportError: # pragma: no cover
|
|
13
|
-
raise unittest.SkipTest("LZMA not available")
|
|
12
|
+
except ImportError as e: # pragma: no cover
|
|
13
|
+
raise unittest.SkipTest("LZMA not available") from e
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
from numcodecs.tests.common import (
|
|
17
|
-
check_encode_decode,
|
|
18
|
-
check_config,
|
|
19
|
-
check_repr,
|
|
20
17
|
check_backwards_compatibility,
|
|
18
|
+
check_config,
|
|
19
|
+
check_encode_decode,
|
|
21
20
|
check_err_decode_object_buffer,
|
|
22
21
|
check_err_encode_object_buffer,
|
|
22
|
+
check_repr,
|
|
23
23
|
)
|
|
24
24
|
|
|
25
|
+
_lzma = cast(ModuleType, _lzma)
|
|
25
26
|
|
|
26
27
|
codecs = [
|
|
27
28
|
LZMA(),
|
numcodecs/tests/test_msgpacks.py
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import numpy as np
|
|
5
4
|
import pytest
|
|
6
5
|
|
|
7
|
-
|
|
8
6
|
try:
|
|
9
7
|
from numcodecs.msgpacks import MsgPack
|
|
10
|
-
except ImportError: # pragma: no cover
|
|
11
|
-
raise unittest.SkipTest("msgpack not available")
|
|
8
|
+
except ImportError as e: # pragma: no cover
|
|
9
|
+
raise unittest.SkipTest("msgpack not available") from e
|
|
12
10
|
|
|
13
11
|
|
|
14
12
|
from numcodecs.tests.common import (
|
|
13
|
+
check_backwards_compatibility,
|
|
15
14
|
check_config,
|
|
16
|
-
check_repr,
|
|
17
15
|
check_encode_decode_array,
|
|
18
|
-
|
|
16
|
+
check_repr,
|
|
19
17
|
greetings,
|
|
20
18
|
)
|
|
21
19
|
|
|
22
|
-
|
|
23
20
|
# object array with strings
|
|
24
21
|
# object array with mix strings / nans
|
|
25
22
|
# object array with mix of string, int, float
|
|
@@ -58,8 +55,11 @@ def test_backwards_compatibility():
|
|
|
58
55
|
check_backwards_compatibility(codec.codec_id, arrays, [codec])
|
|
59
56
|
|
|
60
57
|
|
|
58
|
+
@pytest.mark.filterwarnings(
|
|
59
|
+
"ignore:Creating an ndarray from ragged nested sequences .* is deprecated.*"
|
|
60
|
+
)
|
|
61
61
|
@pytest.mark.parametrize(
|
|
62
|
-
"input_data, dtype",
|
|
62
|
+
("input_data", "dtype"),
|
|
63
63
|
[
|
|
64
64
|
([0, 1], None),
|
|
65
65
|
([[0, 1], [2, 3]], None),
|
numcodecs/tests/test_packbits.py
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
from numcodecs.packbits import PackBits
|
|
5
4
|
from numcodecs.tests.common import (
|
|
6
|
-
|
|
5
|
+
check_backwards_compatibility,
|
|
7
6
|
check_config,
|
|
7
|
+
check_encode_decode,
|
|
8
8
|
check_repr,
|
|
9
|
-
check_backwards_compatibility,
|
|
10
9
|
)
|
|
11
10
|
|
|
12
|
-
|
|
13
11
|
arrays = [
|
|
14
12
|
np.random.randint(0, 2, size=1000, dtype=bool),
|
|
15
13
|
np.random.randint(0, 2, size=(100, 10), dtype=bool),
|
numcodecs/tests/test_pcodec.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import pytest
|
|
2
1
|
import numpy as np
|
|
2
|
+
import pytest
|
|
3
3
|
|
|
4
4
|
from numcodecs.pcodec import PCodec
|
|
5
5
|
|
|
@@ -10,15 +10,14 @@ except ImportError: # pragma: no cover
|
|
|
10
10
|
pytest.skip("pcodec not available", allow_module_level=True)
|
|
11
11
|
|
|
12
12
|
from numcodecs.tests.common import (
|
|
13
|
-
check_encode_decode_array_to_bytes,
|
|
14
|
-
check_config,
|
|
15
|
-
check_repr,
|
|
16
13
|
check_backwards_compatibility,
|
|
14
|
+
check_config,
|
|
15
|
+
check_encode_decode_array_to_bytes,
|
|
17
16
|
check_err_decode_object_buffer,
|
|
18
17
|
check_err_encode_object_buffer,
|
|
18
|
+
check_repr,
|
|
19
19
|
)
|
|
20
20
|
|
|
21
|
-
|
|
22
21
|
codecs = [
|
|
23
22
|
PCodec(),
|
|
24
23
|
PCodec(level=1),
|
|
@@ -58,8 +57,8 @@ def test_config():
|
|
|
58
57
|
|
|
59
58
|
|
|
60
59
|
def test_invalid_config_error():
|
|
60
|
+
codec = PCodec(mode_spec='bogus')
|
|
61
61
|
with pytest.raises(ValueError):
|
|
62
|
-
codec = PCodec(mode_spec='bogus')
|
|
63
62
|
check_encode_decode_array_to_bytes(arrays[0], codec)
|
|
64
63
|
|
|
65
64
|
|
numcodecs/tests/test_pickles.py
CHANGED
|
@@ -6,14 +6,13 @@ import pytest
|
|
|
6
6
|
|
|
7
7
|
from numcodecs.pickles import Pickle
|
|
8
8
|
from numcodecs.tests.common import (
|
|
9
|
+
check_backwards_compatibility,
|
|
9
10
|
check_config,
|
|
10
|
-
check_repr,
|
|
11
11
|
check_encode_decode_array,
|
|
12
|
-
|
|
12
|
+
check_repr,
|
|
13
13
|
greetings,
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
codecs = [Pickle(protocol=i) for i in range(5)]
|
|
18
17
|
|
|
19
18
|
# object array with strings
|
numcodecs/tests/test_quantize.py
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import numpy as np
|
|
5
|
-
from numpy.testing import assert_array_equal, assert_array_almost_equal
|
|
6
4
|
import pytest
|
|
7
|
-
|
|
5
|
+
from numpy.testing import assert_array_almost_equal, assert_array_equal
|
|
8
6
|
|
|
9
7
|
from numcodecs.quantize import Quantize
|
|
10
8
|
from numcodecs.tests.common import (
|
|
11
|
-
|
|
9
|
+
check_backwards_compatibility,
|
|
12
10
|
check_config,
|
|
11
|
+
check_encode_decode,
|
|
13
12
|
check_repr,
|
|
14
|
-
check_backwards_compatibility,
|
|
15
13
|
)
|
|
16
14
|
|
|
17
|
-
|
|
18
15
|
arrays = [
|
|
19
16
|
np.linspace(100, 200, 1000, dtype='<f8'),
|
|
20
17
|
np.random.normal(loc=0, scale=1, size=1000).astype('<f8'),
|
numcodecs/tests/test_registry.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
1
|
import inspect
|
|
4
2
|
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
5
|
import numcodecs
|
|
6
6
|
from numcodecs.registry import get_codec
|
|
7
7
|
|
|
@@ -26,15 +26,17 @@ def test_all_classes_registered():
|
|
|
26
26
|
|
|
27
27
|
see #346 for more info
|
|
28
28
|
"""
|
|
29
|
-
missing = set(
|
|
30
|
-
|
|
31
|
-
for
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
numcodecs/tests/test_shuffle.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
from multiprocessing import Pool
|
|
2
2
|
from multiprocessing.pool import ThreadPool
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
import numpy as np
|
|
6
5
|
import pytest
|
|
7
6
|
|
|
8
|
-
|
|
9
7
|
try:
|
|
10
8
|
from numcodecs.shuffle import Shuffle
|
|
11
9
|
except ImportError: # pragma: no cover
|
|
@@ -13,12 +11,11 @@ except ImportError: # pragma: no cover
|
|
|
13
11
|
|
|
14
12
|
|
|
15
13
|
from numcodecs.tests.common import (
|
|
16
|
-
check_encode_decode,
|
|
17
|
-
check_config,
|
|
18
14
|
check_backwards_compatibility,
|
|
15
|
+
check_config,
|
|
16
|
+
check_encode_decode,
|
|
19
17
|
)
|
|
20
18
|
|
|
21
|
-
|
|
22
19
|
codecs = [
|
|
23
20
|
Shuffle(),
|
|
24
21
|
Shuffle(elementsize=0),
|
|
@@ -92,7 +89,7 @@ def _decode_worker(enc):
|
|
|
92
89
|
return data
|
|
93
90
|
|
|
94
91
|
|
|
95
|
-
@pytest.mark.parametrize('pool',
|
|
92
|
+
@pytest.mark.parametrize('pool', [Pool, ThreadPool])
|
|
96
93
|
def test_multiprocessing(pool):
|
|
97
94
|
data = np.arange(1000000)
|
|
98
95
|
enc = _encode_worker(data)
|
|
@@ -165,7 +162,7 @@ def test_expected_result():
|
|
|
165
162
|
|
|
166
163
|
|
|
167
164
|
def test_incompatible_elementsize():
|
|
165
|
+
arr = np.arange(1001, dtype='u1')
|
|
166
|
+
codec = Shuffle(elementsize=4)
|
|
168
167
|
with pytest.raises(ValueError):
|
|
169
|
-
arr = np.arange(1001, dtype='u1')
|
|
170
|
-
codec = Shuffle(elementsize=4)
|
|
171
168
|
codec.encode(arr)
|
|
@@ -5,17 +5,16 @@ import pytest
|
|
|
5
5
|
|
|
6
6
|
try:
|
|
7
7
|
from numcodecs.vlen import VLenArray
|
|
8
|
-
except ImportError: # pragma: no cover
|
|
9
|
-
raise unittest.SkipTest("vlen-array not available")
|
|
8
|
+
except ImportError as e: # pragma: no cover
|
|
9
|
+
raise unittest.SkipTest("vlen-array not available") from e
|
|
10
10
|
from numcodecs.tests.common import (
|
|
11
|
+
assert_array_items_equal,
|
|
12
|
+
check_backwards_compatibility,
|
|
11
13
|
check_config,
|
|
12
|
-
check_repr,
|
|
13
14
|
check_encode_decode_array,
|
|
14
|
-
|
|
15
|
-
assert_array_items_equal,
|
|
15
|
+
check_repr,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
arrays = [
|
|
20
19
|
np.array([np.array([1, 2, 3]), np.array([4]), np.array([5, 6])] * 300, dtype=object),
|
|
21
20
|
np.array([np.array([1, 2, 3]), np.array([4]), np.array([5, 6])] * 300, dtype=object).reshape(
|
|
@@ -5,18 +5,17 @@ import pytest
|
|
|
5
5
|
|
|
6
6
|
try:
|
|
7
7
|
from numcodecs.vlen import VLenBytes
|
|
8
|
-
except ImportError: # pragma: no cover
|
|
9
|
-
raise unittest.SkipTest("vlen-bytes not available")
|
|
8
|
+
except ImportError as e: # pragma: no cover
|
|
9
|
+
raise unittest.SkipTest("vlen-bytes not available") from e
|
|
10
10
|
from numcodecs.tests.common import (
|
|
11
|
+
assert_array_items_equal,
|
|
12
|
+
check_backwards_compatibility,
|
|
11
13
|
check_config,
|
|
12
|
-
check_repr,
|
|
13
14
|
check_encode_decode_array,
|
|
14
|
-
|
|
15
|
+
check_repr,
|
|
15
16
|
greetings,
|
|
16
|
-
assert_array_items_equal,
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
greetings_bytes = [g.encode('utf-8') for g in greetings]
|
|
21
20
|
|
|
22
21
|
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import numpy as np
|
|
5
4
|
import pytest
|
|
6
5
|
|
|
7
|
-
|
|
8
6
|
try:
|
|
9
7
|
from numcodecs.vlen import VLenUTF8
|
|
10
|
-
except ImportError: # pragma: no cover
|
|
11
|
-
raise unittest.SkipTest("vlen-utf8 not available")
|
|
8
|
+
except ImportError as e: # pragma: no cover
|
|
9
|
+
raise unittest.SkipTest("vlen-utf8 not available") from e
|
|
12
10
|
from numcodecs.tests.common import (
|
|
11
|
+
assert_array_items_equal,
|
|
12
|
+
check_backwards_compatibility,
|
|
13
13
|
check_config,
|
|
14
|
-
check_repr,
|
|
15
14
|
check_encode_decode_array,
|
|
16
|
-
|
|
15
|
+
check_repr,
|
|
17
16
|
greetings,
|
|
18
|
-
assert_array_items_equal,
|
|
19
17
|
)
|
|
20
18
|
|
|
21
|
-
|
|
22
19
|
arrays = [
|
|
23
20
|
np.array(['foo', 'bar', 'baz'] * 300, dtype=object),
|
|
24
21
|
np.array(greetings * 100, dtype=object),
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
if not TYPE_CHECKING:
|
|
9
|
+
zarr = pytest.importorskip("zarr")
|
|
10
|
+
else:
|
|
11
|
+
import 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(mode="w"))
|
|
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
|
+
if codec_class.__doc__ is None:
|
|
54
|
+
pytest.skip()
|
|
55
|
+
assert "See :class:`numcodecs." in codec_class.__doc__
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@pytest.mark.parametrize(
|
|
59
|
+
"codec_class",
|
|
60
|
+
[
|
|
61
|
+
numcodecs.zarr3.Blosc,
|
|
62
|
+
numcodecs.zarr3.LZ4,
|
|
63
|
+
numcodecs.zarr3.Zstd,
|
|
64
|
+
numcodecs.zarr3.Zlib,
|
|
65
|
+
numcodecs.zarr3.GZip,
|
|
66
|
+
numcodecs.zarr3.BZ2,
|
|
67
|
+
numcodecs.zarr3.LZMA,
|
|
68
|
+
numcodecs.zarr3.Shuffle,
|
|
69
|
+
],
|
|
70
|
+
)
|
|
71
|
+
def test_generic_codec_class(store: StorePath, codec_class: type[numcodecs.zarr3._NumcodecsCodec]):
|
|
72
|
+
data = np.arange(0, 256, dtype="uint16").reshape((16, 16))
|
|
73
|
+
|
|
74
|
+
with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
|
|
75
|
+
a = Array.create(
|
|
76
|
+
store / "generic",
|
|
77
|
+
shape=data.shape,
|
|
78
|
+
chunk_shape=(16, 16),
|
|
79
|
+
dtype=data.dtype,
|
|
80
|
+
fill_value=0,
|
|
81
|
+
codecs=[BytesCodec(), codec_class()],
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
a[:, :] = data.copy()
|
|
85
|
+
np.testing.assert_array_equal(data, a[:, :])
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@pytest.mark.parametrize(
|
|
89
|
+
("codec_class", "codec_config"),
|
|
90
|
+
[
|
|
91
|
+
(numcodecs.zarr3.Delta, {"dtype": "float32"}),
|
|
92
|
+
(numcodecs.zarr3.FixedScaleOffset, {"offset": 0, "scale": 25.5}),
|
|
93
|
+
(numcodecs.zarr3.FixedScaleOffset, {"offset": 0, "scale": 51, "astype": "uint16"}),
|
|
94
|
+
(numcodecs.zarr3.AsType, {"encode_dtype": "float32", "decode_dtype": "float64"}),
|
|
95
|
+
],
|
|
96
|
+
ids=[
|
|
97
|
+
"delta",
|
|
98
|
+
"fixedscaleoffset",
|
|
99
|
+
"fixedscaleoffset2",
|
|
100
|
+
"astype",
|
|
101
|
+
],
|
|
102
|
+
)
|
|
103
|
+
def test_generic_filter(
|
|
104
|
+
store: StorePath,
|
|
105
|
+
codec_class: type[numcodecs.zarr3._NumcodecsCodec],
|
|
106
|
+
codec_config: dict[str, JSON],
|
|
107
|
+
):
|
|
108
|
+
data = np.linspace(0, 10, 256, dtype="float32").reshape((16, 16))
|
|
109
|
+
|
|
110
|
+
with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
|
|
111
|
+
a = Array.create(
|
|
112
|
+
store / "generic",
|
|
113
|
+
shape=data.shape,
|
|
114
|
+
chunk_shape=(16, 16),
|
|
115
|
+
dtype=data.dtype,
|
|
116
|
+
fill_value=0,
|
|
117
|
+
codecs=[
|
|
118
|
+
codec_class(**codec_config),
|
|
119
|
+
BytesCodec(),
|
|
120
|
+
],
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
a[:, :] = data.copy()
|
|
124
|
+
a = Array.open(store / "generic")
|
|
125
|
+
np.testing.assert_array_equal(data, a[:, :])
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_generic_filter_bitround(store: StorePath):
|
|
129
|
+
data = np.linspace(0, 1, 256, dtype="float32").reshape((16, 16))
|
|
130
|
+
|
|
131
|
+
with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
|
|
132
|
+
a = Array.create(
|
|
133
|
+
store / "generic_bitround",
|
|
134
|
+
shape=data.shape,
|
|
135
|
+
chunk_shape=(16, 16),
|
|
136
|
+
dtype=data.dtype,
|
|
137
|
+
fill_value=0,
|
|
138
|
+
codecs=[numcodecs.zarr3.BitRound(keepbits=3), BytesCodec()],
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
a[:, :] = data.copy()
|
|
142
|
+
a = Array.open(store / "generic_bitround")
|
|
143
|
+
assert np.allclose(data, a[:, :], atol=0.1)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def test_generic_filter_quantize(store: StorePath):
|
|
147
|
+
data = np.linspace(0, 10, 256, dtype="float32").reshape((16, 16))
|
|
148
|
+
|
|
149
|
+
with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
|
|
150
|
+
a = Array.create(
|
|
151
|
+
store / "generic_quantize",
|
|
152
|
+
shape=data.shape,
|
|
153
|
+
chunk_shape=(16, 16),
|
|
154
|
+
dtype=data.dtype,
|
|
155
|
+
fill_value=0,
|
|
156
|
+
codecs=[numcodecs.zarr3.Quantize(digits=3), BytesCodec()],
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
a[:, :] = data.copy()
|
|
160
|
+
a = Array.open(store / "generic_quantize")
|
|
161
|
+
assert np.allclose(data, a[:, :], atol=0.001)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def test_generic_filter_packbits(store: StorePath):
|
|
165
|
+
data = np.zeros((16, 16), dtype="bool")
|
|
166
|
+
data[0:4, :] = True
|
|
167
|
+
|
|
168
|
+
with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
|
|
169
|
+
a = Array.create(
|
|
170
|
+
store / "generic_packbits",
|
|
171
|
+
shape=data.shape,
|
|
172
|
+
chunk_shape=(16, 16),
|
|
173
|
+
dtype=data.dtype,
|
|
174
|
+
fill_value=0,
|
|
175
|
+
codecs=[numcodecs.zarr3.PackBits(), BytesCodec()],
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
a[:, :] = data.copy()
|
|
179
|
+
a = Array.open(store / "generic_packbits")
|
|
180
|
+
np.testing.assert_array_equal(data, a[:, :])
|
|
181
|
+
|
|
182
|
+
with pytest.raises(ValueError, match=".*requires bool dtype.*"):
|
|
183
|
+
Array.create(
|
|
184
|
+
store / "generic_packbits_err",
|
|
185
|
+
shape=data.shape,
|
|
186
|
+
chunk_shape=(16, 16),
|
|
187
|
+
dtype="uint32",
|
|
188
|
+
fill_value=0,
|
|
189
|
+
codecs=[numcodecs.zarr3.PackBits(), BytesCodec()],
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
@pytest.mark.parametrize(
|
|
194
|
+
"codec_class",
|
|
195
|
+
[
|
|
196
|
+
numcodecs.zarr3.CRC32,
|
|
197
|
+
numcodecs.zarr3.CRC32C,
|
|
198
|
+
numcodecs.zarr3.Adler32,
|
|
199
|
+
numcodecs.zarr3.Fletcher32,
|
|
200
|
+
numcodecs.zarr3.JenkinsLookup3,
|
|
201
|
+
],
|
|
202
|
+
)
|
|
203
|
+
def test_generic_checksum(store: StorePath, codec_class: type[numcodecs.zarr3._NumcodecsCodec]):
|
|
204
|
+
data = np.linspace(0, 10, 256, dtype="float32").reshape((16, 16))
|
|
205
|
+
|
|
206
|
+
with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
|
|
207
|
+
a = Array.create(
|
|
208
|
+
store / "generic_checksum",
|
|
209
|
+
shape=data.shape,
|
|
210
|
+
chunk_shape=(16, 16),
|
|
211
|
+
dtype=data.dtype,
|
|
212
|
+
fill_value=0,
|
|
213
|
+
codecs=[BytesCodec(), codec_class()],
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
a[:, :] = data.copy()
|
|
217
|
+
a = Array.open(store / "generic_checksum")
|
|
218
|
+
np.testing.assert_array_equal(data, a[:, :])
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
@pytest.mark.parametrize("codec_class", [numcodecs.zarr3.PCodec, numcodecs.zarr3.ZFPY])
|
|
222
|
+
def test_generic_bytes_codec(store: StorePath, codec_class: type[numcodecs.zarr3._NumcodecsCodec]):
|
|
223
|
+
try:
|
|
224
|
+
codec_class()._codec # noqa: B018
|
|
225
|
+
except ValueError as e:
|
|
226
|
+
if "codec not available" in str(e):
|
|
227
|
+
pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
|
|
228
|
+
else:
|
|
229
|
+
raise # pragma: no cover
|
|
230
|
+
except ImportError as e:
|
|
231
|
+
pytest.xfail(f"{codec_class.codec_name} is not available: {e}")
|
|
232
|
+
|
|
233
|
+
data = np.arange(0, 256, dtype="float32").reshape((16, 16))
|
|
234
|
+
|
|
235
|
+
with pytest.warns(UserWarning, match=EXPECTED_WARNING_STR):
|
|
236
|
+
a = Array.create(
|
|
237
|
+
store / "generic",
|
|
238
|
+
shape=data.shape,
|
|
239
|
+
chunk_shape=(16, 16),
|
|
240
|
+
dtype=data.dtype,
|
|
241
|
+
fill_value=0,
|
|
242
|
+
codecs=[
|
|
243
|
+
codec_class(),
|
|
244
|
+
],
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
a[:, :] = data.copy()
|
|
248
|
+
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
|
numcodecs/tests/test_zfpy.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
from types import ModuleType
|
|
2
|
+
from typing import cast
|
|
3
3
|
|
|
4
4
|
import numpy as np
|
|
5
|
-
|
|
5
|
+
import pytest
|
|
6
6
|
|
|
7
7
|
try:
|
|
8
8
|
# noinspection PyProtectedMember
|
|
@@ -12,14 +12,16 @@ except ImportError: # pragma: no cover
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
from numcodecs.tests.common import (
|
|
15
|
-
check_encode_decode_array,
|
|
16
|
-
check_config,
|
|
17
|
-
check_repr,
|
|
18
15
|
check_backwards_compatibility,
|
|
16
|
+
check_config,
|
|
17
|
+
check_encode_decode_array,
|
|
19
18
|
check_err_decode_object_buffer,
|
|
20
19
|
check_err_encode_object_buffer,
|
|
20
|
+
check_repr,
|
|
21
21
|
)
|
|
22
22
|
|
|
23
|
+
_zfpy = cast(ModuleType, _zfpy)
|
|
24
|
+
|
|
23
25
|
|
|
24
26
|
codecs = [
|
|
25
27
|
ZFPY(mode=_zfpy.mode_fixed_rate, rate=-1),
|
numcodecs/tests/test_zlib.py
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import numpy as np
|
|
5
4
|
import pytest
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
from numcodecs.zlib import Zlib
|
|
9
6
|
from numcodecs.tests.common import (
|
|
10
|
-
check_encode_decode,
|
|
11
|
-
check_config,
|
|
12
|
-
check_repr,
|
|
13
7
|
check_backwards_compatibility,
|
|
8
|
+
check_config,
|
|
9
|
+
check_encode_decode,
|
|
14
10
|
check_err_decode_object_buffer,
|
|
15
11
|
check_err_encode_object_buffer,
|
|
12
|
+
check_repr,
|
|
16
13
|
)
|
|
17
|
-
|
|
14
|
+
from numcodecs.zlib import Zlib
|
|
18
15
|
|
|
19
16
|
codecs = [
|
|
20
17
|
Zlib(),
|