Skip to content

Commit 6d88cba

Browse files
committed
Merge pull request #1264 from miykael/pep8StyleCorrections
STY: PEP8 style correction for all warnings, and almost all errors. Except E402, E501 and E731
2 parents 450f1d1 + fc34144 commit 6d88cba

File tree

175 files changed

+1988
-1971
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+1988
-1971
lines changed

build_docs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class APIDocs(TempInstall):
7070

7171
user_options = [
7272
('None', None, 'this command has no options'),
73-
]
73+
]
7474

7575
def run(self):
7676
# First build the project and install it to a temporary location.
@@ -193,5 +193,3 @@ def run(self):
193193
'api_docs': APIDocs,
194194
'clean': Clean,
195195
}
196-
197-

doc/conf.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import sys, os
15+
import sys
16+
import os
1617

1718
nipypepath = os.path.abspath('..')
1819
sys.path.insert(1, nipypepath)
@@ -211,8 +212,8 @@
211212
# Grouping the document tree into LaTeX files. List of tuples
212213
# (source start file, target name, title, author, documentclass [howto/manual]).
213214
latex_documents = [
214-
('documentation', 'nipype.tex', u'nipype Documentation',
215-
u'Neuroimaging in Python team', 'manual'),
215+
('documentation', 'nipype.tex', u'nipype Documentation',
216+
u'Neuroimaging in Python team', 'manual'),
216217
]
217218

218219
# The name of an image file (relative to this directory) to place at the top of

doc/sphinxext/autosummary_generate.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
"""
1919

2020
from __future__ import print_function
21-
import glob, re, inspect, os, optparse, pydoc
21+
import glob
22+
import re
23+
import inspect
24+
import os
25+
import optparse
26+
import pydoc
2227
from autosummary import import_by_name
2328

2429
try:
@@ -76,7 +81,7 @@ def main():
7681
f = open(fn, 'w')
7782

7883
try:
79-
f.write('%s\n%s\n\n' % (name, '='*len(name)))
84+
f.write('%s\n%s\n\n' % (name, '=' * len(name)))
8085

8186
if inspect.isclass(obj):
8287
if issubclass(obj, Exception):
@@ -205,7 +210,7 @@ def get_documented_in_lines(lines, module=None, filename=None):
205210
current_module = name
206211
documented.update(get_documented_in_docstring(
207212
name, filename=filename))
208-
elif current_module and not name.startswith(current_module+'.'):
213+
elif current_module and not name.startswith(current_module + '.'):
209214
name = "%s.%s" % (current_module, name)
210215
documented.setdefault(name, []).append(
211216
(filename, current_title, "auto" + m.group(1), None))

doc/sphinxext/numpy_ext/docscrape.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def read_to_condition(self, condition_func):
6767
return self[start:self._l]
6868
self._l += 1
6969
if self.eof():
70-
return self[start:self._l+1]
70+
return self[start:self._l + 1]
7171
return []
7272

7373
def read_to_next_empty_line(self):
@@ -114,7 +114,7 @@ def __init__(self, docstring, config={}):
114114
'References': '',
115115
'Examples': '',
116116
'index': {}
117-
}
117+
}
118118

119119
self._parse()
120120

@@ -139,18 +139,20 @@ def _is_at_section(self):
139139
return True
140140

141141
l2 = self._doc.peek(1).strip() # ---------- or ==========
142-
return l2.startswith('-'*len(l1)) or l2.startswith('='*len(l1))
142+
return l2.startswith('-' * len(l1)) or l2.startswith('=' * len(l1))
143143

144144
def _strip(self, doc):
145145
i = 0
146146
j = 0
147147
for i, line in enumerate(doc):
148-
if line.strip(): break
148+
if line.strip():
149+
break
149150

150151
for j, line in enumerate(doc[::-1]):
151-
if line.strip(): break
152+
if line.strip():
153+
break
152154

153-
return doc[i:len(doc)-j]
155+
return doc[i:len(doc) - j]
154156

155157
def _read_to_next_section(self):
156158
section = self._doc.read_to_next_empty_line()
@@ -227,7 +229,8 @@ def push_item(name, rest):
227229
rest = []
228230

229231
for line in content:
230-
if not line.strip(): continue
232+
if not line.strip():
233+
continue
231234

232235
m = self._name_rgx.match(line)
233236
if m and line[m.end():].strip().startswith(':'):
@@ -306,12 +309,12 @@ def _parse(self):
306309
# string conversion routines
307310

308311
def _str_header(self, name, symbol='-'):
309-
return [name, len(name)*symbol]
312+
return [name, len(name) * symbol]
310313

311314
def _str_indent(self, doc, indent=4):
312315
out = []
313316
for line in doc:
314-
out += [' '*indent + line]
317+
out += [' ' * indent + line]
315318
return out
316319

317320
def _str_signature(self):
@@ -351,7 +354,8 @@ def _str_section(self, name):
351354
return out
352355

353356
def _str_see_also(self, func_role):
354-
if not self['See Also']: return []
357+
if not self['See Also']:
358+
return []
355359
out = []
356360
out += self._str_header("See Also")
357361
last_had_desc = True
@@ -404,7 +408,7 @@ def __str__(self, func_role=''):
404408

405409

406410
def indent(str, indent=4):
407-
indent_str = ' '*indent
411+
indent_str = ' ' * indent
408412
if str is None:
409413
return indent_str
410414
lines = str.split('\n')
@@ -417,7 +421,7 @@ def dedent_lines(lines):
417421

418422

419423
def header(text, style='-'):
420-
return text + '\n' + style*len(text) + '\n'
424+
return text + '\n' + style * len(text) + '\n'
421425

422426

423427
class FunctionDoc(NumpyDocString):
@@ -504,9 +508,9 @@ def methods(self):
504508
if self._cls is None:
505509
return []
506510
return [name for name, func in inspect.getmembers(self._cls)
507-
if ((not name.startswith('_')
508-
or name in self.extra_public_methods)
509-
and callable(func))]
511+
if ((not name.startswith('_') or
512+
name in self.extra_public_methods) and
513+
callable(func))]
510514

511515
@property
512516
def properties(self):

doc/sphinxext/numpy_ext/docscrape_sphinx.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from __future__ import absolute_import
2-
import re, inspect, textwrap, pydoc
2+
import re
3+
import inspect
4+
import textwrap
5+
import pydoc
36
import sphinx
47
from .docscrape import NumpyDocString, FunctionDoc, ClassDoc
58
from nipype.external.six import string_types
@@ -20,7 +23,7 @@ def _str_field_list(self, name):
2023
def _str_indent(self, doc, indent=4):
2124
out = []
2225
for line in doc:
23-
out += [' '*indent + line]
26+
out += [' ' * indent + line]
2427
return out
2528

2629
def _str_signature(self):
@@ -87,7 +90,7 @@ def _str_member_list(self, name):
8790
if others:
8891
maxlen_0 = max([len(x[0]) for x in others])
8992
maxlen_1 = max([len(x[1]) for x in others])
90-
hdr = "="*maxlen_0 + " " + "="*maxlen_1 + " " + "="*10
93+
hdr = "=" * maxlen_0 + " " + "=" * maxlen_1 + " " + "=" * 10
9194
fmt = '%%%ds %%%ds ' % (maxlen_0, maxlen_1)
9295
n_indent = maxlen_0 + maxlen_1 + 4
9396
out += [hdr]
@@ -164,8 +167,8 @@ def _str_references(self):
164167
def _str_examples(self):
165168
examples_str = "\n".join(self['Examples'])
166169

167-
if (self.use_plots and 'import matplotlib' in examples_str
168-
and 'plot::' not in examples_str):
170+
if (self.use_plots and 'import matplotlib' in examples_str and
171+
'plot::' not in examples_str):
169172
out = []
170173
out += self._str_header('Examples')
171174
out += ['.. plot::', '']

doc/sphinxext/numpy_ext/numpydoc.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
if sphinx.__version__ < '1.0.1':
2525
raise RuntimeError("Sphinx 1.0.1 or newer is required")
2626

27-
import os, re, pydoc
27+
import os
28+
import re
29+
import pydoc
2830
from .docscrape_sphinx import get_doc_object, SphinxDocString
2931
from sphinx.util.compat import Directive
3032
import inspect
@@ -39,14 +41,14 @@ def mangle_docstrings(app, what, name, obj, options, lines,
3941
if what == 'module':
4042
# Strip top title
4143
title_re = re.compile(ur'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
42-
re.I |re.S)
44+
re.I | re.S)
4345
lines[:] = title_re.sub(u'', u"\n".join(lines)).split(u"\n")
4446
else:
4547
doc = get_doc_object(obj, what, u"\n".join(lines), config=cfg)
4648
lines[:] = str(doc).split(u"\n")
4749

4850
if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \
49-
obj.__name__:
51+
obj.__name__:
5052
if hasattr(obj, '__module__'):
5153
v = dict(full_name=u"%s.%s" % (obj.__module__, obj.__name__))
5254
else:
@@ -87,8 +89,10 @@ def mangle_signature(app, what, name, obj, options, sig, retann):
8789
'initializes x; see ' in pydoc.getdoc(obj.__init__))):
8890
return '', ''
8991

90-
if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return
91-
if not hasattr(obj, '__doc__'): return
92+
if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')):
93+
return
94+
if not hasattr(obj, '__doc__'):
95+
return
9296

9397
doc = SphinxDocString(pydoc.getdoc(obj))
9498
if doc['Signature']:
@@ -176,4 +180,3 @@ def run(self):
176180
return base_directive.run(self)
177181

178182
return directive
179-

examples/dmri_camino_dti.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def get_affine(volume):
268268
tractography.connect([(dtifit, fa, [("tensor_fitted", "in_file")])])
269269
tractography.connect([(fa, analyzeheader_fa, [("fa", "in_file")])])
270270
tractography.connect([(inputnode, analyzeheader_fa, [(('dwi', get_vox_dims), 'voxel_dims'),
271-
(('dwi', get_data_dims), 'data_dims')])])
271+
(('dwi', get_data_dims), 'data_dims')])])
272272
tractography.connect([(fa, fa2nii, [('fa', 'data_file')])])
273273
tractography.connect([(inputnode, fa2nii, [(('dwi', get_affine), 'affine')])])
274274
tractography.connect([(analyzeheader_fa, fa2nii, [('header', 'header_file')])])
@@ -277,7 +277,7 @@ def get_affine(volume):
277277
tractography.connect([(dtifit, trace, [("tensor_fitted", "in_file")])])
278278
tractography.connect([(trace, analyzeheader_trace, [("trace", "in_file")])])
279279
tractography.connect([(inputnode, analyzeheader_trace, [(('dwi', get_vox_dims), 'voxel_dims'),
280-
(('dwi', get_data_dims), 'data_dims')])])
280+
(('dwi', get_data_dims), 'data_dims')])])
281281
tractography.connect([(trace, trace2nii, [('trace', 'data_file')])])
282282
tractography.connect([(inputnode, trace2nii, [(('dwi', get_affine), 'affine')])])
283283
tractography.connect([(analyzeheader_trace, trace2nii, [('header', 'header_file')])])
@@ -287,10 +287,10 @@ def get_affine(volume):
287287
tractography.connect([(trackpico, cam2trk_pico, [('tracked', 'in_file')])])
288288
tractography.connect([(trackdt, cam2trk_dt, [('tracked', 'in_file')])])
289289
tractography.connect([(inputnode, cam2trk_pico, [(('dwi', get_vox_dims), 'voxel_dims'),
290-
(('dwi', get_data_dims), 'data_dims')])])
290+
(('dwi', get_data_dims), 'data_dims')])])
291291

292292
tractography.connect([(inputnode, cam2trk_dt, [(('dwi', get_vox_dims), 'voxel_dims'),
293-
(('dwi', get_data_dims), 'data_dims')])])
293+
(('dwi', get_data_dims), 'data_dims')])])
294294

295295

296296
"""
@@ -303,9 +303,9 @@ def get_affine(volume):
303303
workflow.base_dir = os.path.abspath('camino_dti_tutorial')
304304
workflow.connect([(infosource, datasource, [('subject_id', 'subject_id')]),
305305
(datasource, tractography, [('dwi', 'inputnode.dwi'),
306-
('bvals', 'inputnode.bvals'),
307-
('bvecs', 'inputnode.bvecs')
308-
])
306+
('bvals', 'inputnode.bvals'),
307+
('bvecs', 'inputnode.bvecs')
308+
])
309309
])
310310
"""
311311
The following functions run the whole workflow and produce a .dot and .png graph of the processing pipeline.

examples/dmri_connectivity.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def select_aparc_annot(list_of_files):
464464
mapping.connect([(dtifit, fa, [("tensor_fitted", "in_file")])])
465465
mapping.connect([(fa, analyzeheader_fa, [("fa", "in_file")])])
466466
mapping.connect([(inputnode, analyzeheader_fa, [(('dwi', get_vox_dims), 'voxel_dims'),
467-
(('dwi', get_data_dims), 'data_dims')])])
467+
(('dwi', get_data_dims), 'data_dims')])])
468468
mapping.connect([(fa, fa2nii, [('fa', 'data_file')])])
469469
mapping.connect([(inputnode, fa2nii, [(('dwi', get_affine), 'affine')])])
470470
mapping.connect([(analyzeheader_fa, fa2nii, [('header', 'header_file')])])
@@ -473,7 +473,7 @@ def select_aparc_annot(list_of_files):
473473
mapping.connect([(dtifit, trace, [("tensor_fitted", "in_file")])])
474474
mapping.connect([(trace, analyzeheader_trace, [("trace", "in_file")])])
475475
mapping.connect([(inputnode, analyzeheader_trace, [(('dwi', get_vox_dims), 'voxel_dims'),
476-
(('dwi', get_data_dims), 'data_dims')])])
476+
(('dwi', get_data_dims), 'data_dims')])])
477477
mapping.connect([(trace, trace2nii, [('trace', 'data_file')])])
478478
mapping.connect([(inputnode, trace2nii, [(('dwi', get_affine), 'affine')])])
479479
mapping.connect([(analyzeheader_trace, trace2nii, [('header', 'header_file')])])
@@ -490,7 +490,7 @@ def select_aparc_annot(list_of_files):
490490
(camino2trackvis, trk2camino, [['trackvis', 'in_file']])
491491
])
492492
mapping.connect([(inputnode, camino2trackvis, [(('dwi', get_vox_dims), 'voxel_dims'),
493-
(('dwi', get_data_dims), 'data_dims')])])
493+
(('dwi', get_data_dims), 'data_dims')])])
494494

495495
"""
496496
Here the CMTK connectivity mapping nodes are connected.
@@ -571,11 +571,11 @@ def select_aparc_annot(list_of_files):
571571
connectivity.connect([
572572
(infosource, datasource, [('subject_id', 'subject_id')]),
573573
(datasource, mapping, [('dwi', 'inputnode.dwi'),
574-
('bvals', 'inputnode.bvals'),
575-
('bvecs', 'inputnode.bvecs')
576-
]),
577-
(infosource, mapping, [('subject_id', 'inputnode.subject_id')])
578-
])
574+
('bvals', 'inputnode.bvals'),
575+
('bvecs', 'inputnode.bvecs')
576+
]),
577+
(infosource, mapping, [('subject_id', 'inputnode.subject_id')])
578+
])
579579

580580
"""
581581
The following functions run the whole workflow and produce graphs describing the processing pipeline.

examples/dmri_connectivity_advanced.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
import nipype.interfaces.cmtk as cmtk
5757
import nipype.interfaces.dipy as dipy
5858
import inspect
59-
import os, os.path as op # system functions
59+
import os
60+
import os.path as op # system functions
6061
from nipype.workflows.dmri.fsl.dti import create_eddy_correct_pipeline
6162
from nipype.workflows.dmri.camino.connectivity_mapping import select_aparc_annot
6263
from nipype.utils.misc import package_check
@@ -580,11 +581,11 @@
580581
connectivity.connect([
581582
(infosource, datasource, [('subject_id', 'subject_id')]),
582583
(datasource, mapping, [('dwi', 'inputnode.dwi'),
583-
('bvals', 'inputnode.bvals'),
584-
('bvecs', 'inputnode.bvecs')
585-
]),
586-
(infosource, mapping, [('subject_id', 'inputnode.subject_id')])
587-
])
584+
('bvals', 'inputnode.bvals'),
585+
('bvecs', 'inputnode.bvecs')
586+
]),
587+
(infosource, mapping, [('subject_id', 'inputnode.subject_id')])
588+
])
588589

589590
"""
590591
The following functions run the whole workflow and produce a .dot and .png graph of the processing pipeline.

0 commit comments

Comments
 (0)