Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

fix the -s flag when there are no animations

leotrse74289e57955
diff --git a/manim/config/utils.py b/manim/config/utils.py
index 68701115a..e1fa020a7 100644
--- a/manim/config/utils.py
+++ b/manim/config/utils.py
@@ -813,8 +813,6 @@ class ManimConfig(MutableMapping):
class ManimFrame(Mapping):
_OPTS = {
- 'pixel_width',
- 'pixel_height',
'pixel_width',
'pixel_height',
'aspect_ratio',
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
index bd69cc7e1..d9f3dc88b 100644
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -486,6 +486,8 @@ class SceneFileWriter(object):
:class:`bool`
Whether the file exists.
"""
+ if not hasattr(self, 'partial_movie_directory'):
+ return False
path = os.path.join(
self.partial_movie_directory,
"{}{}".format(hash_invocation, config['movie_file_extension']),
diff --git a/tests/test_scene_rendering/simple_scenes.py b/tests/test_scene_rendering/simple_scenes.py
index b05c27575..6522d4cf6 100644
--- a/tests/test_scene_rendering/simple_scenes.py
+++ b/tests/test_scene_rendering/simple_scenes.py
@@ -27,3 +27,10 @@ class SceneWithMultipleWaitCalls(Scene):
self.wait(1)
self.play(ShowCreation(Square().shift(3 * DOWN)))
self.wait(1)
+
+
+class NoAnimations(Scene):
+ def construct(self):
+ dot = Dot().set_color(GREEN)
+ self.add(dot)
+ self.wait(1)
diff --git a/tests/test_scene_rendering/test_cli_flags.py b/tests/test_scene_rendering/test_cli_flags.py
index e9fb2a3fc..dba46483c 100644
--- a/tests/test_scene_rendering/test_cli_flags.py
+++ b/tests/test_scene_rendering/test_cli_flags.py
@@ -64,6 +64,31 @@ def test_n_flag(tmp_path, simple_scenes_path):
assert exit_code == 0, err
+def test_s_flag_no_animations(tmp_path, manim_cfg_file, simple_scenes_path):
+ scene_name = "NoAnimations"
+ command = [
+ "python",
+ "-m",
+ "manim",
+ simple_scenes_path,
+ scene_name,
+ "-ql",
+ "-s",
+ "--media_dir",
+ str(tmp_path),
+ ]
+ out, err, exit_code = capture(command)
+ assert exit_code == 0, err
+
+ print(list((tmp_path / 'images' / 'simple_scenes').iterdir()))
+
+ is_empty = not any((tmp_path / 'videos').iterdir())
+ assert is_empty, 'running manim with -s flag rendered a video'
+
+ is_empty = not any((tmp_path / 'images' / 'simple_scenes').iterdir())
+ assert not is_empty, 'running manim with -s flag did not render an image'
+
+
def test_s_flag(tmp_path, manim_cfg_file, simple_scenes_path):
scene_name = "SquareToCircle"
command = [