Skip to content

Commit 5e0ec20

Browse files
committed
adding tests
1 parent dd50224 commit 5e0ec20

File tree

7 files changed

+118
-30
lines changed

7 files changed

+118
-30
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.algorithms.metrics import ErrorMap
4+
5+
def test_ErrorMap_inputs():
6+
input_map = dict(ignore_exception=dict(nohash=True,
7+
usedefault=True,
8+
),
9+
in_ref=dict(mandatory=True,
10+
),
11+
in_tst=dict(mandatory=True,
12+
),
13+
mask=dict(),
14+
metric=dict(mandatory=True,
15+
usedefault=True,
16+
),
17+
out_map=dict(),
18+
)
19+
inputs = ErrorMap.input_spec()
20+
21+
for key, metadata in input_map.items():
22+
for metakey, value in metadata.items():
23+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
24+
25+
def test_ErrorMap_outputs():
26+
output_map = dict(distance=dict(),
27+
out_map=dict(),
28+
)
29+
outputs = ErrorMap.output_spec()
30+
31+
for key, metadata in output_map.items():
32+
for metakey, value in metadata.items():
33+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
34+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.algorithms.misc import Overlap
4+
5+
def test_Overlap_inputs():
6+
input_map = dict(bg_overlap=dict(mandatory=True,
7+
usedefault=True,
8+
),
9+
ignore_exception=dict(nohash=True,
10+
usedefault=True,
11+
),
12+
mask_volume=dict(),
13+
out_file=dict(usedefault=True,
14+
),
15+
vol_units=dict(mandatory=True,
16+
usedefault=True,
17+
),
18+
volume1=dict(mandatory=True,
19+
),
20+
volume2=dict(mandatory=True,
21+
),
22+
weighting=dict(usedefault=True,
23+
),
24+
)
25+
inputs = Overlap.input_spec()
26+
27+
for key, metadata in input_map.items():
28+
for metakey, value in metadata.items():
29+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
30+
31+
def test_Overlap_outputs():
32+
output_map = dict(dice=dict(),
33+
diff_file=dict(),
34+
jaccard=dict(),
35+
labels=dict(),
36+
roi_di=dict(),
37+
roi_ji=dict(),
38+
roi_voldiff=dict(),
39+
volume_difference=dict(),
40+
)
41+
outputs = Overlap.output_spec()
42+
43+
for key, metadata in output_map.items():
44+
for metakey, value in metadata.items():
45+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
46+

nipype/interfaces/afni/preprocess.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,19 @@ class RefitInputSpec(CommandLineInputSpec):
169169
argstr='-yorigin %s')
170170
zorigin = traits.Str(desc='z distance for edge voxel offset',
171171
argstr='-zorigin %s')
172-
172+
173173
xdel = traits.Float(desc='new x voxel dimension in mm',
174174
argstr='-xdel %f')
175-
175+
176176
ydel = traits.Float(desc='new y voxel dimension in mm',
177177
argstr='-ydel %f')
178-
178+
179179
zdel = traits.Float(desc='new z voxel dimension in mm',
180180
argstr='-zdel %f')
181-
182-
space = traits.Enum('TLRC', 'MNI', 'ORIG',
181+
182+
space = traits.Enum('TLRC', 'MNI', 'ORIG',
183183
argstr='-space %s',
184-
desc='Associates the dataset with a specific' +
184+
desc='Associates the dataset with a specific' +
185185
' template type, e.g. TLRC, MNI, ORIG')
186186

187187

nipype/interfaces/afni/tests/test_auto_Refit.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ def test_Refit_inputs():
1818
mandatory=True,
1919
position=-1,
2020
),
21+
space=dict(argstr='-space %s',
22+
),
2123
terminal_output=dict(nohash=True,
2224
),
25+
xdel=dict(argstr='-xdel %f',
26+
),
2327
xorigin=dict(argstr='-xorigin %s',
2428
),
29+
ydel=dict(argstr='-ydel %f',
30+
),
2531
yorigin=dict(argstr='-yorigin %s',
2632
),
33+
zdel=dict(argstr='-zdel %f',
34+
),
2735
zorigin=dict(argstr='-zorigin %s',
2836
),
2937
)

nipype/interfaces/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,9 +1349,9 @@ def _terminal_output_update(self):
13491349
def set_default_terminal_output(cls, output_type):
13501350
"""Set the default terminal output for CommandLine Interfaces.
13511351
1352-
This method is used to set default terminal output for
1353-
CommandLine Interfaces. However, setting this will not
1354-
update the output type for any existing instances. For these,
1352+
This method is used to set default terminal output for
1353+
CommandLine Interfaces. However, setting this will not
1354+
update the output type for any existing instances. For these,
13551355
assign the <instance>.inputs.terminal_output.
13561356
"""
13571357

nipype/utils/nipype_cmd.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def add_options(parser=None, module=None, function=None):
1919
if parser and module and function:
2020
__import__(module)
2121
interface = getattr(sys.modules[module],function)()
22-
22+
2323
inputs = interface.input_spec()
2424
for name, spec in sorted(interface.inputs.traits(transient=None).items()):
2525
desc = "\n".join(interface._get_trait_desc(inputs, name, spec))[len(name)+2:]
@@ -33,7 +33,7 @@ def add_options(parser=None, module=None, function=None):
3333
def run_instance(interface, options):
3434
if interface:
3535
print "setting function inputs"
36-
36+
3737
for input_name, _ in interface.inputs.items():
3838
if getattr(options, input_name) != None:
3939
value = getattr(options, input_name)
@@ -48,23 +48,23 @@ def run_instance(interface, options):
4848
value)
4949
except ValueError, e:
5050
print "Error when setting the value of %s: '%s'"%(input_name, str(e))
51-
51+
5252
print interface.inputs
5353
res = interface.run()
54-
print res.outputs
54+
print res.outputs
5555

5656

5757
def main(argv):
58-
58+
5959
if len(argv) == 2 and not argv[1].startswith("-"):
6060
listClasses(argv[1])
6161
sys.exit(0)
62-
62+
6363
parser = argparse.ArgumentParser(description='Nipype interface runner', prog=argv[0])
6464
parser.add_argument("module", type=str, help="Module name")
6565
parser.add_argument("interface", type=str, help="Interface name")
6666
parsed = parser.parse_args(args=argv[1:3])
67-
67+
6868
_, prog = os.path.split(argv[0])
6969
interface_parser = argparse.ArgumentParser(description="Run %s"%parsed.interface, prog=" ".join([prog] + argv[1:3]))
7070
interface_parser, interface = add_options(interface_parser, parsed.module, parsed.interface)

nipype/utils/tests/test_cmd.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ def test_main_returns_2_on_empty(self):
2222
with self.assertRaises(SystemExit) as cm:
2323
with capture_sys_output() as (stdout, stderr):
2424
nipype_cmd.main(['nipype_cmd'])
25-
25+
2626
exit_exception = cm.exception
2727
self.assertEqual(exit_exception.code, 2)
28-
29-
self.assertEqual(stderr.getvalue(),
28+
29+
self.assertEqual(stderr.getvalue(),
3030
"""usage: nipype_cmd [-h] module interface
3131
nipype_cmd: error: too few arguments
3232
""")
3333
self.assertEqual(stdout.getvalue(), '')
34-
34+
3535
def test_main_returns_0_on_help(self):
3636
with self.assertRaises(SystemExit) as cm:
3737
with capture_sys_output() as (stdout, stderr):
3838
nipype_cmd.main(['nipype_cmd', '-h'])
39-
39+
4040
exit_exception = cm.exception
4141
self.assertEqual(exit_exception.code, 0)
42-
42+
4343
self.assertEqual(stderr.getvalue(), '')
4444
self.assertEqual(stdout.getvalue(),
4545
"""usage: nipype_cmd [-h] module interface
@@ -53,15 +53,15 @@ def test_main_returns_0_on_help(self):
5353
optional arguments:
5454
-h, --help show this help message and exit
5555
""")
56-
56+
5757
def test_list_nipy_interfacesp(self):
5858
with self.assertRaises(SystemExit) as cm:
5959
with capture_sys_output() as (stdout, stderr):
6060
nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy'])
61-
61+
6262
exit_exception = cm.exception
6363
self.assertEqual(exit_exception.code, 0)
64-
64+
6565
self.assertEqual(stderr.getvalue(), '')
6666
self.assertEqual(stdout.getvalue(),
6767
"""Available Interfaces:
@@ -77,10 +77,10 @@ def test_run_4d_realign_without_arguments(self):
7777
with self.assertRaises(SystemExit) as cm:
7878
with capture_sys_output() as (stdout, stderr):
7979
nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d'])
80-
80+
8181
exit_exception = cm.exception
8282
self.assertEqual(exit_exception.code, 2)
83-
83+
8484
self.assertEqual(stderr.getvalue(),
8585
"""usage: nipype_cmd nipype.interfaces.nipy FmriRealign4d [-h]
8686
[--between_loops BETWEEN_LOOPS]
@@ -95,15 +95,15 @@ def test_run_4d_realign_without_arguments(self):
9595
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: too few arguments
9696
""")
9797
self.assertEqual(stdout.getvalue(), '')
98-
98+
9999
def test_run_4d_realign_help(self):
100100
with self.assertRaises(SystemExit) as cm:
101101
with capture_sys_output() as (stdout, stderr):
102102
nipype_cmd.main(['nipype_cmd', 'nipype.interfaces.nipy', 'FmriRealign4d', '-h'])
103-
103+
104104
exit_exception = cm.exception
105105
self.assertEqual(exit_exception.code, 0)
106-
106+
107107
self.assertEqual(stderr.getvalue(), '')
108108
self.assertTrue("Run FmriRealign4d" in stdout.getvalue())
109109

0 commit comments

Comments
 (0)