最有可能我缺少any()
函数的某些内容,它说:Returns True if any of the elements of a evaluate to True.
所以在下面的例子中,我希望true
作为一个元素count[0]
作为输出大于2。但是,输出为FALSE
。
我在做什么愚蠢的错误?!
最小示例:
count = np.zeros(10)
count[0] += 4
count[5] += 1
print(np.any(count,axis=0) > 2)
# parentheses:
np.any(count,axis=0)
#output: True
np.any(count, axis=0)>2
# is a boolean expression. It evaluates to False, because True is not larger than 2.
# So:
np.any(count>2, axis=0)
# should do what you want