Skip to content

Commit eca32f6

Browse files
committed
DOCTEST: De-indent or remove testsetup blocks
1 parent 6bca398 commit eca32f6

File tree

5 files changed

+52
-103
lines changed

5 files changed

+52
-103
lines changed

nipype/interfaces/base/core.py

-13
Original file line numberDiff line numberDiff line change
@@ -692,14 +692,6 @@ class SimpleInterface(BaseInterface):
692692
Examples
693693
--------
694694
695-
.. testsetup::
696-
697-
>>> from .specs import TraitedSpec
698-
>>> tmp = getfixture('tmpdir')
699-
>>> old = tmp.chdir() # changing to a temporary directory
700-
701-
.. doctest::
702-
703695
>>> def double(x):
704696
... return 2 * x
705697
...
@@ -721,11 +713,6 @@ class SimpleInterface(BaseInterface):
721713
>>> dbl.inputs.x = 2
722714
>>> dbl.run().outputs.doubled
723715
4.0
724-
725-
.. testsetup::
726-
727-
>>> os.chdir(old.strpath)
728-
729716
"""
730717

731718
def __init__(self, from_file=None, resource_monitor=None, **inputs):

nipype/interfaces/dcm2nii.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,14 @@ class Dcm2nii(CommandLine):
106106
Examples
107107
========
108108
109-
.. testsetup::
110-
111-
>>> tmp = getfixture('tmpdir')
112-
>>> old = tmp.chdir() # changing to a temporary directory
113-
114-
.. doctest::
115-
116109
>>> from nipype.interfaces.dcm2nii import Dcm2nii
117110
>>> converter = Dcm2nii()
118-
>>> converter.inputs.source_names = [os.path.join(datadir, 'functional_1.dcm'), os.path.join(datadir, 'functional_2.dcm')]
111+
>>> converter.inputs.source_names = ['functional_1.dcm', 'functional_2.dcm']
119112
>>> converter.inputs.gzip_output = True
120113
>>> converter.inputs.output_dir = '.'
121-
>>> converter.cmdline #doctest: +ELLIPSIS
122-
'dcm2nii -a y -c y -b config.ini -v y -d y -e y -g y -i n -n y -o . -p y -x n -f n ...functional_1.dcm'
123-
124-
.. testsetup::
125-
126-
>>> os.chdir(old.strpath)
127-
128-
"""
114+
>>> converter.cmdline # doctest: +ELLIPSIS
115+
'dcm2nii -a y -c y -b config.ini -v y -d y -e y -g y -i n -n y -o . -p y -x n -f n functional_1.dcm'
116+
"""
129117

130118
input_spec = Dcm2niiInputSpec
131119
output_spec = Dcm2niiOutputSpec

nipype/interfaces/image.py

+48-50
Original file line numberDiff line numberDiff line change
@@ -32,65 +32,63 @@ class ReorientOutputSpec(TraitedSpec):
3232
class Reorient(SimpleInterface):
3333
"""Conform an image to a given orientation
3434
35-
Flips and reorder the image data array so that the axes match the
36-
directions indicated in ``orientation``.
37-
The default ``RAS`` orientation corresponds to the first axis being ordered
38-
from left to right, the second axis from posterior to anterior, and the
39-
third axis from inferior to superior.
35+
Flips and reorder the image data array so that the axes match the
36+
directions indicated in ``orientation``.
37+
The default ``RAS`` orientation corresponds to the first axis being ordered
38+
from left to right, the second axis from posterior to anterior, and the
39+
third axis from inferior to superior.
4040
41-
For oblique images, the original orientation is considered to be the
42-
closest plumb orientation.
41+
For oblique images, the original orientation is considered to be the
42+
closest plumb orientation.
4343
44-
No resampling is performed, and thus the output image is not de-obliqued
45-
or registered to any other image or template.
44+
No resampling is performed, and thus the output image is not de-obliqued
45+
or registered to any other image or template.
4646
47-
The effective transform is calculated from the original affine matrix to
48-
the reoriented affine matrix.
47+
The effective transform is calculated from the original affine matrix to
48+
the reoriented affine matrix.
4949
50-
Examples
51-
--------
50+
Examples
51+
--------
5252
53-
.. testsetup::
53+
If an image is not reoriented, the original file is not modified
54+
55+
.. testsetup::
5456
5557
>>> def print_affine(matrix):
5658
... print(str(matrix).replace(']', ' ').replace('[', ' '))
5759
58-
.. doctest::
59-
60-
If an image is not reoriented, the original file is not modified
61-
62-
>>> import numpy as np
63-
>>> from nipype.interfaces.image import Reorient
64-
>>> reorient = Reorient(orientation='LPS')
65-
>>> reorient.inputs.in_file = 'segmentation0.nii.gz'
66-
>>> res = reorient.run()
67-
>>> res.outputs.out_file
68-
'segmentation0.nii.gz'
69-
70-
>>> print_affine(np.loadtxt(res.outputs.transform))
71-
1. 0. 0. 0.
72-
0. 1. 0. 0.
73-
0. 0. 1. 0.
74-
0. 0. 0. 1.
75-
76-
>>> reorient.inputs.orientation = 'RAS'
77-
>>> res = reorient.run()
78-
>>> res.outputs.out_file # doctest: +ELLIPSIS
79-
'.../segmentation0_ras.nii.gz'
80-
81-
>>> print_affine(np.loadtxt(res.outputs.transform))
82-
-1. 0. 0. 60.
83-
0. -1. 0. 72.
84-
0. 0. 1. 0.
85-
0. 0. 0. 1.
86-
87-
.. testcleanup::
88-
89-
>>> import os
90-
>>> os.unlink(res.outputs.out_file)
91-
>>> os.unlink(res.outputs.transform)
92-
93-
"""
60+
>>> import numpy as np
61+
>>> from nipype.interfaces.image import Reorient
62+
>>> reorient = Reorient(orientation='LPS')
63+
>>> reorient.inputs.in_file = 'segmentation0.nii.gz'
64+
>>> res = reorient.run()
65+
>>> res.outputs.out_file
66+
'segmentation0.nii.gz'
67+
68+
>>> print_affine(np.loadtxt(res.outputs.transform))
69+
1. 0. 0. 0.
70+
0. 1. 0. 0.
71+
0. 0. 1. 0.
72+
0. 0. 0. 1.
73+
74+
>>> reorient.inputs.orientation = 'RAS'
75+
>>> res = reorient.run()
76+
>>> res.outputs.out_file # doctest: +ELLIPSIS
77+
'.../segmentation0_ras.nii.gz'
78+
79+
>>> print_affine(np.loadtxt(res.outputs.transform))
80+
-1. 0. 0. 60.
81+
0. -1. 0. 72.
82+
0. 0. 1. 0.
83+
0. 0. 0. 1.
84+
85+
.. testcleanup::
86+
87+
>>> import os
88+
>>> os.unlink(res.outputs.out_file)
89+
>>> os.unlink(res.outputs.transform)
90+
91+
"""
9492
input_spec = ReorientInputSpec
9593
output_spec = ReorientOutputSpec
9694

nipype/interfaces/io.py

-12
Original file line numberDiff line numberDiff line change
@@ -2585,13 +2585,6 @@ class JSONFileGrabber(IOBase):
25852585
Example
25862586
-------
25872587
2588-
.. testsetup::
2589-
2590-
>>> tmp = getfixture('tmpdir')
2591-
>>> old = tmp.chdir() # changing to a temporary directory
2592-
2593-
.. doctest::
2594-
25952588
>>> import pprint
25962589
>>> from nipype.interfaces.io import JSONFileGrabber
25972590
>>> jsonSource = JSONFileGrabber()
@@ -2603,11 +2596,6 @@ class JSONFileGrabber(IOBase):
26032596
>>> res = jsonSource.run()
26042597
>>> pprint.pprint(res.outputs.get()) # doctest:, +ELLIPSIS
26052598
{'param1': 'exampleStr', 'param2': 4, 'param3': 1.0}
2606-
2607-
.. testsetup::
2608-
2609-
>>> os.chdir(old.strpath)
2610-
26112599
"""
26122600
input_spec = JSONFileGrabberInputSpec
26132601
output_spec = DynamicTraitedSpec

nipype/interfaces/niftyreg/regutils.py

-12
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,6 @@ class RegAverage(NiftyRegCommand):
450450
Examples
451451
--------
452452
453-
.. testsetup::
454-
455-
>>> tmp = getfixture('tmpdir')
456-
>>> old = tmp.chdir() # changing to temporary file
457-
458-
.. doctest::
459-
460453
>>> from nipype.interfaces import niftyreg
461454
>>> node = niftyreg.RegAverage()
462455
>>> one_file = 'im1.nii'
@@ -465,11 +458,6 @@ class RegAverage(NiftyRegCommand):
465458
>>> node.inputs.avg_files = [one_file, two_file, three_file]
466459
>>> node.cmdline # doctest: +ELLIPSIS
467460
'reg_average --cmd_file .../reg_average_cmd'
468-
469-
.. testsetup::
470-
471-
>>> os.chdir(old.strpath)
472-
473461
"""
474462
_cmd = get_custom_path('reg_average')
475463
input_spec = RegAverageInputSpec

0 commit comments

Comments
 (0)