diff --git a/manim/scene/scene.py b/manim/scene/scene.py index e3f9925519..249f6b04cc 100644 --- a/manim/scene/scene.py +++ b/manim/scene/scene.py @@ -784,7 +784,6 @@ def update_skipping_status(self): the number of animations that need to be played, and raises an EndSceneEarlyException if they don't correspond. """ - if file_writer_config["from_animation_number"]: if self.num_plays < file_writer_config["from_animation_number"]: file_writer_config["skip_animations"] = True @@ -848,6 +847,10 @@ def handle_caching_wait(func): def wrapper(self, duration=DEFAULT_WAIT_TIME, stop_condition=None): self.revert_to_original_skipping_status() self.update_skipping_status() + if file_writer_config["skip_animations"]: + logger.debug(f"Skipping wait {self.num_plays}") + func(self, duration, stop_condition) + return if not file_writer_config["disable_caching"]: hash_wait = get_hash_from_wait_call( self, self.camera, duration, stop_condition, self.get_mobjects() diff --git a/tests/control_data/videos_data/SceneWithMultiplePlayCallsWithNFlag.json b/tests/control_data/videos_data/SceneWithMultiplePlayCallsWithNFlag.json new file mode 100644 index 0000000000..ad2ea0fac9 --- /dev/null +++ b/tests/control_data/videos_data/SceneWithMultiplePlayCallsWithNFlag.json @@ -0,0 +1,11 @@ +{ + "name": "SceneWithMultiplePlayCallsWithNFlag", + "config": { + "codec_name": "h264", + "width": 854, + "height": 480, + "avg_frame_rate": "15/1", + "duration": "7.000000", + "nb_frames": "105" + } +} \ No newline at end of file diff --git a/tests/control_data/videos_data/SceneWithMultipleWaitCallsWithNFlag.json b/tests/control_data/videos_data/SceneWithMultipleWaitCallsWithNFlag.json new file mode 100644 index 0000000000..05ae9e0384 --- /dev/null +++ b/tests/control_data/videos_data/SceneWithMultipleWaitCallsWithNFlag.json @@ -0,0 +1,11 @@ +{ + "name": "SceneWithMultipleWaitCallsWithNFlag", + "config": { + "codec_name": "h264", + "width": 854, + "height": 480, + "avg_frame_rate": "15/1", + "duration": "5.000000", + "nb_frames": "75" + } +} \ No newline at end of file diff --git a/tests/test_scene_rendering/simple_scenes.py b/tests/test_scene_rendering/simple_scenes.py index 64e6b4f420..b05c27575f 100644 --- a/tests/test_scene_rendering/simple_scenes.py +++ b/tests/test_scene_rendering/simple_scenes.py @@ -15,3 +15,15 @@ def construct(self): for i in range(10): number.become(Integer(i)) self.play(Animation(number)) + + +class SceneWithMultipleWaitCalls(Scene): + def construct(self): + self.play(ShowCreation(Square())) + self.wait(1) + self.play(ShowCreation(Square().shift(DOWN))) + self.wait(1) + self.play(ShowCreation(Square().shift(2 * DOWN))) + self.wait(1) + self.play(ShowCreation(Square().shift(3 * DOWN))) + self.wait(1) diff --git a/tests/test_scene_rendering/test_caching_relalted.py b/tests/test_scene_rendering/test_caching_relalted.py new file mode 100644 index 0000000000..48080f4c1f --- /dev/null +++ b/tests/test_scene_rendering/test_caching_relalted.py @@ -0,0 +1,53 @@ +import os +import pytest +import subprocess +from manim import file_writer_config + +from ..utils.commands import capture +from ..utils.video_tester import video_comparison + + +@video_comparison( + "SceneWithMultipleWaitCallsWithNFlag.json", + "videos/simple_scenes/480p15/SceneWithMultipleWaitCalls.mp4", +) +def test_wait_skip(tmp_path, manim_cfg_file, simple_scenes_path): + # Test for PR #468. Intended to test if wait calls are correctly skipped. + scene_name = "SceneWithMultipleWaitCalls" + command = [ + "python", + "-m", + "manim", + simple_scenes_path, + scene_name, + "-l", + "--media_dir", + str(tmp_path), + "-n", + "3", + ] + out, err, exit_code = capture(command) + assert exit_code == 0, err + + +@video_comparison( + "SceneWithMultiplePlayCallsWithNFlag.json", + "videos/simple_scenes/480p15/SceneWithMultipleCalls.mp4", +) +def test_play_skip(tmp_path, manim_cfg_file, simple_scenes_path): + # Intended to test if play calls are correctly skipped. + scene_name = "SceneWithMultipleCalls" + command = [ + "python", + "-m", + "manim", + simple_scenes_path, + scene_name, + "-l", + "--media_dir", + str(tmp_path), + "-n", + "3", + ] + out, err, exit_code = capture(command) + assert exit_code == 0, err