A community-maintained Python framework for creating mathematical animations.
Small fixes to docstrings. Tiny cleanups. Remove an old unused function. (#834)
Aronec7a962d620e
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.pyindex 134bf7d5e..52049fb67 100644--- a/manim/mobject/mobject.py+++ b/manim/mobject/mobject.py@@ -43,14 +43,13 @@ class Mobject(Container):"""def __init__(self, color=WHITE, name=None, dim=3, target=None, z_index=0, **kwargs):- self.color = color+ self.color = Color(color)self.name = self.__class__.__name__ if name is None else nameself.dim = dimself.target = targetself.z_index = z_indexself.point_hash = Noneself.submobjects = []- self.color = Color(self.color)self.updaters = []self.updating_suspended = Falseself.reset_points()@@ -145,6 +144,15 @@ class Mobject(Container):raise NotImplementedErrordef add_to_back(self, *mobjects):+ """Adds (or moves) all passed mobjects to the back of the scene.++ .. note::++ Technically, this is done by adding (or moving) the mobjects to+ the head of ``self.submobjects``. The head of this list is rendered+ first, which places the corresponding mobjects behind the+ subsequent list members.+ """self.remove(*mobjects)self.submobjects = list(mobjects) + self.submobjectsreturn self@@ -185,17 +193,6 @@ class Mobject(Container):def get_array_attrs(self):return ["points"]- def digest_mobject_attrs(self):- """- Ensures all attributes which are mobjects are included- in the submobjects list.- """- mobject_attrs = [- x for x in list(self.__dict__.values()) if isinstance(x, Mobject)- ]- self.submobjects = list_update(self.submobjects, mobject_attrs)- return self-def apply_over_attr_arrays(self, func):for attr in self.get_array_attrs():setattr(self, attr, func(getattr(self, attr)))@@ -223,7 +220,7 @@ class Mobject(Container):return copy.deepcopy(self)def generate_target(self, use_deepcopy=False):- self.target = None # Prevent exponential explosion+ self.target = None # Prevent unbounded linear recursionif use_deepcopy:self.target = copy.deepcopy(self)else:@@ -600,7 +597,7 @@ class Mobject(Container):return self.rescale_to_fit(height, 1, stretch=True, **kwargs)def stretch_to_fit_depth(self, depth, **kwargs):- return self.rescale_to_fit(depth, 1, stretch=True, **kwargs)+ return self.rescale_to_fit(depth, 2, stretch=True, **kwargs)def set_width(self, width, stretch=False, **kwargs):return self.rescale_to_fit(width, 0, stretch=stretch, **kwargs)diff --git a/manim/mobject/svg/tex_mobject.py b/manim/mobject/svg/tex_mobject.pyindex 435e9f5eb..7eb65746f 100644--- a/manim/mobject/svg/tex_mobject.py+++ b/manim/mobject/svg/tex_mobject.py@@ -217,12 +217,6 @@ class SingleStringMathTex(SVGMobject):tex_template=None,**kwargs,):- self.stroke_width = stroke_width- self.fill_opacity = fill_opacity- self.background_stroke_width = background_stroke_width- self.background_stroke_color = background_stroke_color- self.should_center = should_center- self.height = heightself.organize_left_to_right = organize_left_to_rightself.tex_environment = tex_environmentif tex_template is None:@@ -239,12 +233,12 @@ class SingleStringMathTex(SVGMobject):SVGMobject.__init__(self,file_name=file_name,- should_center=self.should_center,- stroke_width=self.stroke_width,- height=self.height,- fill_opacity=self.fill_opacity,- background_stroke_width=self.background_stroke_width,- background_stroke_color=self.background_stroke_color,+ should_center=should_center,+ stroke_width=stroke_width,+ height=height,+ fill_opacity=fill_opacity,+ background_stroke_width=background_stroke_width,+ background_stroke_color=background_stroke_color,**kwargs,)if self.height is None:@@ -311,9 +305,13 @@ class SingleStringMathTex(SVGMobject):return texdef remove_stray_braces(self, tex):+ r"""+ Makes :class:`~.MathTex` resilient to unmatched braces.++ This is important when the braces in the TeX code are spread over+ multiple arguments as in, e.g., ``MathTex(r"e^{i", r"\tau} = 1")``."""- Makes MathTex resilient to unmatched { at start- """+# "\{" does not count (it's a brace literal), but "\\{" counts (it's a new line and then brace)num_lefts = tex.count("{") - tex.count("\\{") + tex.count("\\\\{")num_rights = tex.count("}") - tex.count("\\}") + tex.count("\\\\}")