Numpy.isnan (value) does not match value == numpy.nan?

Why am I getting the following:

>>> v nan >>> type(v) <type 'numpy.float64'> >>> v == np.nan False >>> np.isnan(v) True 

I would think that they should be equivalent?

+7
python types numpy boolean nan
source share
1 answer

nan != nan . This is how equalities on nan are defined. It was decided that this result is more convenient for numerical algorithms than the alternative. That is why there isnan .

+9
source share

All Articles