summaryrefslogtreecommitdiff
path: root/numpy/ma/extras.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/ma/extras.py')
-rw-r--r--numpy/ma/extras.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
index 38bf1f0e8..56da5a7e5 100644
--- a/numpy/ma/extras.py
+++ b/numpy/ma/extras.py
@@ -592,7 +592,7 @@ def average(a, axis=None, weights=None, returned=False):
avg = a.mean(axis)
scl = avg.dtype.type(a.count(axis))
else:
- wgt = np.asanyarray(weights)
+ wgt = asarray(weights)
if issubclass(a.dtype.type, (np.integer, np.bool_)):
result_dtype = np.result_type(a.dtype, wgt.dtype, 'f8')
@@ -618,6 +618,7 @@ def average(a, axis=None, weights=None, returned=False):
if m is not nomask:
wgt = wgt*(~a.mask)
+ wgt.mask |= a.mask
scl = wgt.sum(axis=axis, dtype=result_dtype)
avg = np.multiply(a, wgt, dtype=result_dtype).sum(axis)/scl