Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix :attr:.ManimConfig.format not updating movie file extension #3839

Merged
merged 2 commits into from
Jul 13, 2024
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
1 change: 1 addition & 0 deletions manim/_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ def format(self, val: str) -> None:
val,
[None, "png", "gif", "mp4", "mov", "webm"],
)
self.resolve_movie_file_extension(self.transparent)
if self.format == "webm":
logging.getLogger("manim").warning(
"Output format set as webm, this can be slower than other formats",
Expand Down
15 changes: 15 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path

import numpy as np
import pytest

from manim import WHITE, Scene, Square, Tex, Text, tempconfig
from manim._config.utils import ManimConfig
Expand Down Expand Up @@ -33,6 +34,20 @@ def test_tempconfig(config):
assert config[k] == v


@pytest.mark.parametrize(
("format", "expected_file_extension"),
[
("mp4", ".mp4"),
("webm", ".webm"),
("mov", ".mov"),
("gif", ".mp4"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is somewhat odd how differently we are treating the case of .gif, but that's a different discussion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's just a missed edge case, probably worth fixing (wow we have a lot of problems with ManimConfig xD)

],
)
def test_resolve_file_extensions(config, format, expected_file_extension):
config.format = format
assert config.movie_file_extension == expected_file_extension


class MyScene(Scene):
def construct(self):
self.add(Square())
Expand Down
Loading