python - numpy any() 返回一个特殊的结果

标签 python numpy

我有一个 numpy.ndarray ary

array([[ -8.34887715e-15],
       [ -8.57980353e-14],
       [ -7.28306304e-14]])

我无法理解以下内容:

ary.any() > 0.1

返回 True,即使 ary 的每个条目都明显低于 0(据我了解,这应该评估为 False).

如果我这样做

ary.any() > 1

此计算结果为 False

如果有人能阐明这一点,我们将不胜感激!

最佳答案

ary.any() 返回 True 当且仅当 ary 的至少一个元素为非零。然后检查 True > .1 是否为真,因为 True 的数值为 1。你的意思是

(ary > .1).any()

关于python - numpy any() 返回一个特殊的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20204094/

相关文章:

python - django-scarface 无法在 python 2.7 中工作

python - 如何在Python中的正则表达式中使用字典?

Python 使用 lxml 下载图像

python - 你如何找到低于某个值的最大 float ?

python - 大数据集优化

python - 在 Python shell 中执行带有参数的文件

python - python中逻辑语句的组合(and、or)

python - 如何获取列表中相同的行索引?

python - 生成包含另一个 NumPy 数组索引的 NumPy 数组

python - 在不改变分组列位置的情况下按另一组中的一列排序