如何测试 numpy 数组中的每个元素是否都被屏蔽?这是我想做的:
x = #is a maksed numpy array
masked_min = numpy.ma.min(x)
if masked_min IS NOT A MASKED ELEMENT:
#do some stuff only if masked_min is a value
在实践中,我看到了这一点:
>>> x = numpy.ma.array(numpy.array([1,2,3]),mask=[True,True,True])
>>> masked_min = numpy.ma.min(x)
masked
测试masked
没有帮助:
>>> numpy.ma.sum(x) == numpy.ma.masked
masked