[Numpy-svn] r5808 - trunk/numpy/numarray

numpy-svn@scip... numpy-svn@scip...
Fri Sep 12 22:41:00 CDT 2008


Author: alan.mcintyre
Date: 2008-09-12 22:40:57 -0500 (Fri, 12 Sep 2008)
New Revision: 5808

Modified:
   trunk/numpy/numarray/alter_code2.py
   trunk/numpy/numarray/functions.py
   trunk/numpy/numarray/numerictypes.py
   trunk/numpy/numarray/session.py
   trunk/numpy/numarray/util.py
Log:
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.


Modified: trunk/numpy/numarray/alter_code2.py
===================================================================
--- trunk/numpy/numarray/alter_code2.py	2008-09-13 02:56:33 UTC (rev 5807)
+++ trunk/numpy/numarray/alter_code2.py	2008-09-13 03:40:57 UTC (rev 5808)
@@ -12,12 +12,9 @@
 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)

Modified: trunk/numpy/numarray/functions.py
===================================================================
--- trunk/numpy/numarray/functions.py	2008-09-13 02:56:33 UTC (rev 5807)
+++ trunk/numpy/numarray/functions.py	2008-09-13 03:40:57 UTC (rev 5808)
@@ -20,13 +20,13 @@
             '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 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 @@
     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 @@
         res = work[indices]
         if outarr is None:
             return res
-        out[...] = res
+        outarr[...] = res
         return
 
 def tensormultiply(a1, a2):
@@ -466,9 +466,9 @@
     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)

Modified: trunk/numpy/numarray/numerictypes.py
===================================================================
--- trunk/numpy/numarray/numerictypes.py	2008-09-13 02:56:33 UTC (rev 5807)
+++ trunk/numpy/numarray/numerictypes.py	2008-09-13 03:40:57 UTC (rev 5808)
@@ -54,9 +54,6 @@
 #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 = {}

Modified: trunk/numpy/numarray/session.py
===================================================================
--- trunk/numpy/numarray/session.py	2008-09-13 02:56:33 UTC (rev 5807)
+++ trunk/numpy/numarray/session.py	2008-09-13 03:40:57 UTC (rev 5808)
@@ -16,7 +16,6 @@
 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 @@
 
 __all__ = ['load', 'save']
 
-import copy
 import sys
 import pickle
 

Modified: trunk/numpy/numarray/util.py
===================================================================
--- trunk/numpy/numarray/util.py	2008-09-13 02:56:33 UTC (rev 5807)
+++ trunk/numpy/numarray/util.py	2008-09-13 03:40:57 UTC (rev 5808)
@@ -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 @@
 
 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')]



More information about the Numpy-svn mailing list