Skip to content

Commit 2555bc7

Browse files
committed
Move Scene.update_skipping_status()
1 parent b1f8f6b commit 2555bc7

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

manim/renderer/cairo_renderer.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
from .. import file_writer_config
33
from ..utils.iterables import list_update
4+
from ..utils.exceptions import EndSceneEarlyException
45

56

67
class CairoRenderer:
@@ -60,3 +61,19 @@ def get_frame(self):
6061
The shape of the array is height x width x 3
6162
"""
6263
return np.array(self.camera.pixel_array)
64+
65+
def update_skipping_status(self):
66+
"""
67+
This method is used internally to check if the current
68+
animation needs to be skipped or not. It also checks if
69+
the number of animations that were played correspond to
70+
the number of animations that need to be played, and
71+
raises an EndSceneEarlyException if they don't correspond.
72+
"""
73+
if file_writer_config["from_animation_number"]:
74+
if self.scene.num_plays < file_writer_config["from_animation_number"]:
75+
file_writer_config["skip_animations"] = True
76+
if file_writer_config["upto_animation_number"]:
77+
if self.scene.num_plays > file_writer_config["upto_animation_number"]:
78+
file_writer_config["skip_animations"] = True
79+
raise EndSceneEarlyException()

manim/scene/scene.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Basic canvas for animations."""
22

33

4-
__all__ = ["Scene", "EndSceneEarlyException"]
4+
__all__ = ["Scene"]
55

66

77
import inspect
@@ -25,6 +25,7 @@
2525
from ..utils.hashing import get_hash_from_play_call, get_hash_from_wait_call
2626
from ..utils.family import extract_mobject_family_members
2727
from ..renderer.cairo_renderer import CairoRenderer
28+
from ..utils.exceptions import EndSceneEarlyException
2829

2930

3031
class Scene(Container):
@@ -732,22 +733,6 @@ def compile_method(state):
732733

733734
return animations
734735

735-
def update_skipping_status(self):
736-
"""
737-
This method is used internally to check if the current
738-
animation needs to be skipped or not. It also checks if
739-
the number of animations that were played correspond to
740-
the number of animations that need to be played, and
741-
raises an EndSceneEarlyException if they don't correspond.
742-
"""
743-
if file_writer_config["from_animation_number"]:
744-
if self.num_plays < file_writer_config["from_animation_number"]:
745-
file_writer_config["skip_animations"] = True
746-
if file_writer_config["upto_animation_number"]:
747-
if self.num_plays > file_writer_config["upto_animation_number"]:
748-
file_writer_config["skip_animations"] = True
749-
raise EndSceneEarlyException()
750-
751736
def begin_animations(self, animations):
752737
"""
753738
This method begins the list of animations that is passed,
@@ -821,7 +806,7 @@ def play(self, *args, **kwargs):
821806

822807
def cached_play(self, *args, **kwargs):
823808
self.revert_to_original_skipping_status()
824-
self.update_skipping_status()
809+
self.renderer.update_skipping_status()
825810
animations = self.compile_play_args_to_animation_list(*args, **kwargs)
826811
self.add_mobjects_from_animations(animations)
827812
if file_writer_config["skip_animations"]:
@@ -1078,7 +1063,3 @@ def show_frame(self):
10781063
"""
10791064
self.renderer.update_frame(ignore_skipping=True)
10801065
self.camera.get_image().show()
1081-
1082-
1083-
class EndSceneEarlyException(Exception):
1084-
pass

manim/utils/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class EndSceneEarlyException(Exception):
2+
pass

0 commit comments

Comments
 (0)