|
15 | 15 | from ..viewers import OrthoSlicer3D
|
16 | 16 |
|
17 | 17 | from numpy.testing.decorators import skipif
|
18 |
| -from numpy.testing import assert_array_equal |
| 18 | +from numpy.testing import assert_array_equal, assert_equal |
19 | 19 |
|
20 | 20 | from nose.tools import assert_raises, assert_true
|
21 | 21 |
|
@@ -48,14 +48,29 @@ def test_viewer():
|
48 | 48 | v._on_mouse(nt('event', 'xdata ydata inaxes button')(0.5, 0.5, ax, 1))
|
49 | 49 | v._on_mouse(nt('event', 'xdata ydata inaxes button')(0.5, 0.5, None, None))
|
50 | 50 | v.set_volume_idx(1)
|
| 51 | + |
| 52 | + # decrement/increment volume numbers via keypress |
51 | 53 | v.set_volume_idx(1) # should just pass
|
| 54 | + v._on_keypress(nt('event', 'key')('-')) # decrement |
| 55 | + assert_equal(v._data_idx[3], 0) |
| 56 | + v._on_keypress(nt('event', 'key')('+')) # increment |
| 57 | + assert_equal(v._data_idx[3], 1) |
| 58 | + v._on_keypress(nt('event', 'key')('-')) |
| 59 | + v._on_keypress(nt('event', 'key')('=')) # alternative increment key |
| 60 | + assert_equal(v._data_idx[3], 1) |
| 61 | + |
52 | 62 | v.close()
|
53 | 63 | v._draw() # should be safe
|
54 | 64 |
|
55 | 65 | # non-multi-volume
|
56 | 66 | v = OrthoSlicer3D(data[:, :, :, 0])
|
57 | 67 | v._on_scroll(nt('event', 'button inaxes key')('up', v._axes[0], 'shift'))
|
58 | 68 | v._on_keypress(nt('event', 'key')('escape'))
|
| 69 | + v.close() |
| 70 | + |
| 71 | + # complex input should raise a TypeError prior to figure creation |
| 72 | + assert_raises(TypeError, OrthoSlicer3D, |
| 73 | + data[:, :, :, 0].astype(np.complex64)) |
59 | 74 |
|
60 | 75 | # other cases
|
61 | 76 | fig, axes = plt.subplots(1, 4)
|
|
0 commit comments