Skip to content

Commit be7fd47

Browse files
committed
TEST Test percentiles
1 parent 6fea5fe commit be7fd47

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
@@ -25,6 +25,7 @@
2525
from numpy.testing import assert_array_equal, assert_array_almost_equal
2626

2727
from .test_helpers import bytesio_round_trip
28+
from .test_viewers import needs_mpl
2829
from ..testing import (clear_and_catch_warnings, suppress_warnings,
2930
memmap_after_ufunc)
3031
from ..tmpdirs import InTemporaryDirectory
@@ -539,6 +540,16 @@ def test_slicer(self):
539540
assert_array_equal(sliced_data, img.dataobj[sliceobj])
540541
assert_array_equal(sliced_data, img.get_data()[sliceobj])
541542

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

544555
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)