summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2008-02-23 06:37:45 +0000
committerTravis Oliphant <oliphant@enthought.com>2008-02-23 06:37:45 +0000
commit0abaf57d5c305044148d7688ce248ad050963a7f (patch)
treec6d252b4c9dd70a002121f743ec40e040d66efd4 /numpy/lib/function_base.py
parent1cc67dd9c8a9c65e511b6a363915688378ba7938 (diff)
downloadnumpy-0abaf57d5c305044148d7688ce248ad050963a7f.tar.gz
Add Anne Archibald's fix to average to remove eval.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index c3cce05ed..ca45f46f8 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -378,9 +378,9 @@ def average(a, axis=None, weights=None, returned=False):
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'