Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored run_time validation for Animation and Scene.wait() #3982

Merged
merged 5 commits into from
Oct 28, 2024

Conversation

chopan050
Copy link
Contributor

@chopan050 chopan050 commented Oct 27, 2024

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

manim/animation/animation.py Fixed Show fixed Hide fixed
manim/animation/animation.py Fixed Show fixed Hide fixed
manim/scene/scene.py Fixed Show fixed Hide fixed
manim/scene/scene.py Fixed Show fixed Hide fixed
manim/scene/scene.py Fixed Show fixed Hide fixed
manim/scene/scene.py Fixed Show fixed Hide fixed
manim/scene/scene.py Fixed Show fixed Hide fixed
manim/scene/scene.py Fixed Show fixed Hide fixed
manim/scene/scene.py Fixed Show fixed Hide fixed
manim/scene/scene.py Fixed Show fixed Hide fixed
manim/scene/scene.py Dismissed Show dismissed Hide dismissed
manim/scene/scene.py Dismissed Show dismissed Hide dismissed
manim/scene/scene.py Dismissed Show dismissed Hide dismissed
manim/scene/scene.py Dismissed Show dismissed Hide dismissed
@chopan050 chopan050 mentioned this pull request Oct 27, 2024
3 tasks
Copy link
Member

@JasonGrace2282 JasonGrace2282 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some brief testing and it seems to work - thanks!

@chopan050 chopan050 enabled auto-merge (squash) October 28, 2024 14:14
@chopan050 chopan050 merged commit f65b7f8 into ManimCommunity:main Oct 28, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants