14
14
from ..viewers import OrthoSlicer3D
15
15
16
16
from numpy .testing .decorators import skipif
17
+ from numpy .testing import assert_array_equal
17
18
18
19
from nose .tools import assert_raises
19
20
@@ -29,7 +30,7 @@ def test_viewer():
29
30
data = (np .outer (a , b )[..., np .newaxis ] * a )[:, :, :, np .newaxis ]
30
31
data = data * np .array ([1. , 2. ]) # give it a # of volumes > 1
31
32
v = OrthoSlicer3D (data )
32
- plt . draw ( )
33
+ assert_array_equal ( v . position , ( 0 , 0 , 0 ) )
33
34
34
35
# fake some events, inside and outside axes
35
36
v ._on_scroll (nt ('event' , 'button inaxes key' )('up' , None , None ))
@@ -41,6 +42,8 @@ def test_viewer():
41
42
for ax in v ._axes .values ():
42
43
v ._on_mouse (nt ('event' , 'xdata ydata inaxes button' )(0.5 , 0.5 , ax , 1 ))
43
44
v ._on_mouse (nt ('event' , 'xdata ydata inaxes button' )(0.5 , 0.5 , None , None ))
45
+ v .set_volume_idx (1 )
46
+ v .set_volume_idx (1 ) # should just pass
44
47
v .close ()
45
48
46
49
# non-multi-volume
@@ -51,7 +54,14 @@ def test_viewer():
51
54
# other cases
52
55
fig , axes = plt .subplots (1 , 4 )
53
56
plt .close (fig )
54
- OrthoSlicer3D (data , pcnt_range = [0.1 , 0.9 ], axes = axes )
55
- OrthoSlicer3D (data , axes = axes [:3 ])
57
+ v1 = OrthoSlicer3D (data , pcnt_range = [0.1 , 0.9 ], axes = axes )
58
+ aff = np .array ([[0 , 1 , 0 , 3 ], [- 1 , 0 , 0 , 2 ], [0 , 0 , 2 , 1 ], [0 , 0 , 0 , 1 ]],
59
+ float )
60
+ v2 = OrthoSlicer3D (data , affine = aff , axes = axes [:3 ])
56
61
assert_raises (ValueError , OrthoSlicer3D , data [:, :, 0 , 0 ])
57
62
assert_raises (ValueError , OrthoSlicer3D , data , affine = np .eye (3 ))
63
+ assert_raises (TypeError , v2 .link_to , 1 )
64
+ v2 .link_to (v1 )
65
+ v2 .link_to (v1 ) # shouldn't do anything
66
+ v1 .close ()
67
+ v2 .close ()
0 commit comments