diff options
-rw-r--r-- | numpy/core/defmatrix.py | 2 | ||||
-rw-r--r-- | numpy/core/fromnumeric.py | 5 | ||||
-rw-r--r-- | numpy/core/ma.py | 2 | ||||
-rw-r--r-- | numpy/core/setup.py | 3 | ||||
-rw-r--r-- | numpy/ctypeslib.py | 2 | ||||
-rw-r--r-- | numpy/f2py/auxfuncs.py | 1 | ||||
-rw-r--r-- | numpy/fft/helper.py | 2 | ||||
-rw-r--r-- | numpy/fft/setup.py | 1 | ||||
-rw-r--r-- | numpy/lib/convdtype.py | 2 | ||||
-rw-r--r-- | numpy/lib/function_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/index_tricks.py | 3 | ||||
-rw-r--r-- | numpy/lib/polynomial.py | 2 | ||||
-rw-r--r-- | numpy/lib/setup.py | 8 | ||||
-rw-r--r-- | numpy/lib/shape_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/twodim_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/utils.py | 6 | ||||
-rw-r--r-- | numpy/linalg/linalg.py | 6 | ||||
-rw-r--r-- | numpy/linalg/setup.py | 2 | ||||
-rw-r--r-- | numpy/oldnumeric/compat.py | 5 | ||||
-rw-r--r-- | numpy/oldnumeric/random_array.py | 48 |
20 files changed, 43 insertions, 63 deletions
diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py index e64fd8c6d..58460265a 100644 --- a/numpy/core/defmatrix.py +++ b/numpy/core/defmatrix.py @@ -2,7 +2,6 @@ __all__ = ['matrix', 'bmat', 'mat', 'asmatrix'] import numeric as N from numeric import concatenate, isscalar, binary_repr -import types import string as str_ import sys @@ -238,6 +237,7 @@ class matrix(N.ndarray): over all dimensions. This preserves the orientation of the result as a row or column. """ + # FIXME: should out=None be used here, or should it just be out? return N.ndarray.sum(self, axis, dtype, out=None)._align(axis) def mean(self, axis=None, out=None): diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index e80006a15..1f84a7b18 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -14,10 +14,7 @@ __all__ = ['take', 'reshape', 'choose', 'repeat', 'put', import multiarray as mu import umath as um import numerictypes as nt -from numeric import asarray, array, asanyarray, correlate, outer, concatenate -from umath import sign, absolute, multiply -import numeric as _nx -import sys +from numeric import asarray, array, asanyarray, concatenate _dt_ = nt.sctype2char import types diff --git a/numpy/core/ma.py b/numpy/core/ma.py index fc1e89d7b..420cbd72d 100644 --- a/numpy/core/ma.py +++ b/numpy/core/ma.py @@ -1683,7 +1683,6 @@ def average (a, axis=None, weights=None, returned = 0): d = add.reduce(w, axis) del w elif wsh == (ash[axis],): - ni = ash[axis] r = [newaxis]*len(ash) r[axis] = slice(None, None, 1) w = eval ("w["+ repr(tuple(r)) + "] * ones(ash, float)") @@ -1708,7 +1707,6 @@ def average (a, axis=None, weights=None, returned = 0): n = add.reduce(a*w, axis) d = add.reduce(w, axis) elif wsh == (ash[axis],): - ni = ash[axis] r = [newaxis]*len(ash) r[axis] = slice(None, None, 1) w = eval ("w["+ repr(tuple(r)) + "] * masked_array(ones(ash, float), mask)") diff --git a/numpy/core/setup.py b/numpy/core/setup.py index ac13f10c8..70dcd5480 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -2,8 +2,7 @@ import imp import os import sys from os.path import join -from glob import glob -from distutils.dep_util import newer,newer_group +from distutils.dep_util import newer FUNCTIONS_TO_CHECK = [ ('expl', 'HAVE_LONGDOUBLE_FUNCS'), diff --git a/numpy/ctypeslib.py b/numpy/ctypeslib.py index 81a25bb92..82f6a91df 100644 --- a/numpy/ctypeslib.py +++ b/numpy/ctypeslib.py @@ -2,7 +2,7 @@ __all__ = ['load_library', 'ndpointer', 'test', 'ctypes_load_library', 'c_intp'] import sys, os -from numpy import integer, product, ndarray, dtype as _dtype, deprecate +from numpy import integer, ndarray, dtype as _dtype, deprecate from numpy.core.multiarray import _flagdict, flagsobj try: diff --git a/numpy/f2py/auxfuncs.py b/numpy/f2py/auxfuncs.py index b7e5aec68..b097cc3b0 100644 --- a/numpy/f2py/auxfuncs.py +++ b/numpy/f2py/auxfuncs.py @@ -228,7 +228,6 @@ def containscommon(rout): def containsmodule(block): if ismodule(block): return 1 if not hasbody(block): return 0 - ret = [] for b in block['body']: if containsmodule(b): return 1 return 0 diff --git a/numpy/fft/helper.py b/numpy/fft/helper.py index 99b576708..17a4a24dc 100644 --- a/numpy/fft/helper.py +++ b/numpy/fft/helper.py @@ -6,7 +6,7 @@ Discrete Fourier Transforms - helper.py __all__ = ['fftshift','ifftshift','fftfreq'] from numpy.core import asarray, concatenate, arange, take, \ - array, integer + integer from numpy import hstack import types diff --git a/numpy/fft/setup.py b/numpy/fft/setup.py index 4d1de069d..82763b70a 100644 --- a/numpy/fft/setup.py +++ b/numpy/fft/setup.py @@ -1,5 +1,4 @@ -from os.path import join def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration diff --git a/numpy/lib/convdtype.py b/numpy/lib/convdtype.py index ffef92e1c..ebc1ba512 100644 --- a/numpy/lib/convdtype.py +++ b/numpy/lib/convdtype.py @@ -1,6 +1,5 @@ from tokenize import generate_tokens import token -from StringIO import StringIO import sys def insert(s1, s2, posn): """insert s1 into s2 at positions posn @@ -17,6 +16,7 @@ def insert(s1, s2, posn): def insert_dtype(readline, output=None): """ + >>> from StringIO import StringIO >>> src = "zeros((2,3), dtype=float); zeros((2,3));" >>> insert_dtype(StringIO(src).readline) zeros((2,3), dtype=float); zeros((2,3), dtype=int); diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 1b79afc25..d7ba85add 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -639,7 +639,7 @@ def trim_zeros(filt, trim='fb'): import sys if sys.hexversion < 0x2040000: - from sets import Set as set + from sets import Set as set def unique(x): """Return sorted unique items from an array or sequence. diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index e64d5dcd4..8ac065c47 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -8,7 +8,6 @@ __all__ = ['unravel_index', 'ndenumerate','ndindex'] import sys -import types import numpy.core.numeric as _nx from numpy.core.numeric import asarray, ScalarType, array @@ -319,8 +318,6 @@ class r_class(concatenator): r_ = r_class() -import warnings - class c_class(concatenator): """Translates slice objects to concatenation along the second axis. diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 9aea4ef12..7026aeb67 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -650,3 +650,5 @@ class poly1d(object): # Stuff to do on module import warnings.simplefilter('always',RankWarning) + + diff --git a/numpy/lib/setup.py b/numpy/lib/setup.py index 0bd3c6ceb..ca228ceef 100644 --- a/numpy/lib/setup.py +++ b/numpy/lib/setup.py @@ -1,15 +1,9 @@ -import imp -import os from os.path import join -from glob import glob -from distutils.dep_util import newer,newer_group def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration,dot_join - from numpy.distutils.system_info import get_info + from numpy.distutils.misc_util import Configuration config = Configuration('lib',parent_package,top_path) - local_dir = config.local_path config.add_include_dirs(join('..','core','include')) diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index 250525f76..cb15a2760 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -568,7 +568,7 @@ def kron(a,b): nd = nda result = outer(a,b).reshape(as_+bs) axis = nd-1 - for k in xrange(nd): + for _ in xrange(nd): result = concatenate(result, axis=axis) if wrapper is not None: result = wrapper(result) diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py index fd2ff586a..7904eae30 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -5,7 +5,7 @@ __all__ = ['diag','diagflat','eye','fliplr','flipud','rot90','tri','triu', 'tril','vander','histogram2d'] -from numpy.core.numeric import asanyarray, int_, equal, subtract, arange, \ +from numpy.core.numeric import asanyarray, equal, subtract, arange, \ zeros, arange, greater_equal, multiply, ones, asarray def fliplr(m): diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index e50679eaa..d16dd8a78 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -1,8 +1,8 @@ -import sys, os +import sys import inspect import types -from numpy.core.numerictypes import obj2sctype, integer, generic -from numpy.core.multiarray import dtype as _dtype, _flagdict, flagsobj +from numpy.core.numerictypes import obj2sctype, generic +from numpy.core.multiarray import dtype as _dtype from numpy.core import product, ndarray __all__ = ['issubclass_', 'get_numpy_include', 'issubsctype', diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index a8ac3e7f8..7f3725e0c 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -20,8 +20,8 @@ from numpy.core import array, asarray, zeros, empty, transpose, \ intc, single, double, csingle, cdouble, inexact, complexfloating, \ newaxis, ravel, all, Inf, dot, add, multiply, identity, sqrt, \ maximum, flatnonzero, diagonal, arange, fastCopyAndTranspose, sum, \ - argsort, isfinite -from numpy.lib import triu, iterable + isfinite +from numpy.lib import triu from numpy.linalg import lapack_lite fortran_int = intc @@ -113,7 +113,7 @@ def _fastCopyAndTranspose(type, *arrays): def _assertRank2(*arrays): for a in arrays: if len(a.shape) != 2: - raise LinAlgError, 'Array must be two-dimensional' + raise LinAlgError, '%d-dimensional array given. Array must be two-dimensional' % len(a.shape) def _assertSquareness(*arrays): for a in arrays: diff --git a/numpy/linalg/setup.py b/numpy/linalg/setup.py index 432bfc133..eeb83a94e 100644 --- a/numpy/linalg/setup.py +++ b/numpy/linalg/setup.py @@ -1,6 +1,4 @@ -from os.path import join - def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import get_info diff --git a/numpy/oldnumeric/compat.py b/numpy/oldnumeric/compat.py index 1d376dd12..369fa5000 100644 --- a/numpy/oldnumeric/compat.py +++ b/numpy/oldnumeric/compat.py @@ -11,13 +11,10 @@ __all__ = ['NewAxis', import numpy.core.multiarray as multiarray import numpy.core.umath as um -from numpy.core.numeric import array, correlate, outer, cross -from numpy.core.umath import sign, absolute, multiply +from numpy.core.numeric import array, correlate import functions import sys -import types - from cPickle import dump, dumps mu = multiarray diff --git a/numpy/oldnumeric/random_array.py b/numpy/oldnumeric/random_array.py index 84e923e13..0b06ee959 100644 --- a/numpy/oldnumeric/random_array.py +++ b/numpy/oldnumeric/random_array.py @@ -72,30 +72,30 @@ def standard_normal(shape=[]): return mt.standard_normal(shape) def normal(mean, std, shape=[]): - """normal(mean, std, n) or normal(mean, std, [n, m, ...]) returns - array of random numbers randomly distributed with specified mean and - standard deviation""" - if shape == []: - shape = None - return mt.normal(mean, std, shape) + """normal(mean, std, n) or normal(mean, std, [n, m, ...]) returns + array of random numbers randomly distributed with specified mean and + standard deviation""" + if shape == []: + shape = None + return mt.normal(mean, std, shape) def multivariate_normal(mean, cov, shape=[]): - """multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...]) - returns an array containing multivariate normally distributed random numbers - with specified mean and covariance. - - mean must be a 1 dimensional array. cov must be a square two dimensional - array with the same number of rows and columns as mean has elements. - - The first form returns a single 1-D array containing a multivariate - normal. - - The second form returns an array of shape (m, n, ..., cov.shape[0]). - In this case, output[i,j,...,:] is a 1-D array containing a multivariate - normal.""" - if shape == []: - shape = None - return mt.multivariate_normal(mean, cov, shape) + """multivariate_normal(mean, cov) or multivariate_normal(mean, cov, [m, n, ...]) + returns an array containing multivariate normally distributed random numbers + with specified mean and covariance. + + mean must be a 1 dimensional array. cov must be a square two dimensional + array with the same number of rows and columns as mean has elements. + + The first form returns a single 1-D array containing a multivariate + normal. + + The second form returns an array of shape (m, n, ..., cov.shape[0]). + In this case, output[i,j,...,:] is a 1-D array containing a multivariate + normal.""" + if shape == []: + shape = None + return mt.multivariate_normal(mean, cov, shape) def exponential(mean, shape=[]): """exponential(mean, n) or exponential(mean, [n, m, ...]) returns array @@ -195,8 +195,8 @@ def mean_var_test(x, type, mean, var, skew=[]): print "(should be about ", mean, "):", x_mean print "Variance of those random numbers (should be about ", var, "):", x_var if skew != []: - x_skew = (Numeric.sum(x_minus_mean*x_minus_mean*x_minus_mean,axis=0)/9998.)/x_var**(3./2.) - print "Skewness of those random numbers (should be about ", skew, "):", x_skew + x_skew = (Numeric.sum(x_minus_mean*x_minus_mean*x_minus_mean,axis=0)/9998.)/x_var**(3./2.) + print "Skewness of those random numbers (should be about ", skew, "):", x_skew def test(): obj = mt.get_state() |