当我在完全屏蔽的屏蔽数组中计算加权平均值时,我得到不同的结果weights=None
or weights=1
:
import numpy.ma as ma
a = ma.arange(2.)
a[:] = ma.masked # fully masked
ma.average(a) # returns NaN, which is ok since all elements are masked
ma.average(a, weights=None, returned=True) # returns (NaN, 0.0), which is ok also
ma.average(a, weights=(1,1), returned=True) # returns 'masked'
我希望最后两行产生相同的结果 - 即相同数量的输出和相同的值,但它们没有。最烦人的是,在最后一种情况下,尝试检索第二个输出参数时会发生错误。为什么我会得到这些结果?