-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest_slice.py
29 lines (23 loc) · 862 Bytes
/
test_slice.py
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
import numpy as np
from tests import test_module as tm
from tests.utils import generate_matrix, check_matrix_content
def test_noslicing():
mat = generate_matrix()
assert(mat.shape == (10, 12, 3))
assert(mat.flags['C_CONTIGUOUS'])
assert(mat.dtype == np.uint16)
assert(tm.get_shape(mat) == (10, 12, 3))
def test_slicing_width():
mat = generate_matrix()[:,:3,:]
assert(mat.shape == (10, 3, 3))
assert(not mat.flags['C_CONTIGUOUS'])
assert(mat.dtype == np.uint16)
assert(tm.get_shape(mat) == (10, 3, 3))
assert(np.all(tm.get_content_as_list(mat) == mat.flatten()))
def test_slicing_channel():
mat = generate_matrix()[:,:,0]
assert(mat.shape == (10, 12))
assert(not mat.flags['C_CONTIGUOUS'])
assert(mat.dtype == np.uint16)
assert(tm.get_shape(mat) == (10, 12, 1))
assert(np.all(tm.get_content_as_list(mat) == mat.flatten()))