Skip to content

Commit

Permalink
follow-up to #3491, made errors more consistent. fixes #3527
Browse files Browse the repository at this point in the history
  • Loading branch information
behackl committed Dec 17, 2023
1 parent b69e1d7 commit cac608b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion manim/animation/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ def begin(self) -> None:
"""
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"
f"{self} has a run_time of <= 0 seconds, this cannot be rendered correctly. "
"Please set the run_time to be positive"
)
self.starting_mobject = self.create_starting_mobject()
if self.suspend_mobject_updating:
Expand Down
7 changes: 4 additions & 3 deletions manim/animation/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ def get_all_mobjects(self) -> Sequence[Mobject]:
def begin(self) -> None:
if self.run_time <= 0:
tmp = (
"please set a runtime > 0"
"Please set the run_time to be positive"
if len(self.animations) != 0
else "Please add at least one Animation"
else "Please add at least one Animation with positive run_time"
)
raise ValueError(
f"{self} has a runtime of 0 seconds. Which cannot be rendered correctly! {tmp}."
f"{self} has a run_time of 0 seconds, this cannot be "
f"rendered correctly. {tmp}."
)
if self.suspend_mobject_updating:
self.group.suspend_updating()
Expand Down
4 changes: 2 additions & 2 deletions tests/module/animation/test_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ def test_animationgroup_is_passing_remover_to_nested_animationgroups():


def test_empty_animation_group_fails():
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="Please add at least one Animation"):
AnimationGroup().begin()


def test_empty_animation_fails():
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="Please set the run_time to be positive"):
FadeIn(None, run_time=0).begin()

0 comments on commit cac608b

Please sign in to comment.