Skip to content

STY: PEP8 style correction for all warnings, and almost all errors. Except E402, E501 and E731 #1264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Nov 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a64c84f
FIX: PEP8 - W191 indentation contains tabs
miykael Nov 1, 2015
347f089
FIX: PEP8 - W291 trailing whitespace
miykael Nov 1, 2015
a177591
FIX: PEP8 - W292 no newline at end of file
miykael Nov 1, 2015
08b94e8
FIX: PEP8 - W293 blank line contains whitespace
miykael Nov 1, 2015
e9dc256
FIX: PEP8 - W391 blank line at end of file
miykael Nov 1, 2015
e6695bc
FIX: PEP8 - W503 line break before binary operator
miykael Nov 1, 2015
ba7f1bb
FIX: PEP8 - E401 multiple imports on one line
miykael Nov 1, 2015
faa13a5
FIX: PEP8 - E502 the backslash is redundant between brackets
miykael Nov 1, 2015
1034f30
FIX: PEP8 - E701 multiple statements on one line (colon)
miykael Nov 1, 2015
67f10e5
FIX: PEP8 - E703 statement ends with a semicolon
miykael Nov 1, 2015
46635e5
FIX: PEP8 - E711 comparison to None should be 'if cond is (not) None:'
miykael Nov 1, 2015
f28d822
FIX: PEP8 - E712 comparison to True/False should be 'if cond is True/…
miykael Nov 1, 2015
89d13fa
FIX: PEP8 - E713 test for membership should be 'not in'
miykael Nov 1, 2015
b60de4c
FIX: PEP8 - E714 test for object identity should be 'is not'
miykael Nov 1, 2015
f4d89d6
FIX: PEP8 - missing whitespace around operator (E225) or arithmetic o…
miykael Nov 1, 2015
1df2021
FIX: PEP8 - indentation correction for E121, E123, E124, E125, E126, …
miykael Nov 1, 2015
42b2ae4
FIX: PEP8 - E241 multiple spaces after ',' - 2nd clean up
miykael Nov 1, 2015
712ab69
STY: PEP8 style correction in auto-generated test files. Those correc…
miykael Nov 1, 2015
0d00610
FIX: correction for docparse test that changed because of PEP8 W291 s…
miykael Nov 1, 2015
fc34144
FIX: Conflict correction after merge with master
miykael Nov 16, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class APIDocs(TempInstall):

user_options = [
('None', None, 'this command has no options'),
]
]

def run(self):
# First build the project and install it to a temporary location.
Expand Down Expand Up @@ -193,5 +193,3 @@ def run(self):
'api_docs': APIDocs,
'clean': Clean,
}


7 changes: 4 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import sys
import os

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

# The name of an image file (relative to this directory) to place at the top of
Expand Down
11 changes: 8 additions & 3 deletions doc/sphinxext/autosummary_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
"""

from __future__ import print_function
import glob, re, inspect, os, optparse, pydoc
import glob
import re
import inspect
import os
import optparse
import pydoc
from autosummary import import_by_name

try:
Expand Down Expand Up @@ -76,7 +81,7 @@ def main():
f = open(fn, 'w')

try:
f.write('%s\n%s\n\n' % (name, '='*len(name)))
f.write('%s\n%s\n\n' % (name, '=' * len(name)))

if inspect.isclass(obj):
if issubclass(obj, Exception):
Expand Down Expand Up @@ -205,7 +210,7 @@ def get_documented_in_lines(lines, module=None, filename=None):
current_module = name
documented.update(get_documented_in_docstring(
name, filename=filename))
elif current_module and not name.startswith(current_module+'.'):
elif current_module and not name.startswith(current_module + '.'):
name = "%s.%s" % (current_module, name)
documented.setdefault(name, []).append(
(filename, current_title, "auto" + m.group(1), None))
Expand Down
34 changes: 19 additions & 15 deletions doc/sphinxext/numpy_ext/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def read_to_condition(self, condition_func):
return self[start:self._l]
self._l += 1
if self.eof():
return self[start:self._l+1]
return self[start:self._l + 1]
return []

def read_to_next_empty_line(self):
Expand Down Expand Up @@ -114,7 +114,7 @@ def __init__(self, docstring, config={}):
'References': '',
'Examples': '',
'index': {}
}
}

self._parse()

Expand All @@ -139,18 +139,20 @@ def _is_at_section(self):
return True

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

def _strip(self, doc):
i = 0
j = 0
for i, line in enumerate(doc):
if line.strip(): break
if line.strip():
break

for j, line in enumerate(doc[::-1]):
if line.strip(): break
if line.strip():
break

return doc[i:len(doc)-j]
return doc[i:len(doc) - j]

def _read_to_next_section(self):
section = self._doc.read_to_next_empty_line()
Expand Down Expand Up @@ -227,7 +229,8 @@ def push_item(name, rest):
rest = []

for line in content:
if not line.strip(): continue
if not line.strip():
continue

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

def _str_header(self, name, symbol='-'):
return [name, len(name)*symbol]
return [name, len(name) * symbol]

def _str_indent(self, doc, indent=4):
out = []
for line in doc:
out += [' '*indent + line]
out += [' ' * indent + line]
return out

def _str_signature(self):
Expand Down Expand Up @@ -351,7 +354,8 @@ def _str_section(self, name):
return out

def _str_see_also(self, func_role):
if not self['See Also']: return []
if not self['See Also']:
return []
out = []
out += self._str_header("See Also")
last_had_desc = True
Expand Down Expand Up @@ -404,7 +408,7 @@ def __str__(self, func_role=''):


def indent(str, indent=4):
indent_str = ' '*indent
indent_str = ' ' * indent
if str is None:
return indent_str
lines = str.split('\n')
Expand All @@ -417,7 +421,7 @@ def dedent_lines(lines):


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


class FunctionDoc(NumpyDocString):
Expand Down Expand Up @@ -504,9 +508,9 @@ def methods(self):
if self._cls is None:
return []
return [name for name, func in inspect.getmembers(self._cls)
if ((not name.startswith('_')
or name in self.extra_public_methods)
and callable(func))]
if ((not name.startswith('_') or
name in self.extra_public_methods) and
callable(func))]

@property
def properties(self):
Expand Down
13 changes: 8 additions & 5 deletions doc/sphinxext/numpy_ext/docscrape_sphinx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import absolute_import
import re, inspect, textwrap, pydoc
import re
import inspect
import textwrap
import pydoc
import sphinx
from .docscrape import NumpyDocString, FunctionDoc, ClassDoc
from nipype.external.six import string_types
Expand All @@ -20,7 +23,7 @@ def _str_field_list(self, name):
def _str_indent(self, doc, indent=4):
out = []
for line in doc:
out += [' '*indent + line]
out += [' ' * indent + line]
return out

def _str_signature(self):
Expand Down Expand Up @@ -87,7 +90,7 @@ def _str_member_list(self, name):
if others:
maxlen_0 = max([len(x[0]) for x in others])
maxlen_1 = max([len(x[1]) for x in others])
hdr = "="*maxlen_0 + " " + "="*maxlen_1 + " " + "="*10
hdr = "=" * maxlen_0 + " " + "=" * maxlen_1 + " " + "=" * 10
fmt = '%%%ds %%%ds ' % (maxlen_0, maxlen_1)
n_indent = maxlen_0 + maxlen_1 + 4
out += [hdr]
Expand Down Expand Up @@ -164,8 +167,8 @@ def _str_references(self):
def _str_examples(self):
examples_str = "\n".join(self['Examples'])

if (self.use_plots and 'import matplotlib' in examples_str
and 'plot::' not in examples_str):
if (self.use_plots and 'import matplotlib' in examples_str and
'plot::' not in examples_str):
out = []
out += self._str_header('Examples')
out += ['.. plot::', '']
Expand Down
15 changes: 9 additions & 6 deletions doc/sphinxext/numpy_ext/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
if sphinx.__version__ < '1.0.1':
raise RuntimeError("Sphinx 1.0.1 or newer is required")

import os, re, pydoc
import os
import re
import pydoc
from .docscrape_sphinx import get_doc_object, SphinxDocString
from sphinx.util.compat import Directive
import inspect
Expand All @@ -39,14 +41,14 @@ def mangle_docstrings(app, what, name, obj, options, lines,
if what == 'module':
# Strip top title
title_re = re.compile(ur'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
re.I |re.S)
re.I | re.S)
lines[:] = title_re.sub(u'', u"\n".join(lines)).split(u"\n")
else:
doc = get_doc_object(obj, what, u"\n".join(lines), config=cfg)
lines[:] = str(doc).split(u"\n")

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

if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')): return
if not hasattr(obj, '__doc__'): return
if not (callable(obj) or hasattr(obj, '__argspec_is_invalid_')):
return
if not hasattr(obj, '__doc__'):
return

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

return directive

14 changes: 7 additions & 7 deletions examples/dmri_camino_dti.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def get_affine(volume):
tractography.connect([(dtifit, fa, [("tensor_fitted", "in_file")])])
tractography.connect([(fa, analyzeheader_fa, [("fa", "in_file")])])
tractography.connect([(inputnode, analyzeheader_fa, [(('dwi', get_vox_dims), 'voxel_dims'),
(('dwi', get_data_dims), 'data_dims')])])
(('dwi', get_data_dims), 'data_dims')])])
tractography.connect([(fa, fa2nii, [('fa', 'data_file')])])
tractography.connect([(inputnode, fa2nii, [(('dwi', get_affine), 'affine')])])
tractography.connect([(analyzeheader_fa, fa2nii, [('header', 'header_file')])])
Expand All @@ -277,7 +277,7 @@ def get_affine(volume):
tractography.connect([(dtifit, trace, [("tensor_fitted", "in_file")])])
tractography.connect([(trace, analyzeheader_trace, [("trace", "in_file")])])
tractography.connect([(inputnode, analyzeheader_trace, [(('dwi', get_vox_dims), 'voxel_dims'),
(('dwi', get_data_dims), 'data_dims')])])
(('dwi', get_data_dims), 'data_dims')])])
tractography.connect([(trace, trace2nii, [('trace', 'data_file')])])
tractography.connect([(inputnode, trace2nii, [(('dwi', get_affine), 'affine')])])
tractography.connect([(analyzeheader_trace, trace2nii, [('header', 'header_file')])])
Expand All @@ -287,10 +287,10 @@ def get_affine(volume):
tractography.connect([(trackpico, cam2trk_pico, [('tracked', 'in_file')])])
tractography.connect([(trackdt, cam2trk_dt, [('tracked', 'in_file')])])
tractography.connect([(inputnode, cam2trk_pico, [(('dwi', get_vox_dims), 'voxel_dims'),
(('dwi', get_data_dims), 'data_dims')])])
(('dwi', get_data_dims), 'data_dims')])])

tractography.connect([(inputnode, cam2trk_dt, [(('dwi', get_vox_dims), 'voxel_dims'),
(('dwi', get_data_dims), 'data_dims')])])
(('dwi', get_data_dims), 'data_dims')])])


"""
Expand All @@ -303,9 +303,9 @@ def get_affine(volume):
workflow.base_dir = os.path.abspath('camino_dti_tutorial')
workflow.connect([(infosource, datasource, [('subject_id', 'subject_id')]),
(datasource, tractography, [('dwi', 'inputnode.dwi'),
('bvals', 'inputnode.bvals'),
('bvecs', 'inputnode.bvecs')
])
('bvals', 'inputnode.bvals'),
('bvecs', 'inputnode.bvecs')
])
])
"""
The following functions run the whole workflow and produce a .dot and .png graph of the processing pipeline.
Expand Down
16 changes: 8 additions & 8 deletions examples/dmri_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def select_aparc_annot(list_of_files):
mapping.connect([(dtifit, fa, [("tensor_fitted", "in_file")])])
mapping.connect([(fa, analyzeheader_fa, [("fa", "in_file")])])
mapping.connect([(inputnode, analyzeheader_fa, [(('dwi', get_vox_dims), 'voxel_dims'),
(('dwi', get_data_dims), 'data_dims')])])
(('dwi', get_data_dims), 'data_dims')])])
mapping.connect([(fa, fa2nii, [('fa', 'data_file')])])
mapping.connect([(inputnode, fa2nii, [(('dwi', get_affine), 'affine')])])
mapping.connect([(analyzeheader_fa, fa2nii, [('header', 'header_file')])])
Expand All @@ -473,7 +473,7 @@ def select_aparc_annot(list_of_files):
mapping.connect([(dtifit, trace, [("tensor_fitted", "in_file")])])
mapping.connect([(trace, analyzeheader_trace, [("trace", "in_file")])])
mapping.connect([(inputnode, analyzeheader_trace, [(('dwi', get_vox_dims), 'voxel_dims'),
(('dwi', get_data_dims), 'data_dims')])])
(('dwi', get_data_dims), 'data_dims')])])
mapping.connect([(trace, trace2nii, [('trace', 'data_file')])])
mapping.connect([(inputnode, trace2nii, [(('dwi', get_affine), 'affine')])])
mapping.connect([(analyzeheader_trace, trace2nii, [('header', 'header_file')])])
Expand All @@ -490,7 +490,7 @@ def select_aparc_annot(list_of_files):
(camino2trackvis, trk2camino, [['trackvis', 'in_file']])
])
mapping.connect([(inputnode, camino2trackvis, [(('dwi', get_vox_dims), 'voxel_dims'),
(('dwi', get_data_dims), 'data_dims')])])
(('dwi', get_data_dims), 'data_dims')])])

"""
Here the CMTK connectivity mapping nodes are connected.
Expand Down Expand Up @@ -571,11 +571,11 @@ def select_aparc_annot(list_of_files):
connectivity.connect([
(infosource, datasource, [('subject_id', 'subject_id')]),
(datasource, mapping, [('dwi', 'inputnode.dwi'),
('bvals', 'inputnode.bvals'),
('bvecs', 'inputnode.bvecs')
]),
(infosource, mapping, [('subject_id', 'inputnode.subject_id')])
])
('bvals', 'inputnode.bvals'),
('bvecs', 'inputnode.bvecs')
]),
(infosource, mapping, [('subject_id', 'inputnode.subject_id')])
])

"""
The following functions run the whole workflow and produce graphs describing the processing pipeline.
Expand Down
13 changes: 7 additions & 6 deletions examples/dmri_connectivity_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
import nipype.interfaces.cmtk as cmtk
import nipype.interfaces.dipy as dipy
import inspect
import os, os.path as op # system functions
import os
import os.path as op # system functions
from nipype.workflows.dmri.fsl.dti import create_eddy_correct_pipeline
from nipype.workflows.dmri.camino.connectivity_mapping import select_aparc_annot
from nipype.utils.misc import package_check
Expand Down Expand Up @@ -580,11 +581,11 @@
connectivity.connect([
(infosource, datasource, [('subject_id', 'subject_id')]),
(datasource, mapping, [('dwi', 'inputnode.dwi'),
('bvals', 'inputnode.bvals'),
('bvecs', 'inputnode.bvecs')
]),
(infosource, mapping, [('subject_id', 'inputnode.subject_id')])
])
('bvals', 'inputnode.bvals'),
('bvecs', 'inputnode.bvecs')
]),
(infosource, mapping, [('subject_id', 'inputnode.subject_id')])
])

"""
The following functions run the whole workflow and produce a .dot and .png graph of the processing pipeline.
Expand Down
Loading