numpy.ma (masked) array mean method has inconsitent return type
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I noticed that the numpy masked-array mean method returns different types when it probably should not: import numpy as np A = np.ma.masked_equal([1,1,0], value=0) B = np.ma.masked_equal([1,1,1], value=0) # no masked values type(A.mean()) #numpy.float64 type(B.mean()) #numpy.ma.core.MaskedArray Other numpy.ma.core.MaskedArray methods seem to be consistent type( A.sum()) == type(B.sum()) # True type( A.prod()) == type(B.prod()) # True type( A.std()) == type(B.std()) # True type( A.mean()) == type(B.mean()) # False Can someone explain this?