Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d402ef0

Browse files
committed
Test all cases for clip().
1 parent dafac5b commit d402ef0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,8 @@ def normalize(numbers):
539539

540540
def clip(x, lowest, highest):
541541
"""Return x clipped to the range [lowest..highest].
542-
>>> clip(-1, 0, 1)
543-
0
544-
>>> clip(10, 0, 1)
545-
1
542+
>>> [clip(x, 0, 1) for x in [-1, 0.5, 10]]
543+
[0, 0.5, 1]
546544
"""
547545
return max(lowest, min(x, highest))
548546

0 commit comments

Comments
 (0)