Skip to content

Commit 8be3633

Browse files
committed
clamp nan
1 parent 61a22d4 commit 8be3633

File tree

1 file changed

+3
-3
lines changed
  • hypothesis-python/src/hypothesis/internal

1 file changed

+3
-3
lines changed

hypothesis-python/src/hypothesis/internal/floats.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ def sign_aware_lte(x: float, y: float) -> bool:
208208

209209
def clamp(lower: float, value: float, upper: float) -> float:
210210
"""Given a value and lower/upper bounds, 'clamp' the value so that
211-
it satisfies lower <= value <= upper."""
211+
it satisfies lower <= value <= upper. NaN is mapped to lower."""
212212
# this seems pointless (and is for integers), but handles the -0.0/0.0 case.
213-
if sign_aware_lte(value, lower):
213+
if not sign_aware_lte(lower, value):
214214
return lower
215-
if sign_aware_lte(upper, value):
215+
if not sign_aware_lte(value, upper):
216216
return upper
217217
return value
218218

0 commit comments

Comments
 (0)