Why does assert np.nan == np.nan cause an error?

Viewed 5396

If

assert 1 == 1

is fine, then why does:

assert np.nan == np.nan

cause an assertion error?

What's even more confusing, this is OK:

assert np.nan != np.nan

What's the best way to test for nan?

2 Answers
Related