Skip to content

Commit c146254

Browse files
committed
BF - add gifti data files to data files; continue to try to fix python3 doc tests
1 parent f105911 commit c146254

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

nibabel/gifti/giftiio.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ def write(image, filename):
7373
.topo.gii
7474
Topology
7575
"""
76-
7776
f = open(filename, 'w')
7877
f.write(image.to_xml())
7978
f.close()
80-
81-

nibabel/spatialimages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@
103103
work:
104104
105105
>>> # write an image to files
106-
>>> from StringIO import StringIO
106+
>>> from StringIO import StringIO as BytesIO
107107
>>> file_map = nib.AnalyzeImage.make_file_map()
108-
>>> file_map['image'].fileobj = StringIO()
109-
>>> file_map['header'].fileobj = StringIO()
108+
>>> file_map['image'].fileobj = BytesIO()
109+
>>> file_map['header'].fileobj = BytesIO()
110110
>>> img = nib.AnalyzeImage(data, np.eye(4))
111111
>>> img.file_map = file_map
112112
>>> img.to_file_map()

nibabel/volumeutils.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,8 @@ def keys(self):
159159
160160
>>> codes = ((1, 'one'), (2, 'two'), (1, 'repeat value'))
161161
>>> k = Recoder(codes).keys()
162-
>>> k.sort() # Just to guarantee order for doctest output
163-
>>> k
164-
[1, 2, 'one', 'repeat value', 'two']
162+
>>> set(k) == set([1, 2, 'one', 'repeat value', 'two'])
163+
True
165164
'''
166165
return self.field1.keys()
167166

@@ -388,14 +387,14 @@ def array_from_file(shape, in_dtype, infile, offset=0, order='F'):
388387
389388
Examples
390389
--------
391-
>>> import StringIO
392-
>>> str_io = StringIO.StringIO()
390+
>>> from StringIO import StringIO as BytesIO
391+
>>> str_io = BytesIO()
393392
>>> arr = np.arange(6).reshape(1,2,3)
394393
>>> str_io.write(arr.tostring('F'))
395394
>>> arr2 = array_from_file((1,2,3), arr.dtype, str_io)
396395
>>> np.all(arr == arr2)
397396
True
398-
>>> str_io = StringIO.StringIO()
397+
>>> str_io = BytesIO()
399398
>>> str_io.write(' ' * 10)
400399
>>> str_io.write(arr.tostring('F'))
401400
>>> arr2 = array_from_file((1,2,3), arr.dtype, str_io, 10)
@@ -486,21 +485,21 @@ def array_to_file(data, fileobj, out_dtype=None, offset=0,
486485
487486
Examples
488487
--------
489-
>>> from StringIO import StringIO
490-
>>> sio = StringIO()
488+
>>> from StringIO import StringIO as BytesIO
489+
>>> sio = BytesIO()
491490
>>> data = np.arange(10, dtype=np.float)
492491
>>> array_to_file(data, sio, np.float)
493492
>>> sio.getvalue() == data.tostring('F')
494493
True
495-
>>> sio.truncate(0)
494+
>>> _ = sio.truncate(0); _ = sio.seek(0) # outputs 0 in python 3
496495
>>> array_to_file(data, sio, np.int16)
497496
>>> sio.getvalue() == data.astype(np.int16).tostring()
498497
True
499-
>>> sio.truncate(0)
498+
>>> _ = sio.truncate(0); _ = sio.seek(0)
500499
>>> array_to_file(data.byteswap(), sio, np.float)
501500
>>> sio.getvalue() == data.byteswap().tostring('F')
502501
True
503-
>>> sio.truncate(0)
502+
>>> _ = sio.truncate(0); _ = sio.seek(0)
504503
>>> array_to_file(data, sio, np.float, order='C')
505504
>>> sio.getvalue() == data.tostring('C')
506505
True

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def main(**extra_args):
8989
[pjoin('tests', 'data', '*'),
9090
pjoin('externals', 'tests', 'data', '*'),
9191
pjoin('nicom', 'tests', 'data', '*'),
92+
pjoin('gifti', 'tests', 'data', '*'),
9293
]},
9394
scripts = [pjoin('bin', 'parrec2nii')],
9495
cmdclass = cmdclass,

0 commit comments

Comments
 (0)