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_lzma.py
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
import unittest
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
import numpy as np
|
|
6
5
|
import pytest
|
|
7
6
|
|
|
8
|
-
|
|
9
7
|
try:
|
|
10
8
|
# noinspection PyProtectedMember
|
|
11
9
|
from numcodecs.lzma import LZMA, _lzma
|
|
12
|
-
except ImportError: # pragma: no cover
|
|
13
|
-
raise unittest.SkipTest("LZMA not available")
|
|
14
|
-
|
|
10
|
+
except ImportError as e: # pragma: no cover
|
|
11
|
+
raise unittest.SkipTest("LZMA not available") from e
|
|
15
12
|
|
|
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
13
|
|
|
14
|
+
from numcodecs.tests.common import (
|
|
15
|
+
check_backwards_compatibility,
|
|
16
|
+
check_config,
|
|
17
|
+
check_encode_decode,
|
|
18
|
+
check_err_decode_object_buffer,
|
|
19
|
+
check_err_encode_object_buffer,
|
|
20
|
+
check_repr,
|
|
21
|
+
)
|
|
21
22
|
|
|
22
23
|
codecs = [
|
|
23
24
|
LZMA(),
|
|
24
25
|
LZMA(preset=1),
|
|
25
26
|
LZMA(preset=5),
|
|
26
27
|
LZMA(preset=9),
|
|
27
|
-
LZMA(format=_lzma.FORMAT_RAW, filters=[dict(id=_lzma.FILTER_LZMA2, preset=1)])
|
|
28
|
+
LZMA(format=_lzma.FORMAT_RAW, filters=[dict(id=_lzma.FILTER_LZMA2, preset=1)]),
|
|
28
29
|
]
|
|
29
30
|
|
|
30
31
|
|
|
@@ -41,10 +42,10 @@ arrays = [
|
|
|
41
42
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
42
43
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
43
44
|
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]'),
|
|
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[ns]'),
|
|
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[m]'),
|
|
48
49
|
]
|
|
49
50
|
|
|
50
51
|
|
numcodecs/tests/test_msgpacks.py
CHANGED
|
@@ -1,19 +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.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
|
-
from numcodecs.tests.common import (
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
from numcodecs.tests.common import (
|
|
13
|
+
check_backwards_compatibility,
|
|
14
|
+
check_config,
|
|
15
|
+
check_encode_decode_array,
|
|
16
|
+
check_repr,
|
|
17
|
+
greetings,
|
|
18
|
+
)
|
|
17
19
|
|
|
18
20
|
# object array with strings
|
|
19
21
|
# object array with mix strings / nans
|
|
@@ -69,7 +71,7 @@ def test_backwards_compatibility():
|
|
|
69
71
|
([b"11", b"11"], None),
|
|
70
72
|
([b"11", b"1", b"1"], None),
|
|
71
73
|
([{b"key": b"value"}, [b"list", b"of", b"strings"]], object),
|
|
72
|
-
]
|
|
74
|
+
],
|
|
73
75
|
)
|
|
74
76
|
def test_non_numpy_inputs(input_data, dtype):
|
|
75
77
|
codec = MsgPack()
|
numcodecs/tests/test_packbits.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
from numcodecs.packbits import PackBits
|
|
5
|
-
from numcodecs.tests.common import (
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
from numcodecs.tests.common import (
|
|
5
|
+
check_backwards_compatibility,
|
|
6
|
+
check_config,
|
|
7
|
+
check_encode_decode,
|
|
8
|
+
check_repr,
|
|
9
|
+
)
|
|
8
10
|
|
|
9
11
|
arrays = [
|
|
10
12
|
np.random.randint(0, 2, size=1000, dtype=bool),
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pytest
|
|
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_backwards_compatibility,
|
|
14
|
+
check_config,
|
|
15
|
+
check_encode_decode_array_to_bytes,
|
|
16
|
+
check_err_decode_object_buffer,
|
|
17
|
+
check_err_encode_object_buffer,
|
|
18
|
+
check_repr,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
codecs = [
|
|
22
|
+
PCodec(),
|
|
23
|
+
PCodec(level=1),
|
|
24
|
+
PCodec(level=5),
|
|
25
|
+
PCodec(level=9),
|
|
26
|
+
PCodec(mode_spec='classic'),
|
|
27
|
+
PCodec(equal_pages_up_to=300),
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# mix of dtypes: integer, float
|
|
32
|
+
# mix of shapes: 1D, 2D
|
|
33
|
+
# mix of orders: C, F
|
|
34
|
+
arrays = [
|
|
35
|
+
np.arange(1000, dtype="u4"),
|
|
36
|
+
np.arange(1000, dtype="u8"),
|
|
37
|
+
np.arange(1000, dtype="i4"),
|
|
38
|
+
np.arange(1000, dtype="i8"),
|
|
39
|
+
np.linspace(1000, 1001, 1000, dtype="f4"),
|
|
40
|
+
np.linspace(1000, 1001, 1000, dtype="f8"),
|
|
41
|
+
np.random.normal(loc=1000, scale=1, size=(100, 10)),
|
|
42
|
+
np.asfortranarray(np.random.normal(loc=1000, scale=1, size=(100, 10))),
|
|
43
|
+
np.random.randint(0, 2**60, size=1000, dtype="u8"),
|
|
44
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype="i8"),
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@pytest.mark.parametrize("arr", arrays)
|
|
49
|
+
@pytest.mark.parametrize("codec", codecs)
|
|
50
|
+
def test_encode_decode(arr, codec):
|
|
51
|
+
check_encode_decode_array_to_bytes(arr, codec)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_config():
|
|
55
|
+
codec = PCodec(level=3)
|
|
56
|
+
check_config(codec)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_invalid_config_error():
|
|
60
|
+
with pytest.raises(ValueError):
|
|
61
|
+
codec = PCodec(mode_spec='bogus')
|
|
62
|
+
check_encode_decode_array_to_bytes(arrays[0], codec)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_repr():
|
|
66
|
+
check_repr(
|
|
67
|
+
"PCodec(delta_encoding_order=None, equal_pages_up_to=262144, level=3, mode_spec='auto')"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_backwards_compatibility():
|
|
72
|
+
check_backwards_compatibility(PCodec.codec_id, arrays, codecs)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_err_decode_object_buffer():
|
|
76
|
+
check_err_decode_object_buffer(PCodec())
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_err_encode_object_buffer():
|
|
80
|
+
check_err_encode_object_buffer(PCodec())
|
numcodecs/tests/test_pickles.py
CHANGED
|
@@ -5,9 +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
|
-
|
|
10
|
-
|
|
8
|
+
from numcodecs.tests.common import (
|
|
9
|
+
check_backwards_compatibility,
|
|
10
|
+
check_config,
|
|
11
|
+
check_encode_decode_array,
|
|
12
|
+
check_repr,
|
|
13
|
+
greetings,
|
|
14
|
+
)
|
|
11
15
|
|
|
12
16
|
codecs = [Pickle(protocol=i) for i in range(5)]
|
|
13
17
|
|
|
@@ -45,14 +49,13 @@ def test_repr():
|
|
|
45
49
|
|
|
46
50
|
# Details on xfail
|
|
47
51
|
# 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
|
-
)
|
|
52
|
+
@pytest.mark.skipif(sys.byteorder != "little", reason="Pickle does not restore byte orders")
|
|
51
53
|
@pytest.mark.xfail(
|
|
52
|
-
sys.platform == "win32",
|
|
54
|
+
sys.platform == "win32",
|
|
55
|
+
reason=(
|
|
53
56
|
"Pickle fails to read w/ Windows carriage return "
|
|
54
57
|
"( https://github.com/zarr-developers/numcodecs/issues/271 )"
|
|
55
|
-
)
|
|
58
|
+
),
|
|
56
59
|
)
|
|
57
60
|
def test_backwards_compatibility():
|
|
58
61
|
check_backwards_compatibility(Pickle.codec_id, arrays, codecs)
|
numcodecs/tests/test_quantize.py
CHANGED
|
@@ -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, 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
|
-
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(100, 200, 1000, dtype='<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
|
|
|
@@ -27,8 +27,8 @@ def test_all_classes_registered():
|
|
|
27
27
|
see #346 for more info
|
|
28
28
|
"""
|
|
29
29
|
missing = set()
|
|
30
|
-
for
|
|
31
|
-
for
|
|
30
|
+
for _name, submod in inspect.getmembers(numcodecs, inspect.ismodule):
|
|
31
|
+
for _name, obj in inspect.getmembers(submod):
|
|
32
32
|
if inspect.isclass(obj):
|
|
33
33
|
if issubclass(obj, numcodecs.abc.Codec):
|
|
34
34
|
if obj.codec_id not in numcodecs.registry.codec_registry:
|
numcodecs/tests/test_shuffle.py
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
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
|
|
12
|
-
pytest.skip(
|
|
13
|
-
"numcodecs.shuffle not available", allow_module_level=True
|
|
14
|
-
)
|
|
15
|
-
|
|
10
|
+
pytest.skip("numcodecs.shuffle not available", allow_module_level=True)
|
|
16
11
|
|
|
17
|
-
from numcodecs.tests.common import (check_encode_decode,
|
|
18
|
-
check_config,
|
|
19
|
-
check_backwards_compatibility)
|
|
20
12
|
|
|
13
|
+
from numcodecs.tests.common import (
|
|
14
|
+
check_backwards_compatibility,
|
|
15
|
+
check_config,
|
|
16
|
+
check_encode_decode,
|
|
17
|
+
)
|
|
21
18
|
|
|
22
19
|
codecs = [
|
|
23
20
|
Shuffle(),
|
|
24
21
|
Shuffle(elementsize=0),
|
|
25
22
|
Shuffle(elementsize=4),
|
|
26
|
-
Shuffle(elementsize=8)
|
|
23
|
+
Shuffle(elementsize=8),
|
|
27
24
|
]
|
|
28
25
|
|
|
29
26
|
|
|
@@ -40,10 +37,10 @@ arrays = [
|
|
|
40
37
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
41
38
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
42
39
|
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]'),
|
|
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[ns]'),
|
|
42
|
+
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[m]'),
|
|
47
44
|
]
|
|
48
45
|
|
|
49
46
|
|
|
@@ -132,22 +129,33 @@ def test_backwards_compatibility():
|
|
|
132
129
|
# with pytest.raises(RuntimeError):
|
|
133
130
|
# codec.decode(bytearray(0))
|
|
134
131
|
|
|
132
|
+
|
|
135
133
|
def test_expected_result():
|
|
136
134
|
# If the input is treated as a 2D byte array, with shape (size of element, number of elements),
|
|
137
135
|
# the shuffle is essentially a transpose. This can be made more apparent by using an array of
|
|
138
136
|
# big-endian integers, as below.
|
|
139
|
-
arr = np.array(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
137
|
+
arr = np.array(
|
|
138
|
+
[
|
|
139
|
+
0x0001020304050607,
|
|
140
|
+
0x08090A0B0C0D0E0F,
|
|
141
|
+
0x1011121314151617,
|
|
142
|
+
0x18191A1B1C1D1E1F,
|
|
143
|
+
],
|
|
144
|
+
dtype='>u8',
|
|
145
|
+
)
|
|
146
|
+
expected = np.array(
|
|
147
|
+
[
|
|
148
|
+
0x00081018,
|
|
149
|
+
0x01091119,
|
|
150
|
+
0x020A121A,
|
|
151
|
+
0x030B131B,
|
|
152
|
+
0x040C141C,
|
|
153
|
+
0x050D151D,
|
|
154
|
+
0x060E161E,
|
|
155
|
+
0x070F171F,
|
|
156
|
+
],
|
|
157
|
+
dtype='u4',
|
|
158
|
+
)
|
|
151
159
|
codec = Shuffle(elementsize=arr.data.itemsize)
|
|
152
160
|
enc = codec.encode(arr)
|
|
153
161
|
np.testing.assert_array_equal(np.frombuffer(enc.data, '>u4'), expected)
|
|
@@ -5,21 +5,21 @@ 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")
|
|
10
|
-
from numcodecs.tests.common import (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
except ImportError as e: # pragma: no cover
|
|
9
|
+
raise unittest.SkipTest("vlen-array not available") from e
|
|
10
|
+
from numcodecs.tests.common import (
|
|
11
|
+
assert_array_items_equal,
|
|
12
|
+
check_backwards_compatibility,
|
|
13
|
+
check_config,
|
|
14
|
+
check_encode_decode_array,
|
|
15
|
+
check_repr,
|
|
16
|
+
)
|
|
15
17
|
|
|
16
18
|
arrays = [
|
|
17
|
-
np.array([np.array([1, 2, 3]),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
np.array([4]),
|
|
22
|
-
np.array([5, 6])] * 300, dtype=object).reshape(90, 10),
|
|
19
|
+
np.array([np.array([1, 2, 3]), np.array([4]), np.array([5, 6])] * 300, dtype=object),
|
|
20
|
+
np.array([np.array([1, 2, 3]), np.array([4]), np.array([5, 6])] * 300, dtype=object).reshape(
|
|
21
|
+
90, 10
|
|
22
|
+
),
|
|
23
23
|
]
|
|
24
24
|
|
|
25
25
|
|
|
@@ -93,7 +93,5 @@ def test_encode_none():
|
|
|
93
93
|
codec = VLenArray(int)
|
|
94
94
|
enc = codec.encode(a)
|
|
95
95
|
dec = codec.decode(enc)
|
|
96
|
-
expect = np.array([np.array([1, 3]),
|
|
97
|
-
np.array([]),
|
|
98
|
-
np.array([4, 7])], dtype=object)
|
|
96
|
+
expect = np.array([np.array([1, 3]), np.array([]), np.array([4, 7])], dtype=object)
|
|
99
97
|
assert_array_items_equal(expect, dec)
|
|
@@ -5,12 +5,16 @@ 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")
|
|
10
|
-
from numcodecs.tests.common import (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
except ImportError as e: # pragma: no cover
|
|
9
|
+
raise unittest.SkipTest("vlen-bytes not available") from e
|
|
10
|
+
from numcodecs.tests.common import (
|
|
11
|
+
assert_array_items_equal,
|
|
12
|
+
check_backwards_compatibility,
|
|
13
|
+
check_config,
|
|
14
|
+
check_encode_decode_array,
|
|
15
|
+
check_repr,
|
|
16
|
+
greetings,
|
|
17
|
+
)
|
|
14
18
|
|
|
15
19
|
greetings_bytes = [g.encode('utf-8') for g in greetings]
|
|
16
20
|
|
|
@@ -19,8 +23,9 @@ arrays = [
|
|
|
19
23
|
np.array([b'foo', b'bar', b'baz'] * 300, dtype=object),
|
|
20
24
|
np.array(greetings_bytes * 100, dtype=object),
|
|
21
25
|
np.array([b'foo', b'bar', b'baz'] * 300, dtype=object).reshape(90, 10),
|
|
22
|
-
np.array(greetings_bytes * 1000, dtype=object).reshape(
|
|
23
|
-
|
|
26
|
+
np.array(greetings_bytes * 1000, dtype=object).reshape(
|
|
27
|
+
len(greetings_bytes), 100, 10, order='F'
|
|
28
|
+
),
|
|
24
29
|
]
|
|
25
30
|
|
|
26
31
|
|
|
@@ -1,18 +1,20 @@
|
|
|
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")
|
|
12
|
-
from numcodecs.tests.common import (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
except ImportError as e: # pragma: no cover
|
|
9
|
+
raise unittest.SkipTest("vlen-utf8 not available") from e
|
|
10
|
+
from numcodecs.tests.common import (
|
|
11
|
+
assert_array_items_equal,
|
|
12
|
+
check_backwards_compatibility,
|
|
13
|
+
check_config,
|
|
14
|
+
check_encode_decode_array,
|
|
15
|
+
check_repr,
|
|
16
|
+
greetings,
|
|
17
|
+
)
|
|
16
18
|
|
|
17
19
|
arrays = [
|
|
18
20
|
np.array(['foo', 'bar', 'baz'] * 300, dtype=object),
|
|
@@ -77,8 +79,11 @@ def test_decode_errors():
|
|
|
77
79
|
codec.decode(enc, out=np.zeros(10, dtype='i4'))
|
|
78
80
|
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
@pytest.mark.parametrize("writable", [True, False])
|
|
83
|
+
def test_encode_utf8(writable):
|
|
81
84
|
a = np.array(['foo', None, 'bar'], dtype=object)
|
|
85
|
+
if not writable:
|
|
86
|
+
a.setflags(write=False)
|
|
82
87
|
codec = VLenUTF8()
|
|
83
88
|
enc = codec.encode(a)
|
|
84
89
|
dec = codec.decode(enc)
|
numcodecs/tests/test_zfpy.py
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
import numpy as np
|
|
5
|
-
|
|
2
|
+
import pytest
|
|
6
3
|
|
|
7
4
|
try:
|
|
8
5
|
# noinspection PyProtectedMember
|
|
@@ -12,15 +9,14 @@ except ImportError: # pragma: no cover
|
|
|
12
9
|
|
|
13
10
|
|
|
14
11
|
from numcodecs.tests.common import (
|
|
15
|
-
check_encode_decode_array,
|
|
16
|
-
check_config,
|
|
17
|
-
check_repr,
|
|
18
12
|
check_backwards_compatibility,
|
|
13
|
+
check_config,
|
|
14
|
+
check_encode_decode_array,
|
|
19
15
|
check_err_decode_object_buffer,
|
|
20
16
|
check_err_encode_object_buffer,
|
|
17
|
+
check_repr,
|
|
21
18
|
)
|
|
22
19
|
|
|
23
|
-
|
|
24
20
|
codecs = [
|
|
25
21
|
ZFPY(mode=_zfpy.mode_fixed_rate, rate=-1),
|
|
26
22
|
ZFPY(),
|
|
@@ -38,12 +34,8 @@ arrays = [
|
|
|
38
34
|
np.random.normal(loc=1000, scale=1, size=(100, 10)),
|
|
39
35
|
np.random.normal(loc=1000, scale=1, size=(10, 10, 10)),
|
|
40
36
|
np.random.normal(loc=1000, scale=1, size=(2, 5, 10, 10)),
|
|
41
|
-
np.random.randint(-(2
|
|
42
|
-
|
|
43
|
-
),
|
|
44
|
-
np.random.randint(-(2 ** 63), -(2 ** 63) + 20, size=1000, dtype="i8").reshape(
|
|
45
|
-
10, 10, 10
|
|
46
|
-
),
|
|
37
|
+
np.random.randint(-(2**31), -(2**31) + 20, size=1000, dtype="i4").reshape(100, 10),
|
|
38
|
+
np.random.randint(-(2**63), -(2**63) + 20, size=1000, dtype="i8").reshape(10, 10, 10),
|
|
47
39
|
]
|
|
48
40
|
|
|
49
41
|
|
|
@@ -72,9 +64,7 @@ def test_backwards_compatibility():
|
|
|
72
64
|
codec = [code]
|
|
73
65
|
check_backwards_compatibility(ZFPY.codec_id, arrays, codec)
|
|
74
66
|
else:
|
|
75
|
-
check_backwards_compatibility(
|
|
76
|
-
ZFPY.codec_id, arrays[: len(arrays) - 2], codecs
|
|
77
|
-
)
|
|
67
|
+
check_backwards_compatibility(ZFPY.codec_id, arrays[: len(arrays) - 2], codecs)
|
|
78
68
|
|
|
79
69
|
|
|
80
70
|
def test_err_decode_object_buffer():
|
numcodecs/tests/test_zlib.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
|
-
|
|
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
|
+
)
|
|
8
14
|
from numcodecs.zlib import Zlib
|
|
9
|
-
from numcodecs.tests.common import (check_encode_decode, check_config, check_repr,
|
|
10
|
-
check_backwards_compatibility,
|
|
11
|
-
check_err_decode_object_buffer,
|
|
12
|
-
check_err_encode_object_buffer)
|
|
13
|
-
|
|
14
15
|
|
|
15
16
|
codecs = [
|
|
16
17
|
Zlib(),
|
|
@@ -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_zstd.py
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
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.zstd import Zstd
|
|
10
8
|
except ImportError: # pragma: no cover
|
|
11
|
-
pytest.skip(
|
|
12
|
-
"numcodecs.zstd not available", allow_module_level=True
|
|
13
|
-
)
|
|
9
|
+
pytest.skip("numcodecs.zstd not available", allow_module_level=True)
|
|
14
10
|
|
|
15
11
|
|
|
16
|
-
from numcodecs.tests.common import (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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_repr,
|
|
19
|
+
)
|
|
21
20
|
|
|
22
21
|
codecs = [
|
|
23
22
|
Zstd(),
|
|
@@ -27,6 +26,9 @@ codecs = [
|
|
|
27
26
|
Zstd(level=10),
|
|
28
27
|
Zstd(level=22),
|
|
29
28
|
Zstd(level=100),
|
|
29
|
+
Zstd(checksum=True),
|
|
30
|
+
Zstd(level=0, checksum=True),
|
|
31
|
+
Zstd(level=22, checksum=True),
|
|
30
32
|
]
|
|
31
33
|
|
|
32
34
|
|
|
@@ -34,8 +36,8 @@ codecs = [
|
|
|
34
36
|
# mix of shapes: 1D, 2D, 3D
|
|
35
37
|
# mix of orders: C, F
|
|
36
38
|
arrays = [
|
|
37
|
-
np.arange(1000, dtype=
|
|
38
|
-
np.linspace(1000, 1001, 1000, dtype=
|
|
39
|
+
np.arange(1000, dtype="i4"),
|
|
40
|
+
np.linspace(1000, 1001, 1000, dtype="f8"),
|
|
39
41
|
np.random.normal(loc=1000, scale=1, size=(100, 10)),
|
|
40
42
|
np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'),
|
|
41
43
|
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10),
|
|
@@ -43,10 +45,10 @@ arrays = [
|
|
|
43
45
|
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
|
|
44
46
|
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
|
|
45
47
|
np.random.randint(0, 2**25, size=1000, dtype='u8').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]'),
|
|
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]'),
|
|
50
52
|
]
|
|
51
53
|
|
|
52
54
|
|
|
@@ -74,3 +76,17 @@ def test_err_decode_object_buffer():
|
|
|
74
76
|
|
|
75
77
|
def test_err_encode_object_buffer():
|
|
76
78
|
check_err_encode_object_buffer(Zstd())
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def test_checksum():
|
|
82
|
+
data = np.arange(0, 64, dtype="uint8")
|
|
83
|
+
assert len(Zstd(level=0, checksum=False).encode(data)) + 4 == len(
|
|
84
|
+
Zstd(level=0, checksum=True).encode(data)
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_native_functions():
|
|
89
|
+
# Note, these assertions might need to be changed for new versions of zstd
|
|
90
|
+
assert Zstd.default_level() == 3
|
|
91
|
+
assert Zstd.min_level() == -131072
|
|
92
|
+
assert Zstd.max_level() == 22
|