From 67ae6bf3a8297d1c864be2ece061e0eb2999d422 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 9 Jan 2019 12:51:41 -0800 Subject: [PATCH] Make sure smooth returns values only between 0 and 1 --- manimlib/utils/rate_functions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manimlib/utils/rate_functions.py b/manimlib/utils/rate_functions.py index a5646f30..fbbe7f5e 100644 --- a/manimlib/utils/rate_functions.py +++ b/manimlib/utils/rate_functions.py @@ -10,7 +10,10 @@ def linear(t): def smooth(t, inflection=10.0): error = sigmoid(-inflection / 2) - return (sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error) + return np.clip( + (sigmoid(inflection * (t - 0.5)) - error) / (1 - 2 * error), + 0, 1, + ) def rush_into(t):