A community-maintained Python framework for creating mathematical animations.
fix(config): restore renderer class bases on config update (#4958)
emerarddced9a52fe92c
diff --git a/manim/_config/utils.py b/manim/_config/utils.pyindex 4e7b35d53..8d1de7a9d 100644--- a/manim/_config/utils.py+++ b/manim/_config/utils.py@@ -380,7 +380,12 @@ class ManimConfig(MutableMapping):"""if isinstance(obj, ManimConfig):+ renderer = obj.rendererself._d.update(obj._d)+ if renderer is not None:+ # Apply the renderer through its setter so that the+ # ConvertToOpenGL class bases stay in sync with the config value.+ self.renderer = rendererif obj.tex_template:self.tex_template = obj.tex_templatediff --git a/tests/test_config.py b/tests/test_config.pyindex 0703b31bf..f80b5808e 100644--- a/tests/test_config.py+++ b/tests/test_config.py@@ -6,8 +6,11 @@ from pathlib import Pathimport numpy as npimport pytest-from manim import WHITE, Scene, Square, Tex, Text, tempconfig+from manim import RIGHT, WHITE, Scene, Square, Tex, Text, Vector, tempconfigfrom manim._config.utils import ManimConfig+from manim.constants import RendererType+from manim.mobject.opengl.opengl_vectorized_mobject import OpenGLVMobject+from manim.mobject.types.vectorized_mobject import VMobjectfrom tests.assert_utils import assert_dir_exists, assert_dir_filled, assert_file_exists@@ -34,6 +37,17 @@ def test_tempconfig(config):assert config[k] == v+def test_tempconfig_restores_renderer_class_bases(config):+ with tempconfig({"renderer": "opengl"}):+ assert config.renderer == RendererType.OPENGL+ assert issubclass(Vector, OpenGLVMobject)++ assert config.renderer == RendererType.CAIRO+ assert issubclass(Vector, VMobject)+ assert not issubclass(Vector, OpenGLVMobject)+ Vector(RIGHT)++@pytest.mark.parametrize(("format", "expected_file_extension"),[