diff options
author | Alan McIntyre <alan.mcintyre@local> | 2008-09-13 03:40:57 +0000 |
---|---|---|
committer | Alan McIntyre <alan.mcintyre@local> | 2008-09-13 03:40:57 +0000 |
commit | e091c840e101eb620307747e0e4cd1b939d8abe6 (patch) | |
tree | 378e691843fe1d56e224266b0c8e5478e1327433 /numpy/numarray | |
parent | b1e2466272fa0c2ee08701c3d86a03088218b69e (diff) | |
download | numpy-e091c840e101eb620307747e0e4cd1b939d8abe6.tar.gz |
Removed unused/duplicate imports.
Removed repeated members of __all__.
Fixed reference to undefined "out" in functions.py:take function.
Fixed references to undefined "N" in functions.py.
Rewrapped lines to conform to PEP8.
Fixed references to undefined FPE_* constants (from numpy) in util.py.
Diffstat (limited to 'numpy/numarray')
-rw-r--r-- | numpy/numarray/alter_code2.py | 3 | ||||
-rw-r--r-- | numpy/numarray/functions.py | 18 | ||||
-rw-r--r-- | numpy/numarray/numerictypes.py | 3 | ||||
-rw-r--r-- | numpy/numarray/session.py | 2 | ||||
-rw-r--r-- | numpy/numarray/util.py | 19 |
5 files changed, 18 insertions, 27 deletions
diff --git a/numpy/numarray/alter_code2.py b/numpy/numarray/alter_code2.py index 87ec5aa07..4bb773850 100644 --- a/numpy/numarray/alter_code2.py +++ b/numpy/numarray/alter_code2.py @@ -12,12 +12,9 @@ import warnings warnings.warn("numpy.numarray.alter_code2 is not working yet.") import sys - import os -import re import glob - def makenewfile(name, filestr): fid = file(name, 'w') fid.write(filestr) diff --git a/numpy/numarray/functions.py b/numpy/numarray/functions.py index bd920219b..6a0fd2958 100644 --- a/numpy/numarray/functions.py +++ b/numpy/numarray/functions.py @@ -20,13 +20,13 @@ __all__ += ['vdot', 'dot', 'matrixmultiply', 'ravel', 'indices', 'any', 'argmax', 'argmin', 'argsort', 'around', 'array_equal', 'array_equiv', 'arrayrange', 'array_str', 'array_repr', 'array2list', 'average', 'choose', 'CLIP', 'RAISE', 'WRAP', - 'clip', 'compress', 'concatenate', 'copy', 'copy_reg', + 'clip', 'compress', 'copy', 'copy_reg', 'diagonal', 'divide_remainder', 'e', 'explicit_type', 'pi', 'flush_caches', 'fromfile', 'os', 'sys', 'STRICT', 'SLOPPY', 'WARN', 'EarlyEOFError', 'SizeMismatchError', 'SizeMismatchWarning', 'FileSeekWarning', 'fromstring', 'fromfunction', 'fromlist', 'getShape', 'getTypeObject', - 'identity', 'indices', 'info', 'innerproduct', 'inputarray', + 'identity', 'info', 'innerproduct', 'inputarray', 'isBigEndian', 'kroneckerproduct', 'lexsort', 'math', 'operator', 'outerproduct', 'put', 'putmask', 'rank', 'repeat', 'reshape', 'resize', 'round', 'searchsorted', @@ -45,9 +45,9 @@ import math import operator from numpy import dot as matrixmultiply, dot, vdot, ravel, concatenate, all,\ - allclose, any, around, argsort, array_equal, array_equiv,\ + allclose, any, argsort, array_equal, array_equiv,\ array_str, array_repr, CLIP, RAISE, WRAP, clip, concatenate, \ - diagonal, e, pi, indices, inner as innerproduct, nonzero, \ + diagonal, e, pi, inner as innerproduct, nonzero, \ outer as outerproduct, kron as kroneckerproduct, lexsort, putmask, rank, \ resize, searchsorted, shape, size, sort, swapaxes, trace, transpose import numpy as np @@ -321,7 +321,7 @@ def getTypeObject(sequence, type): if type is not None: return type try: - return typefrom(N.array(sequence)) + return typefrom(np.array(sequence)) except: raise TypeError("Can't determine a reasonable type from sequence") @@ -458,7 +458,7 @@ def take(array, indices, axis=0, outarr=None, clipmode=RAISE): res = work[indices] if outarr is None: return res - out[...] = res + outarr[...] = res return def tensormultiply(a1, a2): @@ -466,9 +466,9 @@ def tensormultiply(a1, a2): if (a1.shape[-1] != a2.shape[0]): raise ValueError("Unmatched dimensions") shape = a1.shape[:-1] + a2.shape[1:] - return np.reshape(dot(N.reshape(a1, (-1, a1.shape[-1])), - np.reshape(a2, (a2.shape[0],-1))), - shape) + return np.reshape(dot(np.reshape(a1, (-1, a1.shape[-1])), + np.reshape(a2, (a2.shape[0],-1))), + shape) def cumsum(a1, axis=0, out=None, type=None, dim=0): return np.asarray(a1).cumsum(axis,dtype=type,out=out) diff --git a/numpy/numarray/numerictypes.py b/numpy/numarray/numerictypes.py index 99473097d..7bc91612e 100644 --- a/numpy/numarray/numerictypes.py +++ b/numpy/numarray/numerictypes.py @@ -54,9 +54,6 @@ except: #from typeconv import typeConverters as _typeConverters #import numinclude #from _numerictype import _numerictype, typeDict -import types as _types -import copy as _copy -import sys as _sys # Enumeration of numarray type codes typeDict = {} diff --git a/numpy/numarray/session.py b/numpy/numarray/session.py index e1b079103..0982742ab 100644 --- a/numpy/numarray/session.py +++ b/numpy/numarray/session.py @@ -16,7 +16,6 @@ First, some unfortunate (probably unnecessary) concessions to doctest to keep the test run free of warnings. >>> del _PROXY_ALLOWED ->>> del copy >>> del __builtins__ By default, save() stores every variable in the caller's namespace: @@ -76,7 +75,6 @@ which is not restored by a simple import is lost. __all__ = ['load', 'save'] -import copy import sys import pickle diff --git a/numpy/numarray/util.py b/numpy/numarray/util.py index 2a7efb60d..01002f194 100644 --- a/numpy/numarray/util.py +++ b/numpy/numarray/util.py @@ -1,7 +1,8 @@ -from numpy import geterr +import os +import numpy -__all__ = ['MathDomainError', 'UnderflowError', 'NumOverflowError', 'handleError', - 'get_numarray_include_dirs'] +__all__ = ['MathDomainError', 'UnderflowError', 'NumOverflowError', + 'handleError', 'get_numarray_include_dirs'] class MathDomainError(ArithmeticError): pass class UnderflowError(ArithmeticError): pass @@ -9,31 +10,29 @@ class NumOverflowError(OverflowError, ArithmeticError): pass def handleError(errorStatus, sourcemsg): """Take error status and use error mode to handle it.""" - modes = geterr() - if errorStatus & FPE_INVALID: + modes = numpy.geterr() + if errorStatus & numpy.FPE_INVALID: if modes['invalid'] == "warn": print "Warning: Encountered invalid numeric result(s)", sourcemsg if modes['invalid'] == "raise": raise MathDomainError(sourcemsg) - if errorStatus & FPE_DIVIDEBYZERO: + if errorStatus & numpy.FPE_DIVIDEBYZERO: if modes['dividebyzero'] == "warn": print "Warning: Encountered divide by zero(s)", sourcemsg if modes['dividebyzero'] == "raise": raise ZeroDivisionError(sourcemsg) - if errorStatus & FPE_OVERFLOW: + if errorStatus & numpy.FPE_OVERFLOW: if modes['overflow'] == "warn": print "Warning: Encountered overflow(s)", sourcemsg if modes['overflow'] == "raise": raise NumOverflowError(sourcemsg) - if errorStatus & FPE_UNDERFLOW: + if errorStatus & numpy.FPE_UNDERFLOW: if modes['underflow'] == "warn": print "Warning: Encountered underflow(s)", sourcemsg if modes['underflow'] == "raise": raise UnderflowError(sourcemsg) -import os -import numpy def get_numarray_include_dirs(): base = os.path.dirname(numpy.__file__) newdirs = [os.path.join(base, 'numarray')] |