Skip to content

Commit b5246a8

Browse files
committed
refractoring
1 parent 412f7af commit b5246a8

File tree

8 files changed

+53
-27
lines changed

8 files changed

+53
-27
lines changed

doc/devel/matlab_example1.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from nipype.interfaces.matlab import MatlabCommand
2-
from nipype.interfaces.base import TraitedSpec, \
3-
BaseInterface, BaseInterfaceInputSpec, File
2+
from nipype.interfaces.base import (
3+
TraitedSpec,
4+
BaseInterface,
5+
BaseInterfaceInputSpec,
6+
File,
7+
)
48
import os
59
from string import Template
610

711

812
class ConmapTxt2MatInputSpec(BaseInterfaceInputSpec):
913
in_file = File(exists=True, mandatory=True)
10-
out_file = File('cmatrix.mat', usedefault=True)
14+
out_file = File("cmatrix.mat", usedefault=True)
1115

1216

1317
class ConmapTxt2MatOutputSpec(TraitedSpec):
@@ -19,14 +23,15 @@ class ConmapTxt2Mat(BaseInterface):
1923
output_spec = ConmapTxt2MatOutputSpec
2024

2125
def _run_interface(self, runtime):
22-
d = dict(in_file=self.inputs.in_file,
23-
out_file=self.inputs.out_file)
26+
d = dict(in_file=self.inputs.in_file, out_file=self.inputs.out_file)
2427
# This is your MATLAB code template
25-
script = Template("""in_file = '$in_file';
28+
script = Template(
29+
"""in_file = '$in_file';
2630
out_file = '$out_file';
2731
ConmapTxt2Mat(in_file, out_file);
2832
exit;
29-
""").substitute(d)
33+
"""
34+
).substitute(d)
3035

3136
# mfile = True will create an .m file with your script and executed.
3237
# Alternatively
@@ -43,5 +48,5 @@ def _run_interface(self, runtime):
4348

4449
def _list_outputs(self):
4550
outputs = self._outputs().get()
46-
outputs['out_file'] = os.path.abspath(self.inputs.out_file)
51+
outputs["out_file"] = os.path.abspath(self.inputs.out_file)
4752
return outputs

doc/devel/matlab_example2.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55

66
class HelloWorldInputSpec(MatlabInputSpec):
7-
name = traits.Str(mandatory=True,
8-
desc='Name of person to say hello to')
7+
name = traits.Str(mandatory=True, desc="Name of person to say hello to")
98

109

1110
class HelloWorldOutputSpec(TraitedSpec):
@@ -29,6 +28,7 @@ class HelloWorld(MatlabCommand):
2928
>>> out = hello.run()
3029
>>> print out.outputs.matlab_output
3130
"""
31+
3232
input_spec = HelloWorldInputSpec
3333
output_spec = HelloWorldOutputSpec
3434

@@ -37,7 +37,9 @@ def _my_script(self):
3737
script = """
3838
disp('Hello %s Python')
3939
two = 1 + 1
40-
""" % (self.inputs.name)
40+
""" % (
41+
self.inputs.name
42+
)
4143
return script
4244

4345
def run(self, **inputs):

nipype/interfaces/mrtrix3/tests/test_auto_MRConvert.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ def test_MRConvert_inputs():
4444
mandatory=True,
4545
position=-2,
4646
),
47+
json_export=dict(
48+
argstr="-json_export %s",
49+
extensions=None,
50+
mandatory=False,
51+
),
52+
json_import=dict(
53+
argstr="-json_import %s",
54+
extensions=None,
55+
mandatory=False,
56+
),
4757
nthreads=dict(
4858
argstr="-nthreads %d",
4959
nohash=True,
@@ -73,6 +83,9 @@ def test_MRConvert_inputs():
7383

7484
def test_MRConvert_outputs():
7585
output_map = dict(
86+
json_export=dict(
87+
extensions=None,
88+
),
7689
out_file=dict(
7790
extensions=None,
7891
),

nipype/interfaces/mrtrix3/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ class MRConvert(MRTrix3Base):
678678
def _list_outputs(self):
679679
outputs = self.output_spec().get()
680680
outputs["out_file"] = op.abspath(self.inputs.out_file)
681+
outputs["json_export"] = op.abspath(self.inputs.json_export)
681682
return outputs
682683

683684

tools/checkspecs.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
# Functions and classes
1515
class InterfaceChecker(object):
16-
"""Class for checking all interface specifications
17-
"""
16+
"""Class for checking all interface specifications"""
1817

1918
def __init__(
2019
self,
@@ -23,7 +22,7 @@ def __init__(
2322
module_skip_patterns=None,
2423
class_skip_patterns=None,
2524
):
26-
r""" Initialize package for parsing
25+
r"""Initialize package for parsing
2726
2827
Parameters
2928
----------
@@ -113,14 +112,14 @@ def _uri2path(self, uri):
113112
return path
114113

115114
def _path2uri(self, dirpath):
116-
""" Convert directory path to uri """
115+
"""Convert directory path to uri"""
117116
relpath = dirpath.replace(self.root_path, self.package_name)
118117
if relpath.startswith(os.path.sep):
119118
relpath = relpath[1:]
120119
return relpath.replace(os.path.sep, ".")
121120

122121
def _parse_module(self, uri):
123-
""" Parse module defined in *uri* """
122+
"""Parse module defined in *uri*"""
124123
filename = self._uri2path(uri)
125124
if filename is None:
126125
# nothing that we could handle here.
@@ -131,7 +130,7 @@ def _parse_module(self, uri):
131130
return functions, classes
132131

133132
def _parse_lines(self, linesource, module):
134-
""" Parse lines of text for functions and classes """
133+
"""Parse lines of text for functions and classes"""
135134
functions = []
136135
classes = []
137136
for line in linesource:
@@ -387,7 +386,7 @@ def test_specs(self, uri):
387386
return bad_specs
388387

389388
def _survives_exclude(self, matchstr, match_type):
390-
""" Returns True if *matchstr* does not match patterns
389+
"""Returns True if *matchstr* does not match patterns
391390
392391
``self.package_name`` removed from front of string if present
393392
@@ -429,7 +428,7 @@ def _survives_exclude(self, matchstr, match_type):
429428
return True
430429

431430
def discover_modules(self):
432-
""" Return module sequence discovered from ``self.package_name``
431+
"""Return module sequence discovered from ``self.package_name``
433432
434433
435434
Parameters

tools/gitwash_dumper.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def cp_files(in_path, globs, out_path):
5050

5151

5252
def filename_search_replace(sr_pairs, filename, backup=False):
53-
""" Search and replace for expressions in files
54-
55-
"""
53+
"""Search and replace for expressions in files"""
5654
in_txt = open(filename, "rt").read(-1)
5755
out_txt = in_txt[:]
5856
for in_exp, out_exp in sr_pairs:
@@ -94,7 +92,7 @@ def make_link_targets(
9492
url=None,
9593
ml_url=None,
9694
):
97-
""" Check and make link targets
95+
"""Check and make link targets
9896
9997
If url is None or ml_url is None, check if there are links present for
10098
these in `known_link_fname`. If not, raise error. The check is:

tools/run_examples.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44

55

66
if __name__ == "__main__":
7-
print(dedent("""Nipype examples have been moved to niflow-nipype1-examples.
7+
print(
8+
dedent(
9+
"""Nipype examples have been moved to niflow-nipype1-examples.
810
9-
Install with: pip install niflow-nipype1-examples"""))
11+
Install with: pip install niflow-nipype1-examples"""
12+
)
13+
)
1014
if sys.argv[1:]:
11-
print("Run this command with: niflow-nipype1-examples " + " ".join(sys.argv[1:]))
15+
print(
16+
"Run this command with: niflow-nipype1-examples " + " ".join(sys.argv[1:])
17+
)
1218
sys.exit(1)

tools/toollib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def sh(cmd):
3131
def compile_tree():
3232
"""Compile all Python files below current directory."""
3333
vstr = ".".join(map(str, sys.version_info[:2]))
34-
stat = os.system("%s %s/lib/python%s/compileall.py ." % (sys.executable, sys.prefix, vstr))
34+
stat = os.system(
35+
"%s %s/lib/python%s/compileall.py ." % (sys.executable, sys.prefix, vstr)
36+
)
3537
if stat:
3638
msg = "*** ERROR: Some Python files in tree do NOT compile! ***\n"
3739
msg += "See messages above for the actual file that produced it.\n"

0 commit comments

Comments
 (0)