numcodecs 0.12.1__cp311-cp311-win_amd64.whl → 0.13.1__cp311-cp311-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 +33 -7
- numcodecs/_shuffle.cp311-win_amd64.pyd +0 -0
- numcodecs/abc.py +4 -6
- numcodecs/astype.py +2 -10
- numcodecs/bitround.py +0 -1
- numcodecs/blosc.cp311-win_amd64.pyd +0 -0
- numcodecs/bz2.py +1 -4
- numcodecs/categorize.py +12 -18
- numcodecs/checksum32.py +3 -8
- numcodecs/compat.py +6 -12
- numcodecs/compat_ext.cp311-win_amd64.pyd +0 -0
- numcodecs/delta.py +4 -11
- numcodecs/fixedscaleoffset.py +5 -9
- numcodecs/fletcher32.cp311-win_amd64.pyd +0 -0
- numcodecs/gzip.py +1 -5
- numcodecs/jenkins.cp311-win_amd64.pyd +0 -0
- numcodecs/json.py +35 -18
- numcodecs/lz4.cp311-win_amd64.pyd +0 -0
- numcodecs/lzma.py +9 -10
- numcodecs/msgpacks.py +13 -12
- numcodecs/ndarray_like.py +11 -16
- numcodecs/packbits.py +1 -4
- numcodecs/pcodec.py +89 -0
- numcodecs/pickles.py +2 -3
- numcodecs/quantize.py +7 -11
- numcodecs/registry.py +4 -8
- numcodecs/shuffle.py +5 -7
- numcodecs/tests/common.py +42 -32
- numcodecs/tests/package_with_entrypoint/__init__.py +0 -1
- numcodecs/tests/test_astype.py +7 -7
- numcodecs/tests/test_base64.py +10 -13
- numcodecs/tests/test_bitround.py +0 -1
- numcodecs/tests/test_blosc.py +22 -22
- numcodecs/tests/test_bz2.py +12 -11
- numcodecs/tests/test_categorize.py +10 -14
- numcodecs/tests/test_checksum32.py +8 -7
- numcodecs/tests/test_compat.py +8 -13
- numcodecs/tests/test_delta.py +7 -5
- numcodecs/tests/test_entrypoints.py +0 -1
- numcodecs/tests/test_entrypoints_backport.py +8 -5
- numcodecs/tests/test_fixedscaleoffset.py +7 -6
- numcodecs/tests/test_fletcher32.py +13 -6
- numcodecs/tests/test_gzip.py +12 -11
- numcodecs/tests/test_jenkins.py +41 -42
- numcodecs/tests/test_json.py +17 -7
- numcodecs/tests/test_lz4.py +14 -15
- numcodecs/tests/test_lzma.py +15 -14
- numcodecs/tests/test_msgpacks.py +10 -8
- numcodecs/tests/test_packbits.py +6 -4
- numcodecs/tests/test_pcodec.py +80 -0
- numcodecs/tests/test_pickles.py +11 -8
- numcodecs/tests/test_quantize.py +7 -6
- numcodecs/tests/test_registry.py +4 -4
- numcodecs/tests/test_shuffle.py +34 -26
- numcodecs/tests/test_vlen_array.py +14 -16
- numcodecs/tests/test_vlen_bytes.py +13 -8
- numcodecs/tests/test_vlen_utf8.py +14 -9
- numcodecs/tests/test_zfpy.py +7 -17
- numcodecs/tests/test_zlib.py +12 -11
- numcodecs/tests/test_zstd.py +32 -16
- numcodecs/version.py +2 -2
- numcodecs/vlen.cp311-win_amd64.pyd +0 -0
- numcodecs/zfpy.py +35 -20
- numcodecs/zlib.py +1 -4
- numcodecs/zstd.cp311-win_amd64.pyd +0 -0
- {numcodecs-0.12.1.dist-info → numcodecs-0.13.1.dist-info}/METADATA +8 -5
- numcodecs-0.13.1.dist-info/RECORD +74 -0
- {numcodecs-0.12.1.dist-info → numcodecs-0.13.1.dist-info}/WHEEL +1 -1
- numcodecs-0.12.1.dist-info/RECORD +0 -72
- {numcodecs-0.12.1.dist-info → numcodecs-0.13.1.dist-info}/LICENSE.txt +0 -0
- {numcodecs-0.12.1.dist-info → numcodecs-0.13.1.dist-info}/top_level.txt +0 -0
numcodecs/tests/test_blosc.py
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
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 import blosc
|
|
11
9
|
from numcodecs.blosc import Blosc
|
|
12
10
|
except ImportError: # pragma: no cover
|
|
13
|
-
pytest.skip(
|
|
14
|
-
"numcodecs.blosc not available", allow_module_level=True
|
|
15
|
-
)
|
|
16
|
-
|
|
11
|
+
pytest.skip("numcodecs.blosc not available", allow_module_level=True)
|
|
17
12
|
|
|
18
|
-
from numcodecs.tests.common import (check_encode_decode,
|
|
19
|
-
check_encode_decode_partial,
|
|
20
|
-
check_config,
|
|
21
|
-
check_backwards_compatibility,
|
|
22
|
-
check_err_decode_object_buffer,
|
|
23
|
-
check_err_encode_object_buffer,
|
|
24
|
-
check_max_buffer_size)
|
|
25
13
|
|
|
14
|
+
from numcodecs.tests.common import (
|
|
15
|
+
check_backwards_compatibility,
|
|
16
|
+
check_config,
|
|
17
|
+
check_encode_decode,
|
|
18
|
+
check_encode_decode_partial,
|
|
19
|
+
check_err_decode_object_buffer,
|
|
20
|
+
check_err_encode_object_buffer,
|
|
21
|
+
check_max_buffer_size,
|
|
22
|
+
)
|
|
26
23
|
|
|
27
24
|
codecs = [
|
|
28
25
|
Blosc(shuffle=Blosc.SHUFFLE),
|
|
@@ -54,10 +51,10 @@ arrays = [
|
|
|
54
51
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
55
52
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
56
53
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
|
|
57
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
58
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
59
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
60
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
54
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
55
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
56
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
57
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
61
58
|
]
|
|
62
59
|
|
|
63
60
|
|
|
@@ -79,9 +76,13 @@ def test_encode_decode(array, codec):
|
|
|
79
76
|
|
|
80
77
|
|
|
81
78
|
@pytest.mark.parametrize('codec', codecs)
|
|
82
|
-
@pytest.mark.parametrize(
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
@pytest.mark.parametrize(
|
|
80
|
+
'array',
|
|
81
|
+
[
|
|
82
|
+
pytest.param(x) if len(x.shape) == 1 else pytest.param(x, marks=[pytest.mark.xfail])
|
|
83
|
+
for x in arrays
|
|
84
|
+
],
|
|
85
|
+
)
|
|
85
86
|
def test_partial_decode(codec, array):
|
|
86
87
|
_skip_null(codec)
|
|
87
88
|
check_encode_decode_partial(array, codec)
|
|
@@ -105,8 +106,7 @@ def test_repr():
|
|
|
105
106
|
actual = repr(Blosc(cname='zlib', clevel=9, shuffle=Blosc.BITSHUFFLE, blocksize=512))
|
|
106
107
|
assert expect == actual
|
|
107
108
|
expect = "Blosc(cname='blosclz', clevel=5, shuffle=AUTOSHUFFLE, blocksize=1024)"
|
|
108
|
-
actual = repr(Blosc(cname='blosclz', clevel=5, shuffle=Blosc.AUTOSHUFFLE,
|
|
109
|
-
blocksize=1024))
|
|
109
|
+
actual = repr(Blosc(cname='blosclz', clevel=5, shuffle=Blosc.AUTOSHUFFLE, blocksize=1024))
|
|
110
110
|
assert expect == actual
|
|
111
111
|
|
|
112
112
|
|
numcodecs/tests/test_bz2.py
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import numpy as np
|
|
5
4
|
|
|
6
|
-
|
|
7
5
|
from numcodecs.bz2 import BZ2
|
|
8
|
-
from numcodecs.tests.common import (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
from numcodecs.tests.common import (
|
|
7
|
+
check_backwards_compatibility,
|
|
8
|
+
check_config,
|
|
9
|
+
check_encode_decode,
|
|
10
|
+
check_err_decode_object_buffer,
|
|
11
|
+
check_err_encode_object_buffer,
|
|
12
|
+
check_repr,
|
|
13
|
+
)
|
|
13
14
|
|
|
14
15
|
codecs = [
|
|
15
16
|
BZ2(),
|
|
@@ -32,10 +33,10 @@ arrays = [
|
|
|
32
33
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
33
34
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
34
35
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
|
|
35
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
36
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
37
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
38
|
-
np.random.randint(-2**63, -2**63 + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
36
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
37
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[ns]'),
|
|
38
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[m]'),
|
|
39
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
39
40
|
]
|
|
40
41
|
|
|
41
42
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
-
from numpy.testing import assert_array_equal
|
|
3
2
|
import pytest
|
|
4
|
-
|
|
3
|
+
from numpy.testing import assert_array_equal
|
|
5
4
|
|
|
6
5
|
from numcodecs.categorize import Categorize
|
|
7
|
-
from numcodecs.tests.common import (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
from numcodecs.tests.common import (
|
|
7
|
+
check_backwards_compatibility,
|
|
8
|
+
check_config,
|
|
9
|
+
check_encode_decode,
|
|
10
|
+
check_encode_decode_array,
|
|
11
|
+
)
|
|
11
12
|
|
|
12
13
|
labels = ['ƒöõ', 'ßàř', 'ßāẑ', 'ƪùüx']
|
|
13
14
|
arrays = [
|
|
@@ -20,7 +21,6 @@ arrays_object = [a.astype(object) for a in arrays]
|
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
def test_encode_decode():
|
|
23
|
-
|
|
24
24
|
# unicode dtype
|
|
25
25
|
for arr in arrays:
|
|
26
26
|
codec = Categorize(labels, dtype=arr.dtype)
|
|
@@ -34,7 +34,6 @@ def test_encode_decode():
|
|
|
34
34
|
|
|
35
35
|
def test_encode():
|
|
36
36
|
for dtype in 'U', object:
|
|
37
|
-
|
|
38
37
|
arr = np.array(['ƒöõ', 'ßàř', 'ƒöõ', 'ßāẑ', 'ƪùüx'], dtype=dtype)
|
|
39
38
|
# miss off quux
|
|
40
39
|
codec = Categorize(labels=labels[:-1], dtype=arr.dtype, astype='u1')
|
|
@@ -61,8 +60,7 @@ def test_config():
|
|
|
61
60
|
def test_repr():
|
|
62
61
|
dtype = '<U3'
|
|
63
62
|
astype = '|u1'
|
|
64
|
-
codec = Categorize(labels=['foo', 'bar', 'baz', 'qux'],
|
|
65
|
-
dtype=dtype, astype=astype)
|
|
63
|
+
codec = Categorize(labels=['foo', 'bar', 'baz', 'qux'], dtype=dtype, astype=astype)
|
|
66
64
|
expect = "Categorize(dtype='<U3', astype='|u1', labels=['foo', 'bar', 'baz', ...])"
|
|
67
65
|
actual = repr(codec)
|
|
68
66
|
assert expect == actual
|
|
@@ -77,11 +75,9 @@ def test_repr():
|
|
|
77
75
|
|
|
78
76
|
def test_backwards_compatibility():
|
|
79
77
|
codec = Categorize(labels=labels, dtype='<U4', astype='u1')
|
|
80
|
-
check_backwards_compatibility(Categorize.codec_id, arrays, [codec],
|
|
81
|
-
prefix='U')
|
|
78
|
+
check_backwards_compatibility(Categorize.codec_id, arrays, [codec], prefix='U')
|
|
82
79
|
codec = Categorize(labels=labels, dtype=object, astype='u1')
|
|
83
|
-
check_backwards_compatibility(Categorize.codec_id, arrays_object,
|
|
84
|
-
[codec], prefix='O')
|
|
80
|
+
check_backwards_compatibility(Categorize.codec_id, arrays_object, [codec], prefix='O')
|
|
85
81
|
|
|
86
82
|
|
|
87
83
|
def test_errors():
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import numpy as np
|
|
5
4
|
import pytest
|
|
6
5
|
|
|
7
|
-
|
|
8
6
|
from numcodecs.checksum32 import CRC32, Adler32
|
|
9
|
-
from numcodecs.tests.common import (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
from numcodecs.tests.common import (
|
|
8
|
+
check_backwards_compatibility,
|
|
9
|
+
check_config,
|
|
10
|
+
check_encode_decode,
|
|
11
|
+
check_err_encode_object_buffer,
|
|
12
|
+
check_repr,
|
|
13
|
+
)
|
|
13
14
|
|
|
14
15
|
# mix of dtypes: integer, float, bool, string
|
|
15
16
|
# mix of shapes: 1D, 2D, 3D
|
|
@@ -19,7 +20,7 @@ arrays = [
|
|
|
19
20
|
np.linspace(1000, 1001, 1000, dtype='f8'),
|
|
20
21
|
np.random.normal(loc=1000, scale=1, size=(100, 10)),
|
|
21
22
|
np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'),
|
|
22
|
-
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10)
|
|
23
|
+
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10),
|
|
23
24
|
]
|
|
24
25
|
|
|
25
26
|
codecs = [CRC32(), Adler32()]
|
numcodecs/tests/test_compat.py
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import array
|
|
2
2
|
import mmap
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
import numpy as np
|
|
6
5
|
import pytest
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
from numcodecs.compat import ensure_text, ensure_bytes, ensure_contiguous_ndarray
|
|
7
|
+
from numcodecs.compat import ensure_bytes, ensure_contiguous_ndarray, ensure_text
|
|
10
8
|
|
|
11
9
|
|
|
12
10
|
def test_ensure_text():
|
|
@@ -14,7 +12,7 @@ def test_ensure_text():
|
|
|
14
12
|
b'adsdasdas',
|
|
15
13
|
'adsdasdas',
|
|
16
14
|
np.asarray(memoryview(b'adsdasdas')),
|
|
17
|
-
array.array('B', b'qwertyuiqwertyui')
|
|
15
|
+
array.array('B', b'qwertyuiqwertyui'),
|
|
18
16
|
]
|
|
19
17
|
for buf in bufs:
|
|
20
18
|
b = ensure_text(buf)
|
|
@@ -26,7 +24,7 @@ def test_ensure_bytes():
|
|
|
26
24
|
b'adsdasdas',
|
|
27
25
|
bytes(20),
|
|
28
26
|
np.arange(100),
|
|
29
|
-
array.array('l', b'qwertyuiqwertyui')
|
|
27
|
+
array.array('l', b'qwertyuiqwertyui'),
|
|
30
28
|
]
|
|
31
29
|
for buf in bufs:
|
|
32
30
|
b = ensure_bytes(buf)
|
|
@@ -45,7 +43,7 @@ def test_ensure_contiguous_ndarray_shares_memory():
|
|
|
45
43
|
('f', 8, array.array('d', b'qwertyuiqwertyui')),
|
|
46
44
|
('i', 1, array.array('b', b'qwertyuiqwertyui')),
|
|
47
45
|
('u', 1, array.array('B', b'qwertyuiqwertyui')),
|
|
48
|
-
('u', 1, mmap.mmap(-1, 10))
|
|
46
|
+
('u', 1, mmap.mmap(-1, 10)),
|
|
49
47
|
]
|
|
50
48
|
for expected_kind, expected_itemsize, buf in typed_bufs:
|
|
51
49
|
a = ensure_contiguous_ndarray(buf)
|
|
@@ -59,7 +57,6 @@ def test_ensure_contiguous_ndarray_shares_memory():
|
|
|
59
57
|
|
|
60
58
|
|
|
61
59
|
def test_ensure_bytes_invalid_inputs():
|
|
62
|
-
|
|
63
60
|
# object array not allowed
|
|
64
61
|
a = np.array(['Xin chào thế giới'], dtype=object)
|
|
65
62
|
for e in (a, memoryview(a)):
|
|
@@ -68,7 +65,6 @@ def test_ensure_bytes_invalid_inputs():
|
|
|
68
65
|
|
|
69
66
|
|
|
70
67
|
def test_ensure_contiguous_ndarray_invalid_inputs():
|
|
71
|
-
|
|
72
68
|
# object array not allowed
|
|
73
69
|
a = np.array(['Xin chào thế giới'], dtype=object)
|
|
74
70
|
for e in (a, memoryview(a)):
|
|
@@ -98,16 +94,15 @@ def test_ensure_contiguous_ndarray_writeable():
|
|
|
98
94
|
|
|
99
95
|
def test_ensure_contiguous_ndarray_max_buffer_size():
|
|
100
96
|
for max_buffer_size in (4, 64, 1024):
|
|
101
|
-
ensure_contiguous_ndarray(
|
|
102
|
-
|
|
103
|
-
ensure_contiguous_ndarray(
|
|
104
|
-
np.zeros(max_buffer_size, dtype=np.int8), max_buffer_size)
|
|
97
|
+
ensure_contiguous_ndarray(np.zeros(max_buffer_size - 1, dtype=np.int8), max_buffer_size)
|
|
98
|
+
ensure_contiguous_ndarray(np.zeros(max_buffer_size, dtype=np.int8), max_buffer_size)
|
|
105
99
|
buffers = [
|
|
106
100
|
bytes(b"x" * (max_buffer_size + 1)),
|
|
107
101
|
np.zeros(max_buffer_size + 1, dtype=np.int8),
|
|
108
102
|
np.zeros(max_buffer_size + 2, dtype=np.int8),
|
|
109
103
|
np.zeros(max_buffer_size, dtype=np.int16),
|
|
110
|
-
np.zeros(max_buffer_size, dtype=np.int32)
|
|
104
|
+
np.zeros(max_buffer_size, dtype=np.int32),
|
|
105
|
+
]
|
|
111
106
|
for buf in buffers:
|
|
112
107
|
with pytest.raises(ValueError):
|
|
113
108
|
ensure_contiguous_ndarray(buf, max_buffer_size=max_buffer_size)
|
numcodecs/tests/test_delta.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
-
from numpy.testing import assert_array_equal
|
|
3
2
|
import pytest
|
|
4
|
-
|
|
3
|
+
from numpy.testing import assert_array_equal
|
|
5
4
|
|
|
6
5
|
from numcodecs.delta import Delta
|
|
7
|
-
from numcodecs.tests.common import (
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
from numcodecs.tests.common import (
|
|
7
|
+
check_backwards_compatibility,
|
|
8
|
+
check_config,
|
|
9
|
+
check_encode_decode,
|
|
10
|
+
check_repr,
|
|
11
|
+
)
|
|
10
12
|
|
|
11
13
|
# mix of dtypes: integer, float
|
|
12
14
|
# mix of shapes: 1D, 2D, 3D
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import importlib
|
|
1
2
|
import os.path
|
|
2
|
-
import pkgutil
|
|
3
3
|
import sys
|
|
4
|
+
from multiprocessing import Process
|
|
4
5
|
|
|
5
6
|
import pytest
|
|
6
7
|
|
|
7
|
-
from multiprocessing import Process
|
|
8
|
-
|
|
9
8
|
import numcodecs.registry
|
|
10
9
|
|
|
11
|
-
if not
|
|
12
|
-
pytest.skip(
|
|
10
|
+
if not importlib.util.find_spec("importlib_metadata").loader: # pragma: no cover
|
|
11
|
+
pytest.skip(
|
|
12
|
+
"This test module requires importlib_metadata to be installed",
|
|
13
|
+
allow_module_level=True,
|
|
14
|
+
)
|
|
13
15
|
|
|
14
16
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
15
17
|
|
|
@@ -19,6 +21,7 @@ def get_entrypoints_with_importlib_metadata_loaded():
|
|
|
19
21
|
# to the APIs of EntryPoint objects used when registering entrypoints. Attempt to
|
|
20
22
|
# isolate those changes to just this test.
|
|
21
23
|
import importlib_metadata # noqa: F401
|
|
24
|
+
|
|
22
25
|
sys.path.append(here)
|
|
23
26
|
numcodecs.registry.run_entrypoints()
|
|
24
27
|
cls = numcodecs.registry.get_codec({"id": "test"})
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import numpy as np
|
|
5
|
-
from numpy.testing import assert_array_equal
|
|
6
4
|
import pytest
|
|
7
|
-
|
|
5
|
+
from numpy.testing import assert_array_equal
|
|
8
6
|
|
|
9
7
|
from numcodecs.fixedscaleoffset import FixedScaleOffset
|
|
10
|
-
from numcodecs.tests.common import (
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
from numcodecs.tests.common import (
|
|
9
|
+
check_backwards_compatibility,
|
|
10
|
+
check_config,
|
|
11
|
+
check_encode_decode,
|
|
12
|
+
check_repr,
|
|
13
|
+
)
|
|
13
14
|
|
|
14
15
|
arrays = [
|
|
15
16
|
np.linspace(1000, 1001, 1000, dtype='<f8'),
|
|
@@ -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
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import numpy as np
|
|
5
4
|
import pytest
|
|
6
5
|
|
|
7
|
-
|
|
8
6
|
from numcodecs.gzip import GZip
|
|
9
|
-
from numcodecs.tests.common import (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
from numcodecs.tests.common import (
|
|
8
|
+
check_backwards_compatibility,
|
|
9
|
+
check_config,
|
|
10
|
+
check_encode_decode,
|
|
11
|
+
check_err_decode_object_buffer,
|
|
12
|
+
check_err_encode_object_buffer,
|
|
13
|
+
check_repr,
|
|
14
|
+
)
|
|
14
15
|
|
|
15
16
|
codecs = [
|
|
16
17
|
GZip(),
|
|
@@ -35,10 +36,10 @@ arrays = [
|
|
|
35
36
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
36
37
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
37
38
|
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]'),
|
|
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[ns]'),
|
|
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[m]'),
|
|
42
43
|
]
|
|
43
44
|
|
|
44
45
|
|
numcodecs/tests/test_jenkins.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import pytest
|
|
3
3
|
|
|
4
|
-
from numcodecs.jenkins import jenkins_lookup3
|
|
5
4
|
from numcodecs.checksum32 import JenkinsLookup3
|
|
5
|
+
from numcodecs.jenkins import jenkins_lookup3
|
|
6
6
|
|
|
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\
|
|
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"
|
|
117
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_backwards_compatibility,
|
|
9
|
+
check_config,
|
|
10
|
+
check_encode_decode_array,
|
|
11
|
+
check_repr,
|
|
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
|
@@ -1,24 +1,23 @@
|
|
|
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
|
|
11
|
-
pytest.skip(
|
|
12
|
-
"numcodecs.lz4 not available", allow_module_level=True
|
|
13
|
-
)
|
|
14
|
-
|
|
9
|
+
pytest.skip("numcodecs.lz4 not available", allow_module_level=True)
|
|
15
10
|
|
|
16
|
-
from numcodecs.tests.common import (check_encode_decode, check_config, check_repr,
|
|
17
|
-
check_backwards_compatibility,
|
|
18
|
-
check_err_decode_object_buffer,
|
|
19
|
-
check_err_encode_object_buffer,
|
|
20
|
-
check_max_buffer_size)
|
|
21
11
|
|
|
12
|
+
from numcodecs.tests.common import (
|
|
13
|
+
check_backwards_compatibility,
|
|
14
|
+
check_config,
|
|
15
|
+
check_encode_decode,
|
|
16
|
+
check_err_decode_object_buffer,
|
|
17
|
+
check_err_encode_object_buffer,
|
|
18
|
+
check_max_buffer_size,
|
|
19
|
+
check_repr,
|
|
20
|
+
)
|
|
22
21
|
|
|
23
22
|
codecs = [
|
|
24
23
|
LZ4(),
|
|
@@ -44,10 +43,10 @@ arrays = [
|
|
|
44
43
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
45
44
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
46
45
|
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]'),
|
|
46
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('M8[ns]'),
|
|
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[m]'),
|
|
49
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype='i8').view('m8[m]'),
|
|
51
50
|
]
|
|
52
51
|
|
|
53
52
|
|