Skip to content

Commit 30e5464

Browse files
committed
TEST Test percentiles
1 parent ba7b0a0 commit 30e5464

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

nibabel/tests/test_spatialimages.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from numpy.testing import assert_array_equal, assert_array_almost_equal
2525

2626
from .test_helpers import bytesio_round_trip
27+
from .test_viewers import needs_mpl
2728
from ..testing import (clear_and_catch_warnings, suppress_warnings,
2829
VIRAL_MEMMAP)
2930
from ..tmpdirs import InTemporaryDirectory
@@ -541,6 +542,16 @@ def test_slicer(self):
541542
assert_array_equal(sliced_data, img.dataobj[sliceobj])
542543
assert_array_equal(sliced_data, img.get_data()[sliceobj])
543544

545+
@needs_mpl
546+
def test_orthoview(self):
547+
# Assumes all possible images support int16
548+
# See https://github.com/nipy/nibabel/issues/58
549+
arr = np.arange(24, dtype=np.int16).reshape((2, 3, 4))
550+
img = self.image_class(arr, None)
551+
img.orthoview().close()
552+
img.orthoview(vlim=(5, 10)).close()
553+
img.orthoview(slicer=Ellipsis).close()
554+
544555
def test_api_deprecations(self):
545556

546557
class FakeImage(self.image_class):

nibabel/tests/test_viewers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from numpy.testing.decorators import skipif
1818
from numpy.testing import assert_array_equal, assert_equal
1919

20-
from nose.tools import assert_raises, assert_true
20+
from nose.tools import assert_raises, assert_true, assert_false
2121

2222
# Need at least MPL 1.3 for viewer tests.
2323
matplotlib, has_mpl, _ = optional_package('matplotlib', min_version='1.3')
@@ -75,6 +75,15 @@ def test_viewer():
7575
for im in v._ims:
7676
assert_array_equal(im.get_clim(), vlim)
7777
assert_array_equal(v._axes[3].get_ylim(), vlim)
78+
v.close()
79+
v1 = OrthoSlicer3D(data)
80+
v2 = OrthoSlicer3D(data, vlim=('1%', '99%'))
81+
assert_array_equal(v1.clim, v2.clim)
82+
v2.close()
83+
v2 = OrthoSlicer3D(data, vlim=('2%', '98%'))
84+
assert_false(np.array_equal(v1.clim, v2.clim))
85+
v2.close()
86+
v1.close()
7887

7988
# non-multi-volume
8089
v = OrthoSlicer3D(data[:, :, :, 0])

0 commit comments

Comments
 (0)