Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion manim/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
12 changes: 12 additions & 0 deletions tests/test_scene_rendering/simple_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
53 changes: 53 additions & 0 deletions tests/test_scene_rendering/test_caching_relalted.py
Original file line number Diff line number Diff line change
@@ -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