fix float nan comparison

This change also adds minor docstrings fixes and bumps pre-commit blac
version.
This commit is contained in:
James Hilton-Balfe 2022-04-24 00:13:58 +01:00 committed by GitHub
parent ac96d8254b
commit 6f7d706a8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -462,14 +462,13 @@ def _dump_float(value: float) -> Union[float, str]:
Returns
-------
Union[float, str]
Dumped valid, either a float or the strings
"Infinity" or "-Infinity"
Dumped value, either a float or the strings
"""
if value == float("inf"):
return INFINITY
if value == -float("inf"):
return NEG_INFINITY
if value == float("nan"):
if isinstance(value, float) and math.isnan(value):
return NAN
return value