diff options
Diffstat (limited to 'numpy/oldnumeric')
-rw-r--r-- | numpy/oldnumeric/__init__.py | 3 | ||||
-rw-r--r-- | numpy/oldnumeric/alter_code1.py | 8 | ||||
-rw-r--r-- | numpy/oldnumeric/alter_code2.py | 4 | ||||
-rw-r--r-- | numpy/oldnumeric/compat.py | 5 | ||||
-rw-r--r-- | numpy/oldnumeric/fix_default_axis.py | 6 | ||||
-rw-r--r-- | numpy/oldnumeric/functions.py | 9 | ||||
-rw-r--r-- | numpy/oldnumeric/linear_algebra.py | 9 | ||||
-rw-r--r-- | numpy/oldnumeric/matrix.py | 4 | ||||
-rw-r--r-- | numpy/oldnumeric/misc.py | 2 | ||||
-rw-r--r-- | numpy/oldnumeric/mlab.py | 9 | ||||
-rw-r--r-- | numpy/oldnumeric/precision.py | 28 | ||||
-rw-r--r-- | numpy/oldnumeric/random_array.py | 4 | ||||
-rw-r--r-- | numpy/oldnumeric/rng.py | 12 | ||||
-rw-r--r-- | numpy/oldnumeric/tests/test_oldnumeric.py | 2 | ||||
-rw-r--r-- | numpy/oldnumeric/typeconv.py | 3 | ||||
-rw-r--r-- | numpy/oldnumeric/ufuncs.py | 1 |
16 files changed, 49 insertions, 60 deletions
diff --git a/numpy/oldnumeric/__init__.py b/numpy/oldnumeric/__init__.py index dbf4298c5..83819ad04 100644 --- a/numpy/oldnumeric/__init__.py +++ b/numpy/oldnumeric/__init__.py @@ -1,4 +1,3 @@ - # Don't add these to the __all__ variable though from numpy import * @@ -34,7 +33,7 @@ __all__ += precision.__all__ __all__ += functions.__all__ __all__ += ufuncs.__all__ __all__ += misc.__all__ - + del compat del functions del precision diff --git a/numpy/oldnumeric/alter_code1.py b/numpy/oldnumeric/alter_code1.py index 73878de3f..87538a855 100644 --- a/numpy/oldnumeric/alter_code1.py +++ b/numpy/oldnumeric/alter_code1.py @@ -52,7 +52,7 @@ for name in _func2: for name in _func4: _astr = r"""(%s\s*[(][^,]*?[,][^,]*?[,][^,]*?[,][^'"]*?['"])b(['"][^)]*?[)])"""%name - func_re[name] = re.compile(_astr, re.DOTALL) + func_re[name] = re.compile(_astr, re.DOTALL) for name in _meth1: _astr = r"""(.%s\s*[(][^'"]*?['"])b(['"][^)]*?[)])"""%name @@ -143,7 +143,7 @@ def fromstr(filestr): filestr, fromall1 = changeimports(filestr, 'ArrayPrinter', 'numpy.oldnumeric.array_printer') filestr, fromall2 = changeimports(filestr, 'numerix', 'numpy.oldnumeric') filestr, fromall3 = changeimports(filestr, 'scipy_base', 'numpy.oldnumeric') - filestr, fromall3 = changeimports(filestr, 'Matrix', 'numpy.oldnumeric.matrix') + filestr, fromall3 = changeimports(filestr, 'Matrix', 'numpy.oldnumeric.matrix') filestr, fromall3 = changeimports(filestr, 'MLab', 'numpy.oldnumeric.mlab') filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'numpy.oldnumeric.linear_algebra') filestr, fromall3 = changeimports(filestr, 'RNG', 'numpy.oldnumeric.rng') @@ -225,7 +225,7 @@ def convertsrc(direc=os.path.curdir, ext=None, orig=1): else: os.remove(afile) makenewfile(afile, fstr) - + def _func(arg, dirname, fnames): convertall(dirname, orig=0) convertsrc(dirname, ext=['h','c'], orig=0) @@ -234,7 +234,7 @@ def converttree(direc=os.path.curdir): """Convert all .py files and source code files in the tree given """ os.path.walk(direc, _func, None) - + if __name__ == '__main__': fromargs(sys.argv) diff --git a/numpy/oldnumeric/alter_code2.py b/numpy/oldnumeric/alter_code2.py index 6db8fe3e2..baa6b9d26 100644 --- a/numpy/oldnumeric/alter_code2.py +++ b/numpy/oldnumeric/alter_code2.py @@ -30,7 +30,7 @@ import os import re import glob -# To convert typecharacters we need to +# To convert typecharacters we need to # Not very safe. Disabled for now.. def replacetypechars(astr): astr = astr.replace("'s'","'h'") @@ -140,7 +140,7 @@ def converttree(direc=os.path.curdir): """Convert all .py files in the tree given """ - os.path.walk(direc, _func, None) + os.path.walk(direc, _func, None) if __name__ == '__main__': fromargs(sys.argv) diff --git a/numpy/oldnumeric/compat.py b/numpy/oldnumeric/compat.py index 42a98631f..1d376dd12 100644 --- a/numpy/oldnumeric/compat.py +++ b/numpy/oldnumeric/compat.py @@ -2,7 +2,7 @@ __all__ = ['NewAxis', 'UFuncType', 'UfuncType', 'ArrayType', 'arraytype', - 'LittleEndian', 'arrayrange', 'matrixmultiply', + 'LittleEndian', 'arrayrange', 'matrixmultiply', 'array_constructor', 'pickle_array', 'DumpArray', 'LoadArray', 'multiarray', # from cPickle @@ -34,7 +34,7 @@ arraytype = mu.ndarray LittleEndian = (sys.byteorder == 'little') -from numpy import deprecate +from numpy import deprecate # backward compatibility arrayrange = deprecate(functions.arange, 'arrayrange', 'arange') @@ -67,4 +67,3 @@ def pickle_array(a): else: return (array_constructor, (a.shape, a.dtype.char, a.tostring(), LittleEndian)) - diff --git a/numpy/oldnumeric/fix_default_axis.py b/numpy/oldnumeric/fix_default_axis.py index 15054b50c..8483de85e 100644 --- a/numpy/oldnumeric/fix_default_axis.py +++ b/numpy/oldnumeric/fix_default_axis.py @@ -52,7 +52,7 @@ _all = _func0 + _funcm1 func_re = {} for name in _all: - _astr = r"""%s\s*[(]"""%name + _astr = r"""%s\s*[(]"""%name func_re[name] = re.compile(_astr) @@ -142,7 +142,7 @@ def _import_change(fstr, names): fstr = "%s%s%s" % (fstr[:ind], "import numpy.oldnumeric as numpy", fstr[ind+len(importstr):]) num += 1 - + # case 2 importre = re.compile("""import numpy as ([A-Za-z0-9_]+)""") modules = importre.findall(fstr) @@ -230,7 +230,7 @@ def add_axis(fstr, import_change=False): return fstr, total else: fstr, num = _import_change(fstr, _funcm1+_func0) - return fstr, num + return fstr, num def makenewfile(name, filestr): diff --git a/numpy/oldnumeric/functions.py b/numpy/oldnumeric/functions.py index 7d6d8abfa..1f09d8f84 100644 --- a/numpy/oldnumeric/functions.py +++ b/numpy/oldnumeric/functions.py @@ -44,10 +44,10 @@ def argmin(x, axis=-1): def compress(condition, m, axis=-1): return N.compress(condition, m, axis) - + def fromfunction(args, dimensions): return N.fromfunction(args, dimensions, dtype=int) - + def ones(shape, typecode='l', savespace=0, dtype=None): """ones(shape, dtype=int) returns an array of the given dimensions which is initialized to all ones. @@ -61,7 +61,7 @@ def zeros(shape, typecode='l', savespace=0, dtype=None): """zeros(shape, dtype=int) returns an array of the given dimensions which is initialized to all zeros """ - dtype = convtypecode(typecode,dtype) + dtype = convtypecode(typecode,dtype) return mu.zeros(shape, dtype) def identity(n,typecode='l', dtype=None): @@ -71,7 +71,7 @@ def identity(n,typecode='l', dtype=None): return nn.identity(n, dtype) def empty(shape, typecode='l', dtype=None): - dtype = convtypecode(typecode, dtype) + dtype = convtypecode(typecode, dtype) return mu.empty(shape, dtype) def array(sequence, typecode=None, copy=1, savespace=0, dtype=None): @@ -122,4 +122,3 @@ def cross_product(a, b, axis1=-1, axis2=-1): def average(a, axis=0, weights=None, returned=False): return N.average(a, axis, weights, returned) - diff --git a/numpy/oldnumeric/linear_algebra.py b/numpy/oldnumeric/linear_algebra.py index 90d6f7138..2e7a264fe 100644 --- a/numpy/oldnumeric/linear_algebra.py +++ b/numpy/oldnumeric/linear_algebra.py @@ -1,4 +1,3 @@ - """Backward compatible with LinearAlgebra from Numeric """ # This module is a lite version of the linalg.py module in SciPy which contains @@ -7,10 +6,10 @@ # zgeev, dgesdd, zgesdd, dgelsd, zgelsd, dsyevd, zheevd, dgetrf, dpotrf. -__all__ = ['LinAlgError', 'solve_linear_equations', +__all__ = ['LinAlgError', 'solve_linear_equations', 'inverse', 'cholesky_decomposition', 'eigenvalues', - 'Heigenvalues', 'generalized_inverse', - 'determinant', 'singular_value_decomposition', + 'Heigenvalues', 'generalized_inverse', + 'determinant', 'singular_value_decomposition', 'eigenvectors', 'Heigenvectors', 'linear_least_squares' ] @@ -52,7 +51,7 @@ def eigenvectors(A): def Heigenvectors(A): w, v = linalg.eigh(A) return w, transpose(v) - + # Generalized inverse def generalized_inverse(a, rcond = 1.e-10): diff --git a/numpy/oldnumeric/matrix.py b/numpy/oldnumeric/matrix.py index 321d8d4df..7c5b3700c 100644 --- a/numpy/oldnumeric/matrix.py +++ b/numpy/oldnumeric/matrix.py @@ -1,4 +1,4 @@ -# This module is for compatibility only. +# This module is for compatibility only. __all__ = ['UserArray', 'squeeze', 'Matrix', 'asarray', 'dot', 'k', 'Numeric', 'LinearAlgebra', 'identity', 'multiply', 'types', 'string'] @@ -10,7 +10,7 @@ from numpy.oldnumeric import dot, identity, multiply import numpy.oldnumeric.linear_algebra as LinearAlgebra from numpy import matrix as Matrix, squeeze -# Hidden names that will be the same. +# Hidden names that will be the same. _table = [None]*256 for k in range(256): diff --git a/numpy/oldnumeric/misc.py b/numpy/oldnumeric/misc.py index 74a643c64..4b43f3985 100644 --- a/numpy/oldnumeric/misc.py +++ b/numpy/oldnumeric/misc.py @@ -31,7 +31,7 @@ from array_printer import array2string class Unpickler(pickle.Unpickler): def __init__(self, *args, **kwds): - raise NotImplemented + raise NotImplemented def load_array(self): raise NotImplemented diff --git a/numpy/oldnumeric/mlab.py b/numpy/oldnumeric/mlab.py index c7de8a417..c3e125fe3 100644 --- a/numpy/oldnumeric/mlab.py +++ b/numpy/oldnumeric/mlab.py @@ -13,7 +13,7 @@ from numpy import tril, trapz as _Ntrapz, hanning, rot90, triu, diff, \ from numpy.linalg import eig, svd from numpy.random import rand, randn import numpy as nn - + from typeconv import convtypecode def eye(N, M=None, k=0, typecode=None, dtype=None): @@ -25,7 +25,7 @@ def eye(N, M=None, k=0, typecode=None, dtype=None): m = nn.equal(nn.subtract.outer(nn.arange(N), nn.arange(M)),-k) if m.dtype != dtype: return m.astype(dtype) - + def tri(N, M=None, k=0, typecode=None, dtype=None): """ returns a N-by-M array where all the diagonals starting from lower left corner up to the k-th are all ones. @@ -35,7 +35,7 @@ def tri(N, M=None, k=0, typecode=None, dtype=None): m = nn.greater_equal(nn.subtract.outer(nn.arange(N), nn.arange(M)),-k) if m.dtype != dtype: return m.astype(dtype) - + def trapz(y, x=None, axis=-1): return _Ntrapz(y, x, axis=axis) @@ -113,10 +113,9 @@ __all__ += precision.__all__ __all__ += functions.__all__ __all__ += ufuncs.__all__ __all__ += misc.__all__ - + del compat del functions del precision del ufuncs del misc - diff --git a/numpy/oldnumeric/precision.py b/numpy/oldnumeric/precision.py index 8a242f023..f495992a8 100644 --- a/numpy/oldnumeric/precision.py +++ b/numpy/oldnumeric/precision.py @@ -3,7 +3,7 @@ # The character strings are still for "new" NumPy # which is the only Incompatibility with Numeric -__all__ = ['Character', 'Complex', 'Float', +__all__ = ['Character', 'Complex', 'Float', 'PrecisionError', 'PyObject', 'Int', 'UInt', 'UnsignedInteger', 'string', 'typecodes', 'zeros'] @@ -46,25 +46,25 @@ except(PrecisionError): try: UnsignedInt16 = _lookup(_code_table, "UnsignedInteger", 16) UInt16 = UnsignedInt16 - __all__.extend(['UnsignedInt16', 'UInt16']) + __all__.extend(['UnsignedInt16', 'UInt16']) except(PrecisionError): pass try: UnsignedInt32 = _lookup(_code_table, "UnsignedInteger", 32) UInt32 = UnsignedInt32 - __all__.extend(['UnsignedInt32', 'UInt32']) + __all__.extend(['UnsignedInt32', 'UInt32']) except(PrecisionError): pass try: UnsignedInt64 = _lookup(_code_table, "UnsignedInteger", 64) UInt64 = UnsignedInt64 - __all__.extend(['UnsignedInt64', 'UInt64']) + __all__.extend(['UnsignedInt64', 'UInt64']) except(PrecisionError): pass try: UnsignedInt128 = _lookup(_code_table, "UnsignedInteger", 128) UInt128 = UnsignedInt128 - __all__.extend(['UnsignedInt128', 'UInt128']) + __all__.extend(['UnsignedInt128', 'UInt128']) except(PrecisionError): pass UnsignedInteger = 'u' @@ -77,7 +77,7 @@ except(PrecisionError): pass try: Int8 = _lookup(_code_table, 'Integer', 8) - __all__.append('Int8') + __all__.append('Int8') except(PrecisionError): pass try: @@ -109,7 +109,7 @@ except(PrecisionError): pass try: Float8 = _lookup(_code_table, 'Float', 8) - __all__.append('Float8') + __all__.append('Float8') except(PrecisionError): pass try: @@ -119,17 +119,17 @@ except(PrecisionError): pass try: Float32 = _lookup(_code_table, 'Float', 32) - __all__.append('Float32') + __all__.append('Float32') except(PrecisionError): pass try: Float64 = _lookup(_code_table, 'Float', 64) - __all__.append('Float64') + __all__.append('Float64') except(PrecisionError): pass try: Float128 = _lookup(_code_table, 'Float', 128) - __all__.append('Float128') + __all__.append('Float128') except(PrecisionError): pass Float = 'd' @@ -141,22 +141,22 @@ except(PrecisionError): pass try: Complex8 = _lookup(_code_table, 'Complex', 16) - __all__.append('Complex8') + __all__.append('Complex8') except(PrecisionError): pass try: Complex16 = _lookup(_code_table, 'Complex', 32) - __all__.append('Complex16') + __all__.append('Complex16') except(PrecisionError): pass try: Complex32 = _lookup(_code_table, 'Complex', 64) - __all__.append('Complex32') + __all__.append('Complex32') except(PrecisionError): pass try: Complex64 = _lookup(_code_table, 'Complex', 128) - __all__.append('Complex64') + __all__.append('Complex64') except(PrecisionError): pass try: diff --git a/numpy/oldnumeric/random_array.py b/numpy/oldnumeric/random_array.py index e8d386ce4..84e923e13 100644 --- a/numpy/oldnumeric/random_array.py +++ b/numpy/oldnumeric/random_array.py @@ -18,7 +18,7 @@ def seed(x=0, y=0): if (x == 0 or y == 0): mt.seed() else: - mt.seed((x,y)) + mt.seed((x,y)) def get_seed(): raise NotImplementedError, \ @@ -266,5 +266,3 @@ def test(): if __name__ == '__main__': test() - - diff --git a/numpy/oldnumeric/rng.py b/numpy/oldnumeric/rng.py index 77a90c694..fcf08bb37 100644 --- a/numpy/oldnumeric/rng.py +++ b/numpy/oldnumeric/rng.py @@ -1,7 +1,7 @@ # This module re-creates the RNG interface from Numeric # Replace import RNG with import numpy.oldnumeric.rng as RNG # -# It is for backwards compatibility only. +# It is for backwards compatibility only. __all__ = ['CreateGenerator','ExponentialDistribution','LogNormalDistribution','NormalDistribution', @@ -21,7 +21,7 @@ class Distribution(object): def density(self,x): raise NotImplementedError - + def __call__(self, x): return self.density(x) @@ -36,7 +36,7 @@ class Distribution(object): class ExponentialDistribution(Distribution): def __init__(self, lambda_): if (lambda_ <= 0): - raise error, "parameter must be positive" + raise error, "parameter must be positive" Distribution.__init__(self, 'exponential', lambda_) def density(x): @@ -115,7 +115,7 @@ class CreateGenerator(object): def sample(self, n): return self._dist._sample(self._rng, n) - + standard_generator = CreateGenerator(-1) def ranf(): @@ -126,12 +126,10 @@ def random_sample(*n): """random_sample(n) = array of n random numbers; random_sample(n1, n2, ...)= random array of shape (n1, n2, ..)""" - + if not n: return standard_generator.ranf() m = 1 for i in n: m = m * i return standard_generator.sample(m).reshape(*n) - - diff --git a/numpy/oldnumeric/tests/test_oldnumeric.py b/numpy/oldnumeric/tests/test_oldnumeric.py index 14d5dfd84..628ec231f 100644 --- a/numpy/oldnumeric/tests/test_oldnumeric.py +++ b/numpy/oldnumeric/tests/test_oldnumeric.py @@ -80,7 +80,7 @@ class test_oldtypes(NumPyTestCase): a1 = array([0,1,0], Bool) a2 = array([0,1,0], bool) assert_array_equal(a1, a2) - + if __name__ == "__main__": NumPyTest().run() diff --git a/numpy/oldnumeric/typeconv.py b/numpy/oldnumeric/typeconv.py index cb7239027..1fbf1e072 100644 --- a/numpy/oldnumeric/typeconv.py +++ b/numpy/oldnumeric/typeconv.py @@ -1,4 +1,3 @@ - __all__ = ['oldtype2dtype', 'convtypecode', 'convtypecode2', 'oldtypecodes'] import numpy as N @@ -48,7 +47,7 @@ _changedtypes = {'B': 'b', 'h': 's', 'H': 'w', 'I': 'u'} - + class _oldtypecodes(dict): def __getitem__(self, obj): char = N.dtype(obj).char diff --git a/numpy/oldnumeric/ufuncs.py b/numpy/oldnumeric/ufuncs.py index 58fa473a6..c26050f55 100644 --- a/numpy/oldnumeric/ufuncs.py +++ b/numpy/oldnumeric/ufuncs.py @@ -17,4 +17,3 @@ from numpy import less, cosh, arcsinh, add, ceil, arctan2, floor_divide, \ arccosh, logical_or, minimum, conjugate, tan, greater, bitwise_xor, \ fabs, floor, sqrt, arctan, right_shift, absolute, sin, \ multiply, greater_equal, left_shift, exp, divide as divide_safe - |