diff options
author | Travis Oliphant <oliphant@enthought.com> | 2008-02-23 06:37:45 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2008-02-23 06:37:45 +0000 |
commit | 0abaf57d5c305044148d7688ce248ad050963a7f (patch) | |
tree | c6d252b4c9dd70a002121f743ec40e040d66efd4 /numpy/lib/function_base.py | |
parent | 1cc67dd9c8a9c65e511b6a363915688378ba7938 (diff) | |
download | numpy-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.py | 6 |
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' |