Skip to content

Commit 58fae01

Browse files
demianweffigies
authored andcommitted
Increased testing coverage and code cleanup
1 parent fef51b8 commit 58fae01

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

nibabel/cifti2/cifti2.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ def from_file_map(klass, file_map):
984984
""" Load a Cifti2 image from a file_map
985985
986986
Parameters
987-
file_map : string
987+
file_map : file_map
988988
989989
Returns
990990
-------
@@ -1000,9 +1000,6 @@ def from_file_map(klass, file_map):
10001000
cifti_header = item.get_content()
10011001
break
10021002
else:
1003-
cifti_header = None
1004-
1005-
if cifti_header is None:
10061003
raise ValueError('Nifti2 header does not contain a CIFTI2 '
10071004
'extension')
10081005

nibabel/cifti2/tests/test_cifti2io.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
from nibabel.tmpdirs import InTemporaryDirectory
2020
from nibabel.tests.nibabel_data import get_nibabel_data, needs_nibabel_data
2121

22-
CIFTI2_DATA = pjoin(get_nibabel_data(), 'nitest-cifti2')
23-
24-
25-
2622
from numpy.testing import assert_array_equal, assert_array_almost_equal
2723
from nose.tools import (assert_true, assert_false, assert_equal,
2824
assert_raises)
2925

26+
NIBABEL_TEST_DATA = pjoin(dirname(nib.__file__), 'tests', 'data')
27+
NIFTI2_DATA = pjoin(NIBABEL_TEST_DATA, 'example_nifti2.nii.gz')
28+
29+
CIFTI2_DATA = pjoin(get_nibabel_data(), 'nitest-cifti2')
30+
3031
DATA_FILE1 = pjoin(CIFTI2_DATA, '')
3132
DATA_FILE2 = pjoin(CIFTI2_DATA,
3233
'Conte69.MyelinAndCorrThickness.32k_fs_LR.dscalar.nii')
@@ -40,6 +41,12 @@
4041
datafiles = [DATA_FILE2, DATA_FILE3, DATA_FILE4, DATA_FILE5, DATA_FILE6]
4142

4243

44+
def test_read_nifti2():
45+
filemap = ci.Cifti2Image.make_file_map()
46+
for k in filemap:
47+
filemap[k].fileobj = open(NIFTI2_DATA)
48+
assert_raises(ValueError, ci.Cifti2Image.from_file_map, filemap)
49+
4350
@needs_nibabel_data('nitest-cifti2')
4451
def test_read_internal():
4552
img2 = ci.load(DATA_FILE6)

0 commit comments

Comments
 (0)