AttributeError: 'numpy.float64' object has no attribute '_mask'
self = <numpy.ma.tests.test_regression.TestRegression object at 0x0000000012B264E0>
def test_var_sets_maskedarray_scalar(self):
# Issue gh-2757
a = np.ma.array(np.arange(5), mask=True)
mout = np.ma.array(-1, dtype=float)
> a.var(out=mout)
numpy\ma\tests\test_regression.py:64:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
numpy\ma\core.py:5219: in var
dvar = divide(danom.sum(axis, **kwargs), cnt).view(type(self))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <numpy.ma.core._DomainedBinaryOperation object at 0x0000000006CA1048>
a = masked, b = 0, args = (), kwargs = {}, da = array(0.)
db = array(0, dtype=int64), result = nan, m = array([ True])
domain = <numpy.ma.core._DomainSafeDivide object at 0x0000000006CA1240>
masked_result = nan
def __call__(self, a, b, *args, **kwargs):
"Execute the call behavior."
# Get the data
(da, db) = (getdata(a), getdata(b))
# Get the result
with np.errstate(divide='ignore', invalid='ignore'):
result = self.f(da, db, *args, **kwargs)
# Get the mask as a combination of the source masks and invalid
m = ~umath.isfinite(result)
m |= getmask(a)
m |= getmask(b)
# Apply the domain
domain = ufunc_domain.get(self.f, None)
if domain is not None:
m |= domain(da, db)
# Take care of the scalar case first
if (not m.ndim):
if m:
return masked
else:
return result
# When the mask is True, put back da if possible
# any errors, just abort; impossible to guarantee masked values
try:
np.copyto(result, 0, casting='unsafe', where=m)
# avoid using "*" since this may be overlaid
masked_da = umath.multiply(m, da)
# only add back if it can be cast safely
if np.can_cast(masked_da.dtype, result.dtype, casting='safe'):
result += masked_da
except Exception:
pass
# Transforms to a (subclass of) MaskedArray
masked_result = result.view(get_masked_subclass(a, b))
> masked_result._mask = m
E AttributeError: 'numpy.float64' object has no attribute '_mask'
This test has failed a few times with the following message:
And stack trace
Link to failures: https://ci.appveyor.com/project/charris/numpy/build/1.0.8371/job/ewtkpj7ss3beoky3/tests