diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2012-11-23 09:33:05 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2012-11-23 10:34:06 -0700 |
commit | 38c150c20fa0b141aa1189b67dbaa781ee90b457 (patch) | |
tree | 65266f8bc0f0894e3e1094cd35d6f4fabb66bf0a /numpy/ma | |
parent | 20224ea62ed42a3ebc0795f62b78309ff9ab1a8a (diff) | |
download | numpy-38c150c20fa0b141aa1189b67dbaa781ee90b457.tar.gz |
BUG: gh-2757, masked array var method should zero masked out parameter.
When a is a 1-d masked array with all values masked and b is a 0-d masked
array, then a.var(out=b) fails to set the underlying masked value of b,
causing an invalid value warning to be raised in a.std(out=b) whenever b
contained a masked negative number. This fix sets the underlying value to
0, which is consistent with the n-d case. A better fix might be to add an
out parameter to the masked array ufuncs, but that is a bigger project.
Diffstat (limited to 'numpy/ma')
-rw-r--r-- | numpy/ma/core.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index bcd24d22b..b3549654d 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -4749,6 +4749,7 @@ class MaskedArray(ndarray): dvar = masked if out is not None: if isinstance(out, MaskedArray): + out.flat = 0 out.__setmask__(True) elif out.dtype.kind in 'biu': errmsg = "Masked data information would be lost in one or "\ |