On 22/02/2008, Travis E. Oliphant <[EMAIL PROTECTED]> wrote:
> Is there a ticket on the NumPy trac for this? We won't see it if there
> isn't. Thanks for pointing us to the bug.
It appears to be fixed in SVN (that was quick!). But the Debian bug
report also points out a peculiar unnecessary use of eval; the code is
also slower and uses more memory than it has to. Attached is a patch
to cure that.
Anne
Index: numpy/lib/function_base.py
===================================================================
--- numpy/lib/function_base.py (revision 4819)
+++ numpy/lib/function_base.py (working copy)
@@ -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'
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion