If you use your own dataclasses (from dataclassy) instead of tuples, you can override this behaviour.
Making NaNs compare unequal to themselves was a hack that dates back from the time modern floats were first introduced.
Making NaNs compare unequal to themselves was a hack that dates back from the time modern floats were first introduced.
This is because == is an overloaded concept. Python has chosen to define == in the way that makes the most mathematical sense in the case of NaN.
Maybe there's a metaprogramming way to override how == in interpreted for floats?