【发布时间】:2020-03-12 22:52:41
【问题描述】:
我只是觉得这有点奇怪。环境是Python v3,虽然它看起来对我来说很好表达
import numpy as np
np.nan==np.nan
在元组中使用时返回False:
(np.nan,)==(np.nan,)
它返回True
【问题讨论】:
-
因为。元组相等的处理方式与 nan-equality 不同?除此之外 - 你可能想使用
np.isnan(np.nan)- 这会导致 True - 所以也许 Tuple 使用了正确的 NaN 检测......不过只是一个猜测 -
好吧,我不认为它是重复的。那是关于元组而不是列表
-
虽然成员资格测试和元组相等性都检查了身份,但这并不能使这些问题相同。