Skip to content

Commit

Permalink
Fix pycodestyle E305 using autopep8 (scipy#8391)
Browse files Browse the repository at this point in the history
* Fix pycodestyle E305 using autopep8

Using pycodestyle v2.3.1 (successor to the tool pep8) to check
coding style, there were hundreds of cases of:

E305 expected 2 blank lines after class or function definition

These were fixed using:

autopep8 --select E305 --in-place ...

This would close issue scipy#8388, cross reference scipy#8384 for updating
TravisCI to use pycodestyle inplace of pep8 for style checks.

* TravisCI/tox can now enforce pep8 E305
  • Loading branch information
peterjc authored and perimosocordiae committed Feb 25, 2018
1 parent 5bb3190 commit 80e76d4
Show file tree
Hide file tree
Showing 83 changed files with 387 additions and 1 deletion.
1 change: 1 addition & 0 deletions benchmarks/benchmarks/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def time_build(self, mnr, cls_name):
else:
self.cls(self.data)


LEAF_SIZES = [8, 128]
BOX_SIZES = [None, 0.0, 1.0]

Expand Down
1 change: 1 addition & 0 deletions benchmarks/benchmarks/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def der(self, coords):
2. * (2.625 - x + x * y**3) * (3. * x * y**2))
return np.array([dfdx, dfdy])


"""
Global Test functions for minimizers.
Expand Down
1 change: 1 addition & 0 deletions doc/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ def process_tex(lines):
new_lines.append(line)
return new_lines


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ def main():
plt.colorbar()
plt.show()


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions doc/source/tutorial/stats/plots/kde_plot2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def my_kde_bandwidth(obj, fac=1./5):
"""We use Scott's Rule, multiplied by a constant factor."""
return np.power(obj.n, -1./(obj.d+4)) * fac


fig = plt.figure()
ax = fig.add_subplot(111)

Expand Down
1 change: 1 addition & 0 deletions doc/source/tutorial/stats/plots/kde_plot5.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def measure(n):
m2 = np.random.normal(scale=0.5, size=n)
return m1+m2, m1-m2


m1, m2 = measure(2000)
xmin = m1.min()
xmax = m1.max()
Expand Down
1 change: 1 addition & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ def gcov_reset_counters():
# LCOV support
#


LCOV_OUTPUT_FILE = os.path.join(ROOT_DIR, 'build', 'lcov.out')
LCOV_HTML_DIR = os.path.join(ROOT_DIR, 'build', 'lcov')

Expand Down
2 changes: 2 additions & 0 deletions scipy/_lib/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def getargspec(f):
spec = getfullargspec(f)
return ArgSpec(spec.args, spec.varargs, spec.varkw, spec.defaults)


DEF = re.compile(r'\s*def\s*([_\w][_\w\d]*)\s*\(')


Expand Down Expand Up @@ -282,6 +283,7 @@ def __call__(self, func):
func, "with _self_: return _func_(%(shortsignature)s)",
dict(_self_=self, _func_=func), __wrapped__=func)


init = getfullargspec(_GeneratorContextManager.__init__)
n_args = len(init.args)
if n_args == 2 and not init.varargs: # (self, genobj) Python 2.7
Expand Down
3 changes: 3 additions & 0 deletions scipy/cluster/vq.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def py_vq(obs, code_book, check_finite=True):
min_dist = dist[np.arange(len(code)), code]
return code, min_dist


# py_vq2 was equivalent to py_vq
py_vq2 = np.deprecate(py_vq, old_name='py_vq2', new_name='py_vq')

Expand Down Expand Up @@ -515,6 +516,7 @@ def _krandinit(data, k):
x += mu
return x


_valid_init_meth = {'random': _krandinit, 'points': _kpoints}


Expand All @@ -529,6 +531,7 @@ def _missing_raise():
raise ClusterError("One of the clusters is empty. "
"Re-run kmeans with a different initialization.")


_valid_miss_meth = {'warn': _missing_warn, 'raise': _missing_raise}


Expand Down
1 change: 1 addition & 0 deletions scipy/constants/codata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,7 @@ def find(sub=None, disp=False):
else:
return result


# Table is lacking some digits for exact values: calculate from definition
c = value('speed of light in vacuum')
mu0 = 4e-7 * pi
Expand Down
1 change: 1 addition & 0 deletions scipy/fftpack/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def _fake_cfftnd(x, shape, *a, **kw):
else:
return _fftpack.zfftnd(x, shape, *a, **kw).astype(numpy.complex64)


_DTYPE_TO_FFT = {
# numpy.dtype(numpy.float32): _fftpack.crfft,
numpy.dtype(numpy.float32): _fake_crfft,
Expand Down
17 changes: 17 additions & 0 deletions scipy/fftpack/pseudo_diffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def kernel(k,order=order,c=c):
overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,swap_real_imag=order % 2,
overwrite_x=overwrite_x)


del _cache


Expand Down Expand Up @@ -146,6 +148,8 @@ def kernel(k, h=h):

overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)


del _cache


Expand Down Expand Up @@ -186,6 +190,8 @@ def kernel(k,h=h):
_cache[(n,h)] = omega
overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)


del _cache


Expand Down Expand Up @@ -251,6 +257,8 @@ def kernel(k):
_cache[n] = omega
overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)


del _cache


Expand Down Expand Up @@ -323,6 +331,8 @@ def kernel(k,a=a,b=b):
_cache[(n,a,b)] = omega
overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)


del _cache


Expand Down Expand Up @@ -377,6 +387,8 @@ def kernel(k,a=a,b=b):
_cache[(n,a,b)] = omega
overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,swap_real_imag=1,overwrite_x=overwrite_x)


del _cache


Expand Down Expand Up @@ -430,6 +442,8 @@ def kernel(k,a=a,b=b):
_cache[(n,a,b)] = omega
overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,overwrite_x=overwrite_x)


del _cache


Expand Down Expand Up @@ -485,6 +499,8 @@ def kernel(k,a=a,b=b):
_cache[(n,a,b)] = omega
overwrite_x = _datacopied(tmp, x)
return convolve.convolve(tmp,omega,overwrite_x=overwrite_x)


del _cache


Expand Down Expand Up @@ -537,4 +553,5 @@ def kernel_imag(k,a=a):
return convolve.convolve_z(tmp,omega_real,omega_imag,
overwrite_x=overwrite_x)


del _cache
1 change: 1 addition & 0 deletions scipy/fftpack/tests/gen_fftw_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def gen_data(dt):

return arrays


# generate single precision data
data = gen_data(np.float32)
filename = 'fftw_single_ref'
Expand Down
1 change: 1 addition & 0 deletions scipy/integrate/odepack.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class ODEintWarning(Warning):
pass


_msgs = {2: "Integration successful.",
1: "Nothing was done; the integration time was 0.",
-1: "Excess work done on this call (perhaps wrong Dfun type).",
Expand Down
2 changes: 2 additions & 0 deletions scipy/integrate/quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def _cached_roots_legendre(n):

_cached_roots_legendre.cache[n] = roots_legendre(n)
return _cached_roots_legendre.cache[n]


_cached_roots_legendre.cache = dict()


Expand Down
2 changes: 2 additions & 0 deletions scipy/interpolate/_fitpack_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def splprep(x, w=None, u=None, ub=None, ue=None, k=3, task=0, s=None, t=None,
else:
return tcku


_curfit_cache = {'t': array([], float), 'wrk': array([], float),
'iwrk': array([], intc)}

Expand Down Expand Up @@ -792,6 +793,7 @@ def spalde(x, tck):
# def _curfit(x,y,w=None,xb=None,xe=None,k=3,task=0,s=None,t=None,
# full_output=0,nest=None,per=0,quiet=1):


_surfit_cache = {'tx': array([], float), 'ty': array([], float),
'wrk': array([], float), 'iwrk': array([], intc)}

Expand Down
1 change: 1 addition & 0 deletions scipy/interpolate/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def configuration(parent_package='',top_path=None):

return config


if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
1 change: 1 addition & 0 deletions scipy/interpolate/tests/test_polyint.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def check_shape(interpolator_cls, x_shape, y_shape, deriv_shape=None, axis=0,
yi, y = np.broadcast_arrays(yi, yv)
assert_allclose(yi, y)


SHAPES = [(), (0,), (1,), (6, 2, 5)]


Expand Down
1 change: 1 addition & 0 deletions scipy/io/arff/arffread.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ def test_weka(filename):
for i in meta:
print_attribute(i, meta[i], data[i])


# make sure nose does not find this as a test
test_weka.__test__ = False

Expand Down
1 change: 1 addition & 0 deletions scipy/io/arff/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def configuration(parent_package='io',top_path=None):
config.add_data_dir('tests')
return config


if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
1 change: 1 addition & 0 deletions scipy/io/harwell_boeing/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def configuration(parent_package='',top_path=None):

return config


if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
1 change: 1 addition & 0 deletions scipy/io/matlab/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def configuration(parent_package='io',top_path=None):
config.add_data_dir('tests')
return config


if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
1 change: 1 addition & 0 deletions scipy/io/matlab/tests/test_mio.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def mlarr(*args, **kwargs):
arr.shape = matdims(arr)
return arr


# Define cases to test
theta = np.pi/4*np.arange(9,dtype=float).reshape(1,9)
case_table4 = [
Expand Down
1 change: 1 addition & 0 deletions scipy/io/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def configuration(parent_package='',top_path=None):
config.add_subpackage('harwell_boeing')
return config


if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
1 change: 1 addition & 0 deletions scipy/linalg/_cython_signature_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def sigs_from_dir(directory, outfile, manual_wrappers=None, exclusions=None):
# The other manual signatures are used because the signature generating
# functions don't work when function pointer arguments are used.


lapack_manual_wrappers = '''void cgees(char *jobvs, char *sort, cselect1 *select, int *n, c *a, int *lda, int *sdim, c *w, c *vs, int *ldvs, c *work, int *lwork, s *rwork, bint *bwork, int *info)
void cgeesx(char *jobvs, char *sort, cselect1 *select, char *sense, int *n, c *a, int *lda, int *sdim, c *w, c *vs, int *ldvs, s *rconde, s *rcondv, c *work, int *lwork, s *rwork, bint *bwork, int *info)
void cgges(char *jobvsl, char *jobvsr, char *sort, cselect2 *selctg, int *n, c *a, int *lda, c *b, int *ldb, int *sdim, c *alpha, c *beta, c *vsl, int *ldvsl, c *vsr, int *ldvsr, c *work, int *lwork, s *rwork, bint *bwork, int *info)
Expand Down
Loading

0 comments on commit 80e76d4

Please sign in to comment.