1414from ..viewers import OrthoSlicer3D
1515
1616from numpy .testing .decorators import skipif
17+ from numpy .testing import assert_array_equal
1718
1819from nose .tools import assert_raises
1920
@@ -29,7 +30,7 @@ def test_viewer():
2930 data = (np .outer (a , b )[..., np .newaxis ] * a )[:, :, :, np .newaxis ]
3031 data = data * np .array ([1. , 2. ]) # give it a # of volumes > 1
3132 v = OrthoSlicer3D (data )
32- plt . draw ( )
33+ assert_array_equal ( v . position , ( 0 , 0 , 0 ) )
3334
3435 # fake some events, inside and outside axes
3536 v ._on_scroll (nt ('event' , 'button inaxes key' )('up' , None , None ))
@@ -41,6 +42,8 @@ def test_viewer():
4142 for ax in v ._axes .values ():
4243 v ._on_mouse (nt ('event' , 'xdata ydata inaxes button' )(0.5 , 0.5 , ax , 1 ))
4344 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
4447 v .close ()
4548
4649 # non-multi-volume
@@ -51,7 +54,14 @@ def test_viewer():
5154 # other cases
5255 fig , axes = plt .subplots (1 , 4 )
5356 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 ])
5661 assert_raises (ValueError , OrthoSlicer3D , data [:, :, 0 , 0 ])
5762 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