[Numpy-svn] r4820 - trunk/numpy/lib

numpy-svn@scip... numpy-svn@scip...
Sat Feb 23 00:37:47 CST 2008


Author: oliphant
Date: 2008-02-23 00:37:45 -0600 (Sat, 23 Feb 2008)
New Revision: 4820

Modified:
   trunk/numpy/lib/function_base.py
Log:
Add Anne Archibald's fix to average to remove eval.

Modified: trunk/numpy/lib/function_base.py
===================================================================
--- trunk/numpy/lib/function_base.py	2008-02-23 01:14:40 UTC (rev 4819)
+++ trunk/numpy/lib/function_base.py	2008-02-23 06:37:45 UTC (rev 4820)
@@ -378,9 +378,9 @@
                 ni = len(ash)
                 r = [newaxis]*ni
                 r[axis] = slice(None, None, 1)
-                w1 = eval("w["+repr(tuple(r))+"]*ones(ash, float)")
-                n = add.reduce(a*w1, axis)
-                d = add.reduce(w1, axis)
+                r = tuple(r)
+                n = add.reduce(a*w[r], axis)
+                d = add.reduce(w, axis)
             else:
                 raise ValueError, 'averaging weights have wrong shape'
 



More information about the Numpy-svn mailing list