diff --git a/manim/animation/animation.py b/manim/animation/animation.py index ddacb37c6c..75629ecb55 100644 --- a/manim/animation/animation.py +++ b/manim/animation/animation.py @@ -191,6 +191,10 @@ def begin(self) -> None: method. """ + if self.run_time <= 0: + raise ValueError( + f"{self} has a runtime of <= 0 seconds, which cannot be rendered correctly! please set a runtime > 0" + ) self.starting_mobject = self.create_starting_mobject() if self.suspend_mobject_updating: # All calls to self.mobject's internal updaters diff --git a/manim/animation/composition.py b/manim/animation/composition.py index cc6fa2ca7e..20b23d828c 100644 --- a/manim/animation/composition.py +++ b/manim/animation/composition.py @@ -81,6 +81,15 @@ def get_all_mobjects(self) -> Sequence[Mobject]: return list(self.group) def begin(self) -> None: + if self.run_time <= 0: + tmp = ( + "please set a runtime > 0" + if len(self.animations) != 0 + else "Please add at least one Animation" + ) + raise ValueError( + f"{self} has a runtime of 0 seconds. Which cannot be rendered correctly! {tmp}." + ) if self.suspend_mobject_updating: self.group.suspend_updating() for anim in self.animations: diff --git a/tests/module/animation/test_composition.py b/tests/module/animation/test_composition.py index 73cc6b0d60..1f6d6bf5c1 100644 --- a/tests/module/animation/test_composition.py +++ b/tests/module/animation/test_composition.py @@ -169,3 +169,13 @@ def test_animationgroup_is_passing_remover_to_nested_animationgroups(): assert sqr_animation.remover assert circ_animation.remover assert polygon_animation.remover + + +def test_empty_animation_group_fails(): + with pytest.raises(ValueError): + AnimationGroup().begin() + + +def test_empty_animation_fails(): + with pytest.raises(ValueError): + FadeIn(None, run_time=0).begin()