From dec6658cdc10a23ad0e733fb52a814306033d88c Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 30 Jul 2014 16:48:11 -0600 Subject: MAINT: Fixes for problems in numpy/lib revealed by pyflakes. Some of those problems look like potential coding errors. In those cases a Fixme comment was made and the offending code, usually an unused variable, was commented out. --- numpy/lib/function_base.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 00bfab6ba..3d8ffc586 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1,15 +1,5 @@ from __future__ import division, absolute_import, print_function -__docformat__ = "restructuredtext en" -__all__ = [ - 'select', 'piecewise', 'trim_zeros', 'copy', 'iterable', 'percentile', - 'diff', 'gradient', 'angle', 'unwrap', 'sort_complex', 'disp', - 'extract', 'place', 'vectorize', 'asarray_chkfinite', 'average', - 'histogram', 'histogramdd', 'bincount', 'digitize', 'cov', 'corrcoef', - 'msort', 'median', 'sinc', 'hamming', 'hanning', 'bartlett', - 'blackman', 'kaiser', 'trapz', 'i0', 'add_newdoc', 'add_docstring', - 'meshgrid', 'delete', 'insert', 'append', 'interp', 'add_newdoc_ufunc'] - import warnings import sys import collections @@ -20,21 +10,21 @@ import numpy.core.numeric as _nx from numpy.core import linspace, atleast_1d, atleast_2d from numpy.core.numeric import ( ones, zeros, arange, concatenate, array, asarray, asanyarray, empty, - empty_like, ndarray, around, floor, ceil, take, ScalarType, dot, where, - intp, integer, isscalar + empty_like, ndarray, around, floor, ceil, take, dot, where, intp, + integer, isscalar ) from numpy.core.umath import ( pi, multiply, add, arctan2, frompyfunc, cos, less_equal, sqrt, sin, mod, exp, log10 ) from numpy.core.fromnumeric import ( - ravel, nonzero, choose, sort, partition, mean + ravel, nonzero, sort, partition, mean ) from numpy.core.numerictypes import typecodes, number from numpy.lib.twodim_base import diag +from .utils import deprecate from ._compiled_base import _insert, add_docstring from ._compiled_base import digitize, bincount, interp as compiled_interp -from .utils import deprecate from ._compiled_base import add_newdoc_ufunc from numpy.compat import long @@ -43,6 +33,17 @@ if sys.version_info[0] < 3: range = xrange +__all__ = [ + 'select', 'piecewise', 'trim_zeros', 'copy', 'iterable', 'percentile', + 'diff', 'gradient', 'angle', 'unwrap', 'sort_complex', 'disp', + 'extract', 'place', 'vectorize', 'asarray_chkfinite', 'average', + 'histogram', 'histogramdd', 'bincount', 'digitize', 'cov', 'corrcoef', + 'msort', 'median', 'sinc', 'hamming', 'hanning', 'bartlett', + 'blackman', 'kaiser', 'trapz', 'i0', 'add_newdoc', 'add_docstring', + 'meshgrid', 'delete', 'insert', 'append', 'interp', 'add_newdoc_ufunc' + ] + + def iterable(y): """ Check whether or not an object can be iterated over. -- cgit v1.2.1 From 01b0d7e82211b581aaff925e3ccc36cff9ac1895 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 30 Jul 2014 18:06:28 -0600 Subject: STY: Make files in numpy/lib PEP8 compliant. The rules enforced are the same as those used for scipy. --- numpy/lib/function_base.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 3d8ffc586..0a1d05f77 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -367,8 +367,8 @@ def histogramdd(sample, bins=10, range=None, normed=False, weights=None): Ncount[i] = digitize(sample[:, i], edges[i]) # Using digitize, values that fall on an edge are put in the right bin. - # For the rightmost bin, we want values equal to the right - # edge to be counted in the last bin, and not as an outlier. + # For the rightmost bin, we want values equal to the right edge to be + # counted in the last bin, and not as an outlier. for i in arange(D): # Rounding precision mindiff = dedges[i].min() @@ -376,7 +376,8 @@ def histogramdd(sample, bins=10, range=None, normed=False, weights=None): decimal = int(-log10(mindiff)) + 6 # Find which points are on the rightmost edge. not_smaller_than_edge = (sample[:, i] >= edges[i][-1]) - on_edge = (around(sample[:, i], decimal) == around(edges[i][-1], decimal)) + on_edge = (around(sample[:, i], decimal) == + around(edges[i][-1], decimal)) # Shift these points one bin to the left. Ncount[i][where(on_edge & not_smaller_than_edge)[0]] -= 1 @@ -1622,6 +1623,7 @@ class vectorize(object): further degrades performance. """ + def __init__(self, pyfunc, otypes='', doc=None, excluded=None, cache=False): self.pyfunc = pyfunc @@ -3375,7 +3377,7 @@ def meshgrid(*xi, **kwargs): raise TypeError("meshgrid() got an unexpected keyword argument '%s'" % (list(kwargs)[0],)) - if not indexing in ['xy', 'ij']: + if indexing not in ['xy', 'ij']: raise ValueError( "Valid values for `indexing` are 'xy' and 'ij'.") @@ -3436,7 +3438,7 @@ def delete(arr, obj, axis=None): Notes ----- Often it is preferable to use a boolean mask. For example: - + >>> mask = np.ones(len(arr), dtype=bool) >>> mask[[0,2,4]] = False >>> result = arr[mask,...] -- cgit v1.2.1