From c56fb6dd18977a3394a17c054ed63abc3a01c32f Mon Sep 17 00:00:00 2001 From: Benjamin Hackl Date: Tue, 12 Nov 2024 23:28:32 +0100 Subject: [PATCH 1/3] make checks involving from/upto_animation_number more explicit --- manim/renderer/cairo_renderer.py | 8 ++++---- manim/renderer/opengl_renderer.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manim/renderer/cairo_renderer.py b/manim/renderer/cairo_renderer.py index b97fa50299..0b13fb8638 100644 --- a/manim/renderer/cairo_renderer.py +++ b/manim/renderer/cairo_renderer.py @@ -252,13 +252,13 @@ def update_skipping_status(self): if config["save_last_frame"]: self.skip_animations = True if ( - config["from_animation_number"] - and self.num_plays < config["from_animation_number"] + config.from_animation_number > 0 + and self.num_plays < config.from_animation_number ): self.skip_animations = True if ( - config["upto_animation_number"] - and self.num_plays > config["upto_animation_number"] + config.upto_animation_number >= 0 + and self.num_plays > config.upto_animation_number ): self.skip_animations = True raise EndSceneEarlyException() diff --git a/manim/renderer/opengl_renderer.py b/manim/renderer/opengl_renderer.py index ead0d0d82b..2f0ad398fe 100644 --- a/manim/renderer/opengl_renderer.py +++ b/manim/renderer/opengl_renderer.py @@ -400,13 +400,13 @@ def update_skipping_status(self): if self.file_writer.sections[-1].skip_animations: self.skip_animations = True if ( - config["from_animation_number"] - and self.num_plays < config["from_animation_number"] + config.from_animation_number > 0 + and self.num_plays < config.from_animation_number ): self.skip_animations = True if ( - config["upto_animation_number"] - and self.num_plays > config["upto_animation_number"] + config.upto_animation_number >= 0 + and self.num_plays > config.upto_animation_number ): self.skip_animations = True raise EndSceneEarlyException() From 4901a099e6d68d3b4e63d70964a05f9b88923231 Mon Sep 17 00:00:00 2001 From: Benjamin Hackl Date: Tue, 12 Nov 2024 23:28:58 +0100 Subject: [PATCH 2/3] add test for flag -n 0,0 for only rendering first animation --- tests/test_config.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_config.py b/tests/test_config.py index a245f4027a..7ebc4914eb 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -244,3 +244,26 @@ def test_tex_template_file(tmp_path): assert Path(custom_config.tex_template_file) == tex_file assert custom_config.tex_template.body == "Hello World!" + + +def test_from_to_animations_only_first_animation(config): + config: ManimConfig + config.from_animation_number = 0 + config.upto_animation_number = 0 + + class SceneWithTwoAnimations(Scene): + def construct(self): + self.after_first_animation = False + s = Square() + self.add(s) + self.play(s.animate.scale(2)) + self.renderer.update_skipping_status() + self.after_first_animation = True + self.play(s.animate.scale(2)) + + + scene = SceneWithTwoAnimations() + scene.render() + + assert scene.after_first_animation is False + \ No newline at end of file From aadf29eda5ea11af5530ae4f6d3fa9492ed522ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 22:31:29 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_config.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index 7ebc4914eb..0703b31bf4 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -260,10 +260,8 @@ def construct(self): self.renderer.update_skipping_status() self.after_first_animation = True self.play(s.animate.scale(2)) - - + scene = SceneWithTwoAnimations() scene.render() assert scene.after_first_animation is False - \ No newline at end of file