numcodecs 0.12.1__cp312-cp312-macosx_11_0_arm64.whl → 0.13.0__cp312-cp312-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.
- numcodecs/__init__.py +29 -1
- numcodecs/_shuffle.cpython-312-darwin.so +0 -0
- numcodecs/abc.py +5 -5
- numcodecs/astype.py +2 -8
- numcodecs/blosc.cpython-312-darwin.so +0 -0
- numcodecs/bz2.py +0 -2
- numcodecs/categorize.py +14 -13
- numcodecs/checksum32.py +2 -5
- numcodecs/compat.py +2 -6
- numcodecs/compat_ext.cpython-312-darwin.so +0 -0
- numcodecs/delta.py +2 -8
- numcodecs/fixedscaleoffset.py +8 -6
- numcodecs/fletcher32.cpython-312-darwin.so +0 -0
- numcodecs/gzip.py +1 -5
- numcodecs/jenkins.cpython-312-darwin.so +0 -0
- numcodecs/json.py +28 -10
- numcodecs/lz4.cpython-312-darwin.so +0 -0
- numcodecs/lzma.py +14 -8
- numcodecs/msgpacks.py +13 -9
- numcodecs/ndarray_like.py +7 -12
- numcodecs/packbits.py +1 -3
- numcodecs/pcodec.py +89 -0
- numcodecs/pickles.py +1 -2
- numcodecs/quantize.py +9 -7
- numcodecs/registry.py +2 -6
- numcodecs/shuffle.py +2 -4
- numcodecs/tests/common.py +36 -22
- numcodecs/tests/package_with_entrypoint/__init__.py +0 -1
- numcodecs/tests/test_astype.py +7 -5
- numcodecs/tests/test_base64.py +8 -8
- numcodecs/tests/test_blosc.py +22 -19
- numcodecs/tests/test_bz2.py +12 -8
- numcodecs/tests/test_categorize.py +9 -11
- numcodecs/tests/test_checksum32.py +8 -4
- numcodecs/tests/test_compat.py +7 -10
- numcodecs/tests/test_delta.py +6 -2
- numcodecs/tests/test_entrypoints_backport.py +5 -1
- numcodecs/tests/test_fixedscaleoffset.py +6 -2
- numcodecs/tests/test_fletcher32.py +13 -6
- numcodecs/tests/test_gzip.py +12 -8
- numcodecs/tests/test_jenkins.py +41 -42
- numcodecs/tests/test_json.py +17 -7
- numcodecs/tests/test_lz4.py +14 -12
- numcodecs/tests/test_lzma.py +13 -9
- numcodecs/tests/test_msgpacks.py +8 -3
- numcodecs/tests/test_packbits.py +6 -2
- numcodecs/tests/test_pcodec.py +81 -0
- numcodecs/tests/test_pickles.py +11 -7
- numcodecs/tests/test_quantize.py +6 -2
- numcodecs/tests/test_shuffle.py +34 -23
- numcodecs/tests/test_vlen_array.py +12 -13
- numcodecs/tests/test_vlen_bytes.py +11 -5
- numcodecs/tests/test_vlen_utf8.py +12 -4
- numcodecs/tests/test_zfpy.py +3 -9
- numcodecs/tests/test_zlib.py +12 -8
- numcodecs/tests/test_zstd.py +32 -13
- numcodecs/version.py +2 -2
- numcodecs/vlen.cpython-312-darwin.so +0 -0
- numcodecs/zfpy.py +28 -12
- numcodecs/zlib.py +0 -2
- numcodecs/zstd.cpython-312-darwin.so +0 -0
- {numcodecs-0.12.1.dist-info → numcodecs-0.13.0.dist-info}/METADATA +6 -3
- numcodecs-0.13.0.dist-info/RECORD +74 -0
- {numcodecs-0.12.1.dist-info → numcodecs-0.13.0.dist-info}/WHEEL +1 -1
- numcodecs-0.12.1.dist-info/RECORD +0 -72
- {numcodecs-0.12.1.dist-info → numcodecs-0.13.0.dist-info}/LICENSE.txt +0 -0
- {numcodecs-0.12.1.dist-info → numcodecs-0.13.0.dist-info}/top_level.txt +0 -0
numcodecs/tests/test_delta.py
CHANGED
|
@@ -4,8 +4,12 @@ import pytest
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
from numcodecs.delta import Delta
|
|
7
|
-
from numcodecs.tests.common import (
|
|
8
|
-
|
|
7
|
+
from numcodecs.tests.common import (
|
|
8
|
+
check_encode_decode,
|
|
9
|
+
check_config,
|
|
10
|
+
check_repr,
|
|
11
|
+
check_backwards_compatibility,
|
|
12
|
+
)
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
# mix of dtypes: integer, float
|
|
@@ -9,7 +9,10 @@ from multiprocessing import Process
|
|
|
9
9
|
import numcodecs.registry
|
|
10
10
|
|
|
11
11
|
if not pkgutil.find_loader("importlib_metadata"): # pragma: no cover
|
|
12
|
-
pytest.skip(
|
|
12
|
+
pytest.skip(
|
|
13
|
+
"This test module requires importlib_metadata to be installed",
|
|
14
|
+
allow_module_level=True,
|
|
15
|
+
)
|
|
13
16
|
|
|
14
17
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
15
18
|
|
|
@@ -19,6 +22,7 @@ def get_entrypoints_with_importlib_metadata_loaded():
|
|
|
19
22
|
# to the APIs of EntryPoint objects used when registering entrypoints. Attempt to
|
|
20
23
|
# isolate those changes to just this test.
|
|
21
24
|
import importlib_metadata # noqa: F401
|
|
25
|
+
|
|
22
26
|
sys.path.append(here)
|
|
23
27
|
numcodecs.registry.run_entrypoints()
|
|
24
28
|
cls = numcodecs.registry.get_codec({"id": "test"})
|
|
@@ -7,8 +7,12 @@ import pytest
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
from numcodecs.fixedscaleoffset import FixedScaleOffset
|
|
10
|
-
from numcodecs.tests.common import (
|
|
11
|
-
|
|
10
|
+
from numcodecs.tests.common import (
|
|
11
|
+
check_encode_decode,
|
|
12
|
+
check_config,
|
|
13
|
+
check_repr,
|
|
14
|
+
check_backwards_compatibility,
|
|
15
|
+
)
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
arrays = [
|
|
@@ -4,10 +4,7 @@ import pytest
|
|
|
4
4
|
from numcodecs.fletcher32 import Fletcher32
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
@pytest.mark.parametrize(
|
|
8
|
-
"dtype",
|
|
9
|
-
["uint8", "int32", "float32"]
|
|
10
|
-
)
|
|
7
|
+
@pytest.mark.parametrize("dtype", ["uint8", "int32", "float32"])
|
|
11
8
|
def test_with_data(dtype):
|
|
12
9
|
data = np.arange(100, dtype=dtype)
|
|
13
10
|
f = Fletcher32()
|
|
@@ -33,11 +30,21 @@ def test_known():
|
|
|
33
30
|
b'\x88\t\x00\x00\x00\x00\x00\x00i\x03\x00\x00\x00\x00\x00\x00'
|
|
34
31
|
b'\x93\xfd\xff\xff\xff\xff\xff\xff\xc3\xfc\xff\xff\xff\xff\xff\xff'
|
|
35
32
|
b"'\x02\x00\x00\x00\x00\x00\x00\xba\xf7\xff\xff\xff\xff\xff\xff"
|
|
36
|
-
b'\xfd%\x86d'
|
|
33
|
+
b'\xfd%\x86d'
|
|
34
|
+
)
|
|
37
35
|
data3 = Fletcher32().decode(data)
|
|
38
36
|
outarr = np.frombuffer(data3, dtype="<i8")
|
|
39
37
|
expected = [
|
|
40
|
-
1911,
|
|
38
|
+
1911,
|
|
39
|
+
-2427,
|
|
40
|
+
1897,
|
|
41
|
+
-2412,
|
|
42
|
+
2440,
|
|
43
|
+
873,
|
|
44
|
+
-621,
|
|
45
|
+
-829,
|
|
46
|
+
551,
|
|
47
|
+
-2118,
|
|
41
48
|
]
|
|
42
49
|
assert outarr.tolist() == expected
|
|
43
50
|
|
numcodecs/tests/test_gzip.py
CHANGED
|
@@ -6,10 +6,14 @@ import pytest
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
from numcodecs.gzip import GZip
|
|
9
|
-
from numcodecs.tests.common import (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
from numcodecs.tests.common import (
|
|
10
|
+
check_encode_decode,
|
|
11
|
+
check_config,
|
|
12
|
+
check_repr,
|
|
13
|
+
check_backwards_compatibility,
|
|
14
|
+
check_err_decode_object_buffer,
|
|
15
|
+
check_err_encode_object_buffer,
|
|
16
|
+
)
|
|
13
17
|
|
|
14
18
|
|
|
15
19
|
codecs = [
|
|
@@ -35,10 +39,10 @@ arrays = [
|
|
|
35
39
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
36
40
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
37
41
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
|
|
38
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
39
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
40
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
41
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
42
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
43
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
44
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
45
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
42
46
|
]
|
|
43
47
|
|
|
44
48
|
|
numcodecs/tests/test_jenkins.py
CHANGED
|
@@ -7,13 +7,13 @@ from numcodecs.checksum32 import JenkinsLookup3
|
|
|
7
7
|
|
|
8
8
|
def test_jenkins_lookup3():
|
|
9
9
|
h = jenkins_lookup3(b"", 0)
|
|
10
|
-
assert h ==
|
|
11
|
-
h = jenkins_lookup3(b"",
|
|
12
|
-
assert h ==
|
|
10
|
+
assert h == 0xDEADBEEF
|
|
11
|
+
h = jenkins_lookup3(b"", 0xDEADBEEF)
|
|
12
|
+
assert h == 0xBD5B7DDE
|
|
13
13
|
h = jenkins_lookup3(b"Four score and seven years ago", 0)
|
|
14
14
|
assert h == 0x17770551
|
|
15
15
|
h = jenkins_lookup3(b"Four score and seven years ago", 1)
|
|
16
|
-
assert h ==
|
|
16
|
+
assert h == 0xCD628161
|
|
17
17
|
|
|
18
18
|
# jenkins-cffi example
|
|
19
19
|
h = jenkins_lookup3(b"jenkins", 0)
|
|
@@ -69,7 +69,7 @@ def test_jenkins_lookup3_codec():
|
|
|
69
69
|
assert result[-4:] == b'\x51\x05\x77\x17'
|
|
70
70
|
assert bytes(j.decode(result)) == s
|
|
71
71
|
|
|
72
|
-
j = JenkinsLookup3(initval=
|
|
72
|
+
j = JenkinsLookup3(initval=0xDEADBEEF)
|
|
73
73
|
result = j.encode(s)
|
|
74
74
|
assert bytes(j.decode(result)) == s
|
|
75
75
|
|
|
@@ -82,39 +82,41 @@ def test_jenkins_lookup3_codec():
|
|
|
82
82
|
result = j.encode(s)
|
|
83
83
|
assert bytes(j.decode(result)) == s
|
|
84
84
|
|
|
85
|
-
chunk_index =
|
|
86
|
-
b"\
|
|
87
|
-
b"\xf7\
|
|
88
|
-
b"\xf7\
|
|
89
|
-
b"\
|
|
90
|
-
b"\
|
|
91
|
-
b"\
|
|
92
|
-
b"\
|
|
93
|
-
b"\
|
|
94
|
-
b"\
|
|
95
|
-
b"\
|
|
96
|
-
b"\
|
|
97
|
-
b"\
|
|
98
|
-
b"\
|
|
99
|
-
b"\
|
|
100
|
-
b"\
|
|
101
|
-
b"\
|
|
102
|
-
b"\
|
|
103
|
-
b"\
|
|
104
|
-
b"\
|
|
105
|
-
b"\
|
|
106
|
-
b"\
|
|
107
|
-
b"\
|
|
108
|
-
b"\
|
|
109
|
-
b"\
|
|
110
|
-
b"\
|
|
111
|
-
b"\
|
|
112
|
-
b"\
|
|
113
|
-
b"\
|
|
114
|
-
b"\
|
|
115
|
-
b"
|
|
116
|
-
b"\xf7\
|
|
117
|
-
b"
|
|
85
|
+
chunk_index = (
|
|
86
|
+
b"\x00\x08\x00\x00\x00\x00\x00\x00"
|
|
87
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
88
|
+
+ b"\xf7\x17\x00\x00\x00\x00\x00\x00"
|
|
89
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
90
|
+
+ b"\xee'\x00\x00\x00\x00\x00\x00"
|
|
91
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
92
|
+
+ b"\xe57\x00\x00\x00\x00\x00\x00"
|
|
93
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
94
|
+
+ b"\xdcG\x00\x00\x00\x00\x00\x00"
|
|
95
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
96
|
+
+ b"\xd3W\x00\x00\x00\x00\x00\x00"
|
|
97
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
98
|
+
+ b"\xcag\x00\x00\x00\x00\x00\x00"
|
|
99
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
100
|
+
+ b"\xc1w\x00\x00\x00\x00\x00\x00"
|
|
101
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
102
|
+
+ b"\xb8\x87\x00\x00\x00\x00\x00\x00"
|
|
103
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
104
|
+
+ b"\xaf\x97\x00\x00\x00\x00\x00\x00"
|
|
105
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
106
|
+
+ b"\xa6\xa7\x00\x00\x00\x00\x00\x00"
|
|
107
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
108
|
+
+ b"\x9d\xb7\x00\x00\x00\x00\x00\x00"
|
|
109
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
110
|
+
+ b"\x94\xc7\x00\x00\x00\x00\x00\x00"
|
|
111
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
112
|
+
+ b"\x8b\xd7\x00\x00\x00\x00\x00\x00"
|
|
113
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
114
|
+
+ b"\x82\xe7\x00\x00\x00\x00\x00\x00"
|
|
115
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
116
|
+
+ b"y\xf7\x00\x00\x00\x00\x00\x00"
|
|
117
|
+
+ b"\xf7\x0f\x00\x00\x00\x00\x00\x00"
|
|
118
|
+
+ b"n\x96\x07\x85"
|
|
119
|
+
)
|
|
118
120
|
hdf5_fadb_prefix = b'FADB\x00\x01\xcf\x01\x00\x00\x00\x00\x00\x00'
|
|
119
121
|
j = JenkinsLookup3(prefix=hdf5_fadb_prefix)
|
|
120
122
|
result = j.encode(chunk_index[:-4])
|
|
@@ -122,10 +124,7 @@ def test_jenkins_lookup3_codec():
|
|
|
122
124
|
assert result == chunk_index
|
|
123
125
|
|
|
124
126
|
|
|
125
|
-
@pytest.mark.parametrize(
|
|
126
|
-
"dtype",
|
|
127
|
-
["uint8", "int32", "float32"]
|
|
128
|
-
)
|
|
127
|
+
@pytest.mark.parametrize("dtype", ["uint8", "int32", "float32"])
|
|
129
128
|
def test_with_data(dtype):
|
|
130
129
|
data = np.arange(100, dtype=dtype)
|
|
131
130
|
j = JenkinsLookup3()
|
numcodecs/tests/test_json.py
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import numpy as np
|
|
5
4
|
import pytest
|
|
6
5
|
|
|
7
6
|
from numcodecs.json import JSON
|
|
8
|
-
from numcodecs.tests.common import (
|
|
9
|
-
|
|
7
|
+
from numcodecs.tests.common import (
|
|
8
|
+
check_config,
|
|
9
|
+
check_repr,
|
|
10
|
+
check_encode_decode_array,
|
|
11
|
+
check_backwards_compatibility,
|
|
12
|
+
greetings,
|
|
13
|
+
)
|
|
14
|
+
|
|
10
15
|
codecs = [
|
|
11
16
|
JSON(),
|
|
12
17
|
JSON(indent=True),
|
|
@@ -62,14 +67,19 @@ def test_backwards_compatibility():
|
|
|
62
67
|
([[[0, 0]], [[1, 1]], [[2, 3]]], None),
|
|
63
68
|
(["1"], None),
|
|
64
69
|
(["11", "11"], None),
|
|
65
|
-
(["11", "1", "1"],
|
|
70
|
+
(["11", "1", "1"], None),
|
|
66
71
|
([{}], None),
|
|
67
72
|
([{"key": "value"}, ["list", "of", "strings"]], object),
|
|
68
|
-
|
|
73
|
+
([0], None),
|
|
74
|
+
([{'hi': 0}], "object"),
|
|
75
|
+
(["hi"], "object"),
|
|
76
|
+
(0, None),
|
|
77
|
+
],
|
|
69
78
|
)
|
|
70
79
|
def test_non_numpy_inputs(input_data, dtype):
|
|
71
80
|
# numpy will infer a range of different shapes and dtypes for these inputs.
|
|
72
81
|
# Make sure that round-tripping through encode preserves this.
|
|
82
|
+
data = np.array(input_data, dtype=dtype)
|
|
73
83
|
for codec in codecs:
|
|
74
|
-
output_data = codec.decode(codec.encode(
|
|
75
|
-
assert
|
|
84
|
+
output_data = codec.decode(codec.encode(data))
|
|
85
|
+
assert input_data == output_data.tolist()
|
numcodecs/tests/test_lz4.py
CHANGED
|
@@ -8,16 +8,18 @@ import pytest
|
|
|
8
8
|
try:
|
|
9
9
|
from numcodecs.lz4 import LZ4
|
|
10
10
|
except ImportError: # pragma: no cover
|
|
11
|
-
pytest.skip(
|
|
12
|
-
"numcodecs.lz4 not available", allow_module_level=True
|
|
13
|
-
)
|
|
11
|
+
pytest.skip("numcodecs.lz4 not available", allow_module_level=True)
|
|
14
12
|
|
|
15
13
|
|
|
16
|
-
from numcodecs.tests.common import (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
from numcodecs.tests.common import (
|
|
15
|
+
check_encode_decode,
|
|
16
|
+
check_config,
|
|
17
|
+
check_repr,
|
|
18
|
+
check_backwards_compatibility,
|
|
19
|
+
check_err_decode_object_buffer,
|
|
20
|
+
check_err_encode_object_buffer,
|
|
21
|
+
check_max_buffer_size,
|
|
22
|
+
)
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
codecs = [
|
|
@@ -44,10 +46,10 @@ arrays = [
|
|
|
44
46
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
45
47
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
46
48
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
|
|
47
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
48
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
49
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
50
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
49
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
50
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
51
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
52
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
51
53
|
]
|
|
52
54
|
|
|
53
55
|
|
numcodecs/tests/test_lzma.py
CHANGED
|
@@ -13,10 +13,14 @@ except ImportError: # pragma: no cover
|
|
|
13
13
|
raise unittest.SkipTest("LZMA not available")
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
from numcodecs.tests.common import (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
from numcodecs.tests.common import (
|
|
17
|
+
check_encode_decode,
|
|
18
|
+
check_config,
|
|
19
|
+
check_repr,
|
|
20
|
+
check_backwards_compatibility,
|
|
21
|
+
check_err_decode_object_buffer,
|
|
22
|
+
check_err_encode_object_buffer,
|
|
23
|
+
)
|
|
20
24
|
|
|
21
25
|
|
|
22
26
|
codecs = [
|
|
@@ -24,7 +28,7 @@ codecs = [
|
|
|
24
28
|
LZMA(preset=1),
|
|
25
29
|
LZMA(preset=5),
|
|
26
30
|
LZMA(preset=9),
|
|
27
|
-
LZMA(format=_lzma.FORMAT_RAW, filters=[dict(id=_lzma.FILTER_LZMA2, preset=1)])
|
|
31
|
+
LZMA(format=_lzma.FORMAT_RAW, filters=[dict(id=_lzma.FILTER_LZMA2, preset=1)]),
|
|
28
32
|
]
|
|
29
33
|
|
|
30
34
|
|
|
@@ -41,10 +45,10 @@ arrays = [
|
|
|
41
45
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
42
46
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
43
47
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
|
|
44
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
45
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
46
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
47
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
48
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
49
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
50
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
51
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
48
52
|
]
|
|
49
53
|
|
|
50
54
|
|
numcodecs/tests/test_msgpacks.py
CHANGED
|
@@ -11,8 +11,13 @@ except ImportError: # pragma: no cover
|
|
|
11
11
|
raise unittest.SkipTest("msgpack not available")
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
from numcodecs.tests.common import (
|
|
15
|
-
|
|
14
|
+
from numcodecs.tests.common import (
|
|
15
|
+
check_config,
|
|
16
|
+
check_repr,
|
|
17
|
+
check_encode_decode_array,
|
|
18
|
+
check_backwards_compatibility,
|
|
19
|
+
greetings,
|
|
20
|
+
)
|
|
16
21
|
|
|
17
22
|
|
|
18
23
|
# object array with strings
|
|
@@ -69,7 +74,7 @@ def test_backwards_compatibility():
|
|
|
69
74
|
([b"11", b"11"], None),
|
|
70
75
|
([b"11", b"1", b"1"], None),
|
|
71
76
|
([{b"key": b"value"}, [b"list", b"of", b"strings"]], object),
|
|
72
|
-
]
|
|
77
|
+
],
|
|
73
78
|
)
|
|
74
79
|
def test_non_numpy_inputs(input_data, dtype):
|
|
75
80
|
codec = MsgPack()
|
numcodecs/tests/test_packbits.py
CHANGED
|
@@ -2,8 +2,12 @@ import numpy as np
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
from numcodecs.packbits import PackBits
|
|
5
|
-
from numcodecs.tests.common import (
|
|
6
|
-
|
|
5
|
+
from numcodecs.tests.common import (
|
|
6
|
+
check_encode_decode,
|
|
7
|
+
check_config,
|
|
8
|
+
check_repr,
|
|
9
|
+
check_backwards_compatibility,
|
|
10
|
+
)
|
|
7
11
|
|
|
8
12
|
|
|
9
13
|
arrays = [
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from numcodecs.pcodec import PCodec
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
# initializing codec triggers ImportError
|
|
8
|
+
PCodec()
|
|
9
|
+
except ImportError: # pragma: no cover
|
|
10
|
+
pytest.skip("pcodec not available", allow_module_level=True)
|
|
11
|
+
|
|
12
|
+
from numcodecs.tests.common import (
|
|
13
|
+
check_encode_decode_array_to_bytes,
|
|
14
|
+
check_config,
|
|
15
|
+
check_repr,
|
|
16
|
+
check_backwards_compatibility,
|
|
17
|
+
check_err_decode_object_buffer,
|
|
18
|
+
check_err_encode_object_buffer,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
codecs = [
|
|
23
|
+
PCodec(),
|
|
24
|
+
PCodec(level=1),
|
|
25
|
+
PCodec(level=5),
|
|
26
|
+
PCodec(level=9),
|
|
27
|
+
PCodec(mode_spec='classic'),
|
|
28
|
+
PCodec(equal_pages_up_to=300),
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# mix of dtypes: integer, float
|
|
33
|
+
# mix of shapes: 1D, 2D
|
|
34
|
+
# mix of orders: C, F
|
|
35
|
+
arrays = [
|
|
36
|
+
np.arange(1000, dtype="u4"),
|
|
37
|
+
np.arange(1000, dtype="u8"),
|
|
38
|
+
np.arange(1000, dtype="i4"),
|
|
39
|
+
np.arange(1000, dtype="i8"),
|
|
40
|
+
np.linspace(1000, 1001, 1000, dtype="f4"),
|
|
41
|
+
np.linspace(1000, 1001, 1000, dtype="f8"),
|
|
42
|
+
np.random.normal(loc=1000, scale=1, size=(100, 10)),
|
|
43
|
+
np.asfortranarray(np.random.normal(loc=1000, scale=1, size=(100, 10))),
|
|
44
|
+
np.random.randint(0, 2**60, size=1000, dtype="u8"),
|
|
45
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype="i8"),
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@pytest.mark.parametrize("arr", arrays)
|
|
50
|
+
@pytest.mark.parametrize("codec", codecs)
|
|
51
|
+
def test_encode_decode(arr, codec):
|
|
52
|
+
check_encode_decode_array_to_bytes(arr, codec)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_config():
|
|
56
|
+
codec = PCodec(level=3)
|
|
57
|
+
check_config(codec)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_invalid_config_error():
|
|
61
|
+
with pytest.raises(ValueError):
|
|
62
|
+
codec = PCodec(mode_spec='bogus')
|
|
63
|
+
check_encode_decode_array_to_bytes(arrays[0], codec)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_repr():
|
|
67
|
+
check_repr(
|
|
68
|
+
"PCodec(delta_encoding_order=None, equal_pages_up_to=262144, level=3, mode_spec='auto')"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_backwards_compatibility():
|
|
73
|
+
check_backwards_compatibility(PCodec.codec_id, arrays, codecs)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_err_decode_object_buffer():
|
|
77
|
+
check_err_decode_object_buffer(PCodec())
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_err_encode_object_buffer():
|
|
81
|
+
check_err_encode_object_buffer(PCodec())
|
numcodecs/tests/test_pickles.py
CHANGED
|
@@ -5,8 +5,13 @@ import numpy as np
|
|
|
5
5
|
import pytest
|
|
6
6
|
|
|
7
7
|
from numcodecs.pickles import Pickle
|
|
8
|
-
from numcodecs.tests.common import (
|
|
9
|
-
|
|
8
|
+
from numcodecs.tests.common import (
|
|
9
|
+
check_config,
|
|
10
|
+
check_repr,
|
|
11
|
+
check_encode_decode_array,
|
|
12
|
+
check_backwards_compatibility,
|
|
13
|
+
greetings,
|
|
14
|
+
)
|
|
10
15
|
|
|
11
16
|
|
|
12
17
|
codecs = [Pickle(protocol=i) for i in range(5)]
|
|
@@ -45,14 +50,13 @@ def test_repr():
|
|
|
45
50
|
|
|
46
51
|
# Details on xfail
|
|
47
52
|
# https://stackoverflow.com/questions/58194852/modulenotfounderror-no-module-named-numpy-core-multiarray-r
|
|
48
|
-
@pytest.mark.skipif(
|
|
49
|
-
sys.byteorder != "little", reason="Pickle does not restore byte orders"
|
|
50
|
-
)
|
|
53
|
+
@pytest.mark.skipif(sys.byteorder != "little", reason="Pickle does not restore byte orders")
|
|
51
54
|
@pytest.mark.xfail(
|
|
52
|
-
sys.platform == "win32",
|
|
55
|
+
sys.platform == "win32",
|
|
56
|
+
reason=(
|
|
53
57
|
"Pickle fails to read w/ Windows carriage return "
|
|
54
58
|
"( https://github.com/zarr-developers/numcodecs/issues/271 )"
|
|
55
|
-
)
|
|
59
|
+
),
|
|
56
60
|
)
|
|
57
61
|
def test_backwards_compatibility():
|
|
58
62
|
check_backwards_compatibility(Pickle.codec_id, arrays, codecs)
|
numcodecs/tests/test_quantize.py
CHANGED
|
@@ -7,8 +7,12 @@ import pytest
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
from numcodecs.quantize import Quantize
|
|
10
|
-
from numcodecs.tests.common import
|
|
11
|
-
|
|
10
|
+
from numcodecs.tests.common import (
|
|
11
|
+
check_encode_decode,
|
|
12
|
+
check_config,
|
|
13
|
+
check_repr,
|
|
14
|
+
check_backwards_compatibility,
|
|
15
|
+
)
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
arrays = [
|
numcodecs/tests/test_shuffle.py
CHANGED
|
@@ -9,21 +9,21 @@ import pytest
|
|
|
9
9
|
try:
|
|
10
10
|
from numcodecs.shuffle import Shuffle
|
|
11
11
|
except ImportError: # pragma: no cover
|
|
12
|
-
pytest.skip(
|
|
13
|
-
"numcodecs.shuffle not available", allow_module_level=True
|
|
14
|
-
)
|
|
12
|
+
pytest.skip("numcodecs.shuffle not available", allow_module_level=True)
|
|
15
13
|
|
|
16
14
|
|
|
17
|
-
from numcodecs.tests.common import (
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
from numcodecs.tests.common import (
|
|
16
|
+
check_encode_decode,
|
|
17
|
+
check_config,
|
|
18
|
+
check_backwards_compatibility,
|
|
19
|
+
)
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
codecs = [
|
|
23
23
|
Shuffle(),
|
|
24
24
|
Shuffle(elementsize=0),
|
|
25
25
|
Shuffle(elementsize=4),
|
|
26
|
-
Shuffle(elementsize=8)
|
|
26
|
+
Shuffle(elementsize=8),
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
|
|
@@ -40,10 +40,10 @@ arrays = [
|
|
|
40
40
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
41
41
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
42
42
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
|
|
43
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
44
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
45
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
46
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
43
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
44
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
45
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
46
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
47
47
|
]
|
|
48
48
|
|
|
49
49
|
|
|
@@ -132,22 +132,33 @@ def test_backwards_compatibility():
|
|
|
132
132
|
# with pytest.raises(RuntimeError):
|
|
133
133
|
# codec.decode(bytearray(0))
|
|
134
134
|
|
|
135
|
+
|
|
135
136
|
def test_expected_result():
|
|
136
137
|
# If the input is treated as a 2D byte array, with shape (size of element, number of elements),
|
|
137
138
|
# the shuffle is essentially a transpose. This can be made more apparent by using an array of
|
|
138
139
|
# big-endian integers, as below.
|
|
139
|
-
arr = np.array(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
arr = np.array(
|
|
141
|
+
[
|
|
142
|
+
0x0001020304050607,
|
|
143
|
+
0x08090A0B0C0D0E0F,
|
|
144
|
+
0x1011121314151617,
|
|
145
|
+
0x18191A1B1C1D1E1F,
|
|
146
|
+
],
|
|
147
|
+
dtype='>u8',
|
|
148
|
+
)
|
|
149
|
+
expected = np.array(
|
|
150
|
+
[
|
|
151
|
+
0x00081018,
|
|
152
|
+
0x01091119,
|
|
153
|
+
0x020A121A,
|
|
154
|
+
0x030B131B,
|
|
155
|
+
0x040C141C,
|
|
156
|
+
0x050D151D,
|
|
157
|
+
0x060E161E,
|
|
158
|
+
0x070F171F,
|
|
159
|
+
],
|
|
160
|
+
dtype='u4',
|
|
161
|
+
)
|
|
151
162
|
codec = Shuffle(elementsize=arr.data.itemsize)
|
|
152
163
|
enc = codec.encode(arr)
|
|
153
164
|
np.testing.assert_array_equal(np.frombuffer(enc.data, '>u4'), expected)
|