【发布时间】:2020-05-10 20:59:26
【问题描述】:
我有一个 numpy 一维数组,其中包含 True 或 False 的布尔值。我想检查它们是否都是False,这样无论numpy数组中的所有元素都是False还是True,都会返回一个True/False
x = np.array([False, False, False]) # this should return True, since all values are False
y = np.array([True, True, True]) # this should return False, since all values are True
z = np.array([True, False, True]) # this should return False, since not all values are False
我查看了np.all(),但这并不能解决我的问题。
谢谢!
【问题讨论】:
-
布尔+
all():(x==False).all()