fix float nan comparison
This change also adds minor docstrings fixes and bumps pre-commit blac version.
This commit is contained in:
parent
ac96d8254b
commit
6f7d706a8e
@ -434,7 +434,7 @@ def _parse_float(value: Any) -> float:
|
|||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
value : Any
|
value: Any
|
||||||
Value to parse
|
Value to parse
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
@ -456,20 +456,19 @@ def _dump_float(value: float) -> Union[float, str]:
|
|||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
value : float
|
value: float
|
||||||
Value to dump
|
Value to dump
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
Union[float, str]
|
Union[float, str]
|
||||||
Dumped valid, either a float or the strings
|
Dumped value, either a float or the strings
|
||||||
"Infinity" or "-Infinity"
|
|
||||||
"""
|
"""
|
||||||
if value == float("inf"):
|
if value == float("inf"):
|
||||||
return INFINITY
|
return INFINITY
|
||||||
if value == -float("inf"):
|
if value == -float("inf"):
|
||||||
return NEG_INFINITY
|
return NEG_INFINITY
|
||||||
if value == float("nan"):
|
if isinstance(value, float) and math.isnan(value):
|
||||||
return NAN
|
return NAN
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user