nan-comparison (PLW0177)
Added in 0.12.0 · Related issues · View source
Derived from the Pylint linter.
What it does
Checks for comparisons against NaN values.
Why is this bad?
Comparing against a NaN value can lead to unexpected results. For example,
float("NaN") == float("NaN") will return False and, in general,
x == float("NaN") will always return False, even if x is NaN.
To determine whether a value is NaN, use math.isnan or np.isnan
instead of comparing against NaN directly.
Example
Use instead: