I made a new function validate_run_time() to refactor a validation already done somewhere else: it takes a run_time and raises a ValueError if it is <= 0, or a warning if it's too short for the current frame rate. Then, I called it on Animation.begin(), Wait.begin() and AnimationGroup.begin(), as well as in Scene.wait(), Scene.pause() and Scene.wait_until(), for reasons I'll explain later.
Previously, this was strangely done inside the Scene.get_run_time() which is called by Scene.play_internal(). The merged PR #3491 did a run_time check inside Animation.begin(), but, for some reason, this was removed later.
As for Scene.wait(): currently, in the main branch, Scene.wait() plays a Wait animation. Right now, it doesn't seem necessary to add this validation here, because Wait.begin() would already take care of that. However, in the experimental branch, Scene.wait() does something different. Therefore, it is also necessary to validate the wait duration there. The plan is to port this PR into experimental.
Reviewer Checklist
[ ] The PR title is descriptive enough for the changelog, and the PR is labeled correctly
[ ] If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
[ ] If applicable: newly added functions and classes are tested
I made a new function
validate_run_time()
to refactor a validation already done somewhere else: it takes arun_time
and raises aValueError
if it is<= 0
, or a warning if it's too short for the current frame rate. Then, I called it onAnimation.begin()
,Wait.begin()
andAnimationGroup.begin()
, as well as inScene.wait()
,Scene.pause()
andScene.wait_until()
, for reasons I'll explain later.Previously, this was strangely done inside the
Scene.get_run_time()
which is called byScene.play_internal()
. The merged PR #3491 did arun_time
check insideAnimation.begin()
, but, for some reason, this was removed later.As for
Scene.wait()
: currently, in themain
branch,Scene.wait()
plays aWait
animation. Right now, it doesn't seem necessary to add this validation here, becauseWait.begin()
would already take care of that. However, in theexperimental
branch,Scene.wait()
does something different. Therefore, it is also necessary to validate the waitduration
there. The plan is to port this PR intoexperimental
.Reviewer Checklist