diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2007-01-08 21:56:54 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2007-01-08 21:56:54 +0000 |
commit | 1bd2d49ef378fb869d015cef32c3e44a4c03a8f0 (patch) | |
tree | 43335baf1da0b6e9de0ad806e721a077e3cbfa45 /numpy/numarray | |
parent | 98b6d48b07f4eadfb7d1fc41483debe7e07eecd6 (diff) | |
download | numpy-1bd2d49ef378fb869d015cef32c3e44a4c03a8f0.tar.gz |
Whitespace cleanup.
Diffstat (limited to 'numpy/numarray')
-rw-r--r-- | numpy/numarray/alter_code1.py | 12 | ||||
-rw-r--r-- | numpy/numarray/alter_code2.py | 2 | ||||
-rw-r--r-- | numpy/numarray/convolve.py | 2 | ||||
-rw-r--r-- | numpy/numarray/functions.py | 25 | ||||
-rw-r--r-- | numpy/numarray/image.py | 2 | ||||
-rw-r--r-- | numpy/numarray/numerictypes.py | 55 | ||||
-rw-r--r-- | numpy/numarray/session.py | 21 | ||||
-rw-r--r-- | numpy/numarray/setup.py | 3 | ||||
-rw-r--r-- | numpy/numarray/util.py | 2 |
9 files changed, 59 insertions, 65 deletions
diff --git a/numpy/numarray/alter_code1.py b/numpy/numarray/alter_code1.py index 4a62324fc..ae950e7e0 100644 --- a/numpy/numarray/alter_code1.py +++ b/numpy/numarray/alter_code1.py @@ -50,7 +50,7 @@ Makes the following changes: - .setimag() --> .imag = - .getimaginary() --> .imag - .setimaginary() --> .imag - + """ __all__ = ['convertfile', 'convertall', 'converttree', 'convertsrc'] @@ -111,14 +111,14 @@ def replaceattr(astr): astr = astr.replace(".is_fortran_contiguous()",".flags.fortran") astr = astr.replace(".itemsize()",".itemsize") astr = astr.replace(".size()",".size") - astr = astr.replace(".nelements()",".size") + astr = astr.replace(".nelements()",".size") astr = astr.replace(".typecode()",".dtype.char") astr = astr.replace(".stddev()",".std()") astr = astr.replace(".getshape()", ".shape") astr = astr.replace(".getflat()", ".ravel()") astr = astr.replace(".getreal", ".real") astr = astr.replace(".getimag", ".imag") - astr = astr.replace(".getimaginary", ".imag") + astr = astr.replace(".getimaginary", ".imag") # preserve uses of flat that should be o.k. tmpstr = flatindex_re.sub(r"@@@@\2",astr) @@ -161,9 +161,9 @@ def replaceother(astr): astr = setshape_re.sub('\\1.shape = \\2', astr) astr = setreal_re.sub('\\1.real = \\2', astr) astr = setimag_re.sub('\\1.imag = \\2', astr) - astr = setimaginary_re.sub('\\1.imag = \\2', astr) + astr = setimaginary_re.sub('\\1.imag = \\2', astr) return astr - + import datetime def fromstr(filestr): savestr = filestr[:] @@ -249,7 +249,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, ['h','c'], orig=0) diff --git a/numpy/numarray/alter_code2.py b/numpy/numarray/alter_code2.py index 8505ca9cc..87ec5aa07 100644 --- a/numpy/numarray/alter_code2.py +++ b/numpy/numarray/alter_code2.py @@ -2,7 +2,7 @@ This module converts code written for numpy.numarray to work with numpy -FIXME: finish this. +FIXME: finish this. """ #__all__ = ['convertfile', 'convertall', 'converttree'] diff --git a/numpy/numarray/convolve.py b/numpy/numarray/convolve.py index 6c40ef111..68a4730a1 100644 --- a/numpy/numarray/convolve.py +++ b/numpy/numarray/convolve.py @@ -10,5 +10,5 @@ except ImportError: It can be downloaded by checking out the latest source from http://svn.scipy.org/svn/scipy/trunk/Lib/stsci or by downloading and installing all of SciPy from http://www.scipy.org. -""" +""" raise ImportError(msg) diff --git a/numpy/numarray/functions.py b/numpy/numarray/functions.py index 2a6e5317b..329e08024 100644 --- a/numpy/numarray/functions.py +++ b/numpy/numarray/functions.py @@ -1,4 +1,3 @@ - # missing Numarray defined names (in from numarray import *) ##__all__ = ['ClassicUnpickler', 'Complex32_fromtype', ## 'Complex64_fromtype', 'ComplexArray', 'Error', @@ -8,7 +7,7 @@ ## 'PyINT_TYPES', 'PyLevel2Type', 'PyNUMERIC_TYPES', 'PyREAL_TYPES', ## 'SUPPRESS_SMALL', ## 'SuitableBuffer', 'USING_BLAS', -## 'UsesOpPriority', +## 'UsesOpPriority', ## 'codegenerator', 'generic', 'libnumarray', 'libnumeric', ## 'make_ufuncs', 'memory', ## 'numarrayall', 'numarraycore', 'numinclude', 'safethread', @@ -72,7 +71,7 @@ def type2dtype(typecode, type, dtype, use_default=True): def fromfunction(shape, dimensions, type=None, typecode=None, dtype=None): dtype = type2dtype(typecode, type, dtype, 1) - return N.fromfunction(shape, dimensions, dtype=dtype) + return N.fromfunction(shape, dimensions, dtype=dtype) def ones(shape, type=None, typecode=None, dtype=None): dtype = type2dtype(typecode, type, dtype, 1) return N.ones(shape, dtype) @@ -90,7 +89,7 @@ def where(condition, x=None, y=None, out=None): out[...] = arr return out return arr - + def indices(shape, type=None): return N.indices(shape, type) @@ -118,7 +117,7 @@ def around(array, digits=0, output=None): if output is None: return ret return - + def array2list(arr): return arr.tolist() @@ -174,7 +173,7 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT, shape = (-1,) if not isinstance(shape, tuple): shape = (shape,) - + if (list(shape).count(-1)>1): raise ValueError("At most one unspecified dimension in shape") @@ -208,7 +207,7 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT, ##the most common case, namely reading in data from an unchanging ##file whose size may be determined before allocation, should be ##quick -- only one allocation will be needed. - + recsize = dtype.itemsize * N.product([i for i in shape if i != -1]) blocksize = max(_BLOCKSIZE/recsize, 1)*recsize @@ -265,7 +264,7 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT, if a.dtype.char == '?': N.not_equal(a, 0, a) return a - + def fromstring(datastring, type=None, shape=None, typecode=None, dtype=None): dtype = type2dtype(typecode, type, dtype, True) if shape is None: @@ -275,7 +274,7 @@ def fromstring(datastring, type=None, shape=None, typecode=None, dtype=None): res = N.fromstring(datastring, count=count) if shape is not None: res.shape = shape - return res + return res # check_overflow is ignored @@ -333,12 +332,12 @@ def getShape(shape, *args): if not issubclass(dummy.dtype.type, N.integer): raise TypeError if len(dummy) > N.MAXDIMS: - raise TypeError + raise TypeError except: raise TypeError("Shape must be a sequence of integers") return shape - + def identity(n, type=None, typecode=None, dtype=None): dtype = type2dtype(typecode, type, dtype, True) return N.identity(n, dtype) @@ -455,8 +454,8 @@ def take(array, indices, axis=0, outarr=None, clipmode=RAISE): if outarr is None: return res out[...] = res - return - + return + def tensormultiply(a1, a2): a1, a2 = N.asarray(a1), N.asarray(a2) if (a1.shape[-1] != a2.shape[0]): diff --git a/numpy/numarray/image.py b/numpy/numarray/image.py index 4ba23b68e..e24326f79 100644 --- a/numpy/numarray/image.py +++ b/numpy/numarray/image.py @@ -12,4 +12,4 @@ http://svn.scipy.org/svn/scipy/trunk/Lib/stsci or by downloading and installing all of SciPy from http://www.scipy.org. """ raise ImportError(msg) - + diff --git a/numpy/numarray/numerictypes.py b/numpy/numarray/numerictypes.py index 3b27871df..490ced970 100644 --- a/numpy/numarray/numerictypes.py +++ b/numpy/numarray/numerictypes.py @@ -118,7 +118,7 @@ class NumericType(object): self.default = None self.typeno = -1 return self - + def __init__(self, name, bytes, default, typeno): if not isinstance(name, str): raise TypeError("name must be a string") @@ -159,7 +159,7 @@ class UnsignedIntegralType(IntegralType, UnsignedType): class FloatingType(NumericType): pass - + class ComplexType(NumericType): pass @@ -174,7 +174,7 @@ class ObjectType(NumericType): Any = AnyType("Any", None, None, _tAny) Object = ObjectType("Object", None, None, _tObject) - + # Numeric Types: Bool = BooleanType("Bool", 1, 0, _tBool) @@ -182,7 +182,7 @@ Int8 = SignedIntegralType( "Int8", 1, 0, _tInt8) Int16 = SignedIntegralType("Int16", 2, 0, _tInt16) Int32 = SignedIntegralType("Int32", 4, 0, _tInt32) Int64 = SignedIntegralType("Int64", 8, 0, _tInt64) - + Float32 = FloatingType("Float32", 4, 0.0, _tFloat32) Float64 = FloatingType("Float64", 8, 0.0, _tFloat64) @@ -227,8 +227,8 @@ else: Long = _register("Long", Int32) _register("ULong", UInt32) MaybeLong = _register("MaybeLong", Int32) - __all__.append('MaybeLong') - + __all__.append('MaybeLong') + _register("UByte", UInt8) _register("UShort", UInt16) @@ -249,7 +249,7 @@ _register("i4", Int32) _register("i8", Int64) if HasUInt64: _register("u8", UInt64) - + _register("f4", Float32) _register("f8", Float64) _register("c8", Complex32) @@ -272,7 +272,7 @@ if LP64: _register("l", Int64) else: _register("l", Int32) - + _register("d", Float64) _register("f", Float32) _register("D", Complex64) @@ -311,7 +311,7 @@ else: genericTypeRank = ['Bool','Int8','UInt8','Int16','UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', 'Float32','Float64', 'Complex32', 'Complex64', 'Object'] - + pythonTypeRank = [ bool, int, long, float, complex ] # The next line is not platform independent XXX Needs to be generalized @@ -321,7 +321,7 @@ if not LP64: long:("Int64","int"), float:("Float64","float"), complex:("Complex64","complex")} - + scalarTypeMap = { int:"Int32", long:"Int64", @@ -348,7 +348,7 @@ scalarTypeMap.update({bool:"Bool"}) def _initGenericCoercions(): global genericCoercions genericCoercions = {} - + # vector with ... for ntype1 in genericTypeRank: nt1 = typeDict[ntype1] @@ -375,14 +375,14 @@ def _initGenericCoercions(): size = min(2*ntypesize1, MAX_INT_SIZE) else: size = ntypesize2 - outtype = "Int"+str(8*size) + outtype = "Int"+str(8*size) else: if rank1 >= rank2: outtype = ntype1 else: outtype = ntype2 genericCoercions[(ntype1, ntype2)] = outtype - + for ntype2 in pythonTypeRank: # scalar mapto, kind = pythonTypeMap[ntype2] @@ -397,7 +397,7 @@ def _initGenericCoercions(): outtype = mapto genericCoercions[(ntype1, ntype2)] = outtype genericCoercions[(ntype2, ntype1)] = outtype - + # scalar-scalar for ntype1 in pythonTypeRank: maptype1 = scalarTypeMap[ntype1] @@ -405,7 +405,7 @@ def _initGenericCoercions(): for ntype2 in pythonTypeRank: maptype2 = scalarTypeMap[ntype2] genericCoercions[(ntype1, ntype2)] = genericCoercions[(maptype1, maptype2)] - + # Special cases more easily dealt with outside of the loop genericCoercions[("Complex32", "Float64")] = "Complex64" genericCoercions[("Float64", "Complex32")] = "Complex64" @@ -454,42 +454,42 @@ typecodes = {'Integer': '1silN', if HasUInt64: _MaximumType = { Bool : UInt64, - + Int8 : Int64, Int16 : Int64, Int32 : Int64, Int64 : Int64, - + UInt8 : UInt64, UInt16 : UInt64, UInt32 : UInt64, UInt8 : UInt64, - + Float32 : Float64, Float64 : Float64, - + Complex32 : Complex64, - Complex64 : Complex64 + Complex64 : Complex64 } else: _MaximumType = { Bool : Int64, - + Int8 : Int64, Int16 : Int64, Int32 : Int64, Int64 : Int64, - + UInt8 : Int64, UInt16 : Int64, UInt32 : Int64, UInt8 : Int64, - + Float32 : Float64, Float64 : Float64, - + Complex32 : Complex64, - Complex64 : Complex64 + Complex64 : Complex64 } def MaximumType(t): @@ -510,7 +510,7 @@ def getType(type): raise TypeError("Not a numeric type") scalarTypes = (bool,int,long,float,complex) - + _scipy_dtypechar = { Int8 : 'b', UInt8 : 'B', @@ -546,7 +546,6 @@ if LP64: else: _scipy_dtypechar_inverse['p'] = Int32 _scipy_dtypechar_inverse['P'] = UInt32 - + def typefrom(obj): return _scipy_dtypechar_inverse[obj.dtype.char] - diff --git a/numpy/numarray/session.py b/numpy/numarray/session.py index 25520bd41..ee155f9dc 100644 --- a/numpy/numarray/session.py +++ b/numpy/numarray/session.py @@ -209,7 +209,7 @@ class _ObjectProxy(object): return False -class _SaveSession(object): +class _SaveSession(object): """Tag object which marks the end of a save session and holds the saved session variable names as a list of strings in the same order as the session pickles.""" @@ -250,13 +250,13 @@ def save(variables=None, file=SAVEFILE, dictionary=None, verbose=False): Defaults to dictionary.keys(). 'file' a filename or file object for the session file. - + 'dictionary' the dictionary in which to look up the variables. Defaults to the caller's globals() - + 'verbose' print additional debug output when True. """ - + global VERBOSE VERBOSE = verbose @@ -264,7 +264,7 @@ def save(variables=None, file=SAVEFILE, dictionary=None, verbose=False): if isinstance(file, str): file = open(file, "wb") - + if dictionary is None: dictionary = _callers_globals() @@ -272,7 +272,7 @@ def save(variables=None, file=SAVEFILE, dictionary=None, verbose=False): keys = dictionary.keys() else: keys = variables.split(",") - + source_modules = _callers_modules() + sys.modules.keys() p = pickle.Pickler(file, protocol=2) @@ -303,7 +303,7 @@ def save(variables=None, file=SAVEFILE, dictionary=None, verbose=False): file.close() def load(variables=None, file=SAVEFILE, dictionary=None, verbose=False): - + """load a numpy session from a file and store the specified 'variables' into 'dictionary'. @@ -311,16 +311,16 @@ def load(variables=None, file=SAVEFILE, dictionary=None, verbose=False): Defaults to dictionary.keys(). 'file' a filename or file object for the session file. - + 'dictionary' the dictionary in which to look up the variables. Defaults to the caller's globals() 'verbose' print additional debug output when True. """ - + global VERBOSE VERBOSE = verbose - + if isinstance(file, str): file = open(file, "rb") if dictionary is None: @@ -346,4 +346,3 @@ def load(variables=None, file=SAVEFILE, dictionary=None, verbose=False): def test(): import doctest, numpy.numarray.session return doctest.testmod(numpy.numarray.session) - diff --git a/numpy/numarray/setup.py b/numpy/numarray/setup.py index 39fc40152..056232d4b 100644 --- a/numpy/numarray/setup.py +++ b/numpy/numarray/setup.py @@ -1,4 +1,3 @@ - from os.path import join def configuration(parent_package='',top_path=None): @@ -6,7 +5,7 @@ def configuration(parent_package='',top_path=None): config = Configuration('numarray',parent_package,top_path) config.add_data_files('numpy/') - + # Configure fftpack_lite config.add_extension('_capi', sources=['_capi.c'] diff --git a/numpy/numarray/util.py b/numpy/numarray/util.py index 374c041cc..2a7efb60d 100644 --- a/numpy/numarray/util.py +++ b/numpy/numarray/util.py @@ -1,4 +1,3 @@ - from numpy import geterr __all__ = ['MathDomainError', 'UnderflowError', 'NumOverflowError', 'handleError', @@ -39,4 +38,3 @@ def get_numarray_include_dirs(): base = os.path.dirname(numpy.__file__) newdirs = [os.path.join(base, 'numarray')] return newdirs - |