forked from zarr-developers/numcodecs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_packbits.py
More file actions
39 lines (29 loc) · 979 Bytes
/
test_packbits.py
File metadata and controls
39 lines (29 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import numpy as np
from numcodecs.packbits import PackBits
from tests.common import (
check_backwards_compatibility,
check_config,
check_encode_decode,
check_repr,
)
arrays = [
np.random.randint(0, 2, size=1000, dtype=bool),
np.random.randint(0, 2, size=(100, 10), dtype=bool),
np.random.randint(0, 2, size=(10, 10, 10), dtype=bool),
np.random.randint(0, 2, size=1000, dtype=bool).reshape(10, 10, 10, order='F'),
]
def test_encode_decode():
codec = PackBits()
for arr in arrays:
check_encode_decode(arr, codec)
# check different number of left-over bits
arr = np.random.randint(0, 2, size=1000, dtype=bool)
for size in list(range(1, 17)):
check_encode_decode(arr[:size], codec)
def test_config():
codec = PackBits()
check_config(codec)
def test_repr():
check_repr("PackBits()")
def test_backwards_compatibility():
check_backwards_compatibility(PackBits.codec_id, arrays, [PackBits()])