Revert accidental renaming of OpenGLMobject to Mobject and duplicated .set_default() - now the example scene works again

This commit is contained in:
Francisco Manríquez Novoa 2026-02-08 21:29:53 -03:00
commit fbe41c1902

View file

@ -154,7 +154,7 @@ _ShaderDType: TypeAlias = np.void
_ShaderData: TypeAlias = npt.NDArray[_ShaderDType]
class Mobject:
class OpenGLMobject:
"""Mathematical Object: base class for objects that can be displayed on screen.
Attributes
@ -173,17 +173,6 @@ class Mobject:
dim: int = 3
animation_overrides = {}
@classmethod
def __init_subclass__(cls, **kwargs) -> None:
super().__init_subclass__(**kwargs)
cls.animation_overrides: dict[
type[Animation],
FunctionOverride,
] = {}
cls._add_intrinsic_animation_overrides()
cls._original__init__ = cls.__init__
# WARNING: when changing a parameter here, be sure to update the
# TypedDict above so that autocomplete works for users
def __init__(
@ -236,6 +225,12 @@ class Mobject:
@classmethod
def __init_subclass__(cls, **kwargs: Any) -> None:
super().__init_subclass__(**kwargs)
# cls.animation_overrides: dict[
# type[Animation],
# FunctionOverride,
# ] = {}
# cls._add_intrinsic_animation_overrides()
cls._original__init__ = cls.__init__
def __str__(self) -> str:
@ -373,6 +368,7 @@ class Mobject:
if method_name.startswith("__"):
continue
print(cls, method_name)
method = getattr(cls, method_name)
if hasattr(method, "_override_animation"):
animation_class = method._override_animation
@ -411,56 +407,6 @@ class Mobject:
f"{override_func.__qualname__}.",
)
@classmethod
def set_default(cls, **kwargs) -> None:
"""Sets the default values of keyword arguments.
If this method is called without any additional keyword
arguments, the original default values of the initialization
method of this class are restored.
Parameters
----------
kwargs
Passing any keyword argument will update the default
values of the keyword arguments of the initialization
function of this class.
Examples
--------
::
>>> from manim import Square, GREEN
>>> Square.set_default(color=GREEN, fill_opacity=0.25)
>>> s = Square()
>>> s.color, s.fill_opacity
(ManimColor('#83C167'), 0.25)
>>> Square.set_default()
>>> s = Square()
>>> s.color, s.fill_opacity
(ManimColor('#FFFFFF'), 0.0)
.. manim:: ChangedDefaultTextcolor
:save_last_frame:
config.background_color = WHITE
class ChangedDefaultTextcolor(Scene):
def construct(self):
Text.set_default(color=BLACK)
self.add(Text("Changing default values is easy!"))
# we revert the colour back to the default to prevent a bug in the docs.
Text.set_default(color=WHITE)
"""
if kwargs:
cls.__init__ = partialmethod(cls.__init__, **kwargs)
else:
cls.__init__ = cls._original__init__
# https://github.com/python/typing/issues/802
# so we hack around it by doing | Self
# but this causes issues in Scene.play which only