1
- import sme_contrib . pyvista_utils as pvu
1
+ import sme_contrib as smeplots
2
2
import numpy as np
3
3
import matplotlib .pyplot as plt
4
4
import matplotlib .colors as mcolors
@@ -12,22 +12,22 @@ def test_rgb_to_scalar():
12
12
[[[0 , 0 , 0 ], [255 , 255 , 255 ]], [[0 , 0 , 0 ], [255 , 255 , 255 ]]],
13
13
]
14
14
)
15
- scalar_img = pvu .rgb_to_scalar (img )
15
+ scalar_img = smeplots . pyvista_utils .rgb_to_scalar (img )
16
16
assert scalar_img .shape == (3 , 2 , 2 )
17
17
assert np .all (
18
18
scalar_img == np .array ([[[0 , 1 ], [0 , 1 ]], [[0 , 1 ], [0 , 1 ]], [[0 , 1 ], [0 , 1 ]]])
19
19
)
20
20
21
21
22
22
def test_make_discrete_colormap ():
23
- lt = pvu .make_discrete_colormap ()
23
+ lt = smeplots . pyvista_utils .make_discrete_colormap ()
24
24
cm = plt .get_cmap ("tab10" ).colors
25
25
should = (np .array ([mcolors .to_rgba (cm [0 ])]) * 255 ).astype (np .int32 )
26
26
assert lt .n_values == 1
27
27
assert lt .scalar_range == (0 , 1 )
28
28
assert np .all (lt .values == should )
29
29
30
- lt = pvu .make_discrete_colormap ("tab20" , np .array ([0 , 1 , 2 , 3 ]))
30
+ lt = smeplots . pyvista_utils .make_discrete_colormap ("tab20" , np .array ([0 , 1 , 2 , 3 ]))
31
31
assert lt .n_values == 4
32
32
assert lt .scalar_range == (0 , 4 )
33
33
cm = plt .get_cmap ("tab20" ).colors
@@ -46,18 +46,18 @@ def test_make_discrete_colormap():
46
46
47
47
48
48
def test_find_layout ():
49
- assert pvu .find_layout (1 ) == (1 , 1 )
50
- assert pvu .find_layout (3 ) == (1 , 3 )
51
- assert pvu .find_layout (5 ) == (2 , 3 )
52
- assert pvu .find_layout (8 ) == (2 , 4 )
53
- assert pvu .find_layout (10 ) == (2 , 5 )
54
- assert pvu .find_layout (15 ) == (3 , 5 )
55
- assert pvu .find_layout (15 , portrait = True ) == (5 , 3 )
56
- assert pvu .find_layout (16 ) == (4 , 4 )
57
- assert pvu .find_layout (19 ) == (4 , 5 )
58
- assert pvu .find_layout (23 ) == (4 , 6 )
59
- assert pvu .find_layout (25 ) == (5 , 5 )
60
- assert pvu .find_layout (27 ) == (4 , 7 )
61
- assert pvu .find_layout (29 ) == (5 , 6 )
62
- assert pvu .find_layout (31 ) == (5 , 7 )
63
- assert pvu .find_layout (31 , portrait = True ) == (7 , 5 )
49
+ assert smeplots . pyvista_utils .find_layout (1 ) == (1 , 1 )
50
+ assert smeplots . pyvista_utils .find_layout (3 ) == (1 , 3 )
51
+ assert smeplots . pyvista_utils .find_layout (5 ) == (2 , 3 )
52
+ assert smeplots . pyvista_utils .find_layout (8 ) == (2 , 4 )
53
+ assert smeplots . pyvista_utils .find_layout (10 ) == (2 , 5 )
54
+ assert smeplots . pyvista_utils .find_layout (15 ) == (3 , 5 )
55
+ assert smeplots . pyvista_utils .find_layout (15 , portrait = True ) == (5 , 3 )
56
+ assert smeplots . pyvista_utils .find_layout (16 ) == (4 , 4 )
57
+ assert smeplots . pyvista_utils .find_layout (19 ) == (4 , 5 )
58
+ assert smeplots . pyvista_utils .find_layout (23 ) == (4 , 6 )
59
+ assert smeplots . pyvista_utils .find_layout (25 ) == (5 , 5 )
60
+ assert smeplots . pyvista_utils .find_layout (27 ) == (4 , 7 )
61
+ assert smeplots . pyvista_utils .find_layout (29 ) == (5 , 6 )
62
+ assert smeplots . pyvista_utils .find_layout (31 ) == (5 , 7 )
63
+ assert smeplots . pyvista_utils .find_layout (31 , portrait = True ) == (7 , 5 )
0 commit comments