A community-maintained Python framework for creating mathematical animations.
Hide more private methods from the docs. (#2468)
Laith Bahodi902e7eb4f014
diff --git a/docs/source/reference.rst b/docs/source/reference.rstindex cf9e9b989..19687ac72 100644--- a/docs/source/reference.rst+++ b/docs/source/reference.rst@@ -69,8 +69,6 @@ Mobjectsmanim.mobject.vector_fieldmanim.mobject.svg.bracemanim.mobject.svg.code_mobject- manim.mobject.svg.style_utils- manim.mobject.svg.svg_pathmanim.mobject.svg.svg_mobjectmanim.mobject.svg.tex_mobjectmanim.mobject.svg.text_mobjectdiff --git a/manim/__init__.py b/manim/__init__.pyindex 08b56121c..33d9d24cb 100644--- a/manim/__init__.py+++ b/manim/__init__.py@@ -68,9 +68,7 @@ from .mobject.probability import *from .mobject.shape_matchers import *from .mobject.svg.brace import *from .mobject.svg.code_mobject import *-from .mobject.svg.style_utils import *from .mobject.svg.svg_mobject import *-from .mobject.svg.svg_path import *from .mobject.svg.tex_mobject import *from .mobject.svg.text_mobject import *from .mobject.table import *diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.pyindex 518861a28..80004dd2a 100644--- a/manim/mobject/geometry.py+++ b/manim/mobject/geometry.py@@ -68,7 +68,7 @@ __all__ = [import itertoolsimport mathimport warnings-from typing import Iterable, Optional, Sequence+from typing import Iterable, Optional, Sequence, Unionimport numpy as npfrom colour import Color@@ -316,7 +316,7 @@ class Arc(TipableVMobject):super().__init__(**kwargs)def generate_points(self):- self.set_pre_positioned_points()+ self._set_pre_positioned_points()self.scale(self.radius, about_point=ORIGIN)self.shift(self.arc_center)@@ -325,7 +325,7 @@ class Arc(TipableVMobject):# has to be used.def init_points(self):self.set_points(- Arc.create_quadratic_bezier_points(+ Arc._create_quadratic_bezier_points(angle=self.angle,start_angle=self.start_angle,n_components=self.num_components,@@ -335,7 +335,7 @@ class Arc(TipableVMobject):self.shift(self.arc_center)@staticmethod- def create_quadratic_bezier_points(angle, start_angle=0, n_components=8):+ def _create_quadratic_bezier_points(angle, start_angle=0, n_components=8):samples = np.array([[np.cos(a), np.sin(a), 0]@@ -355,7 +355,7 @@ class Arc(TipableVMobject):points[2::3] = samples[2::2]return points- def set_pre_positioned_points(self):+ def _set_pre_positioned_points(self):anchors = np.array([np.cos(a) * RIGHT + np.sin(a) * UP@@ -956,7 +956,7 @@ class Line(TipableVMobject):self.dim = 3self.buff = buffself.path_arc = path_arc- self.set_start_and_end_attrs(start, end)+ self._set_start_and_end_attrs(start, end)super().__init__(**kwargs)def generate_points(self):@@ -974,15 +974,11 @@ class Line(TipableVMobject):else:self.set_points_as_corners([start, end])- self.account_for_buff(buff)+ self._account_for_buff(buff)init_points = generate_points- def set_path_arc(self, new_value):- self.path_arc = new_value- self.init_points()-- def account_for_buff(self, buff):+ def _account_for_buff(self, buff):if buff == 0:return#@@ -997,19 +993,34 @@ class Line(TipableVMobject):self.pointwise_become_partial(self, buff_proportion, 1 - buff_proportion)return self- def set_start_and_end_attrs(self, start, end):+ def _set_start_and_end_attrs(self, start, end):# If either start or end are Mobjects, this# gives their centers- rough_start = self.pointify(start)- rough_end = self.pointify(end)+ rough_start = self._pointify(start)+ rough_end = self._pointify(end)vect = normalize(rough_end - rough_start)# Now that we know the direction between them,# we can find the appropriate boundary point from# start and end, if they're mobjects- self.start = self.pointify(start, vect)- self.end = self.pointify(end, -vect)+ self.start = self._pointify(start, vect)+ self.end = self._pointify(end, -vect)- def pointify(self, mob_or_point, direction=None):+ def _pointify(+ self,+ mob_or_point: Union["Mobject", Sequence[float]],+ direction: Optional[Sequence[float]] = None,+ ) -> np.ndarray:+ """Transforms a mobject into its corresponding point. Does nothing if a point is passed.++ ``direction`` determines the location of the point along its bounding box in that direction.++ Parameters+ ----------+ mob_or_point+ The mobject or point.+ direction+ The direction.+ """if isinstance(mob_or_point, (Mobject, OpenGLMobject)):mob = mob_or_pointif direction is None:@@ -1018,6 +1029,10 @@ class Line(TipableVMobject):return mob.get_boundary_point(direction)return np.array(mob_or_point)+ def set_path_arc(self, new_value):+ self.path_arc = new_value+ self.init_points()+def put_start_and_end_on(self, start: Sequence[float], end: Sequence[float]):"""Sets starts and end coordinates of a line.Examples@@ -1136,20 +1151,20 @@ class DashedLine(Line):super().__init__(*args, **kwargs)dashes = DashedVMobject(self,- num_dashes=self.calculate_num_dashes(),+ num_dashes=self._calculate_num_dashes(),dashed_ratio=dashed_ratio,)self.clear_points()self.add(*dashes)- def calculate_num_dashes(self) -> int:+ def _calculate_num_dashes(self) -> int:"""Returns the number of dashes in the dashed line.Examples--------::- >>> DashedLine().calculate_num_dashes()+ >>> DashedLine()._calculate_num_dashes()20"""@@ -1411,7 +1426,7 @@ class Arrow(Line):# Arrow.set_stroke is called?self.initial_stroke_width = self.stroke_widthself.add_tip(tip_shape=tip_shape)- self.set_stroke_width_from_length()+ self._set_stroke_width_from_length()def scale(self, factor, scale_tips=False, **kwargs):r"""Scale an arrow, but keep stroke width and arrow tip size fixed.@@ -1446,7 +1461,7 @@ class Arrow(Line):if scale_tips:super().scale(factor, **kwargs)- self.set_stroke_width_from_length()+ self._set_stroke_width_from_length()return selfhas_tip = self.has_tip()@@ -1455,7 +1470,7 @@ class Arrow(Line):old_tips = self.pop_tips()super().scale(factor, **kwargs)- self.set_stroke_width_from_length()+ self._set_stroke_width_from_length()if has_tip:self.add_tip(tip=old_tips[0])@@ -1497,8 +1512,8 @@ class Arrow(Line):max_ratio = self.max_tip_length_to_length_ratioreturn min(self.tip_length, max_ratio * self.get_length())- def set_stroke_width_from_length(self):- """Used internally. Sets stroke width based on length."""+ def _set_stroke_width_from_length(self):+ """Sets stroke width based on length."""max_ratio = self.max_stroke_width_to_length_ratioif config.renderer == "opengl":self.set_stroke(@@ -1586,9 +1601,9 @@ class Vector(Arrow):Returns-------:class:`~.Matrix`-The label."""+# avoiding circular importsfrom .matrix import Matrixdiff --git a/manim/mobject/matrix.py b/manim/mobject/matrix.pyindex 450dbcd99..e5c7b8f57 100644--- a/manim/mobject/matrix.py+++ b/manim/mobject/matrix.py@@ -189,11 +189,11 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):self.left_bracket = left_bracketself.right_bracket = right_bracketsuper().__init__(**kwargs)- mob_matrix = self.matrix_to_mob_matrix(matrix)- self.organize_mob_matrix(mob_matrix)+ mob_matrix = self._matrix_to_mob_matrix(matrix)+ self._organize_mob_matrix(mob_matrix)self.elements = VGroup(*it.chain(*mob_matrix))self.add(self.elements)- self.add_brackets(self.left_bracket, self.right_bracket, **bracket_config)+ self._add_brackets(self.left_bracket, self.right_bracket, **bracket_config)self.center()self.mob_matrix = mob_matrixif self.add_background_rectangles_to_entries:@@ -202,8 +202,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):if self.include_background_rectangle:self.add_background_rectangle()- def matrix_to_mob_matrix(self, matrix):- """Used internally."""+ def _matrix_to_mob_matrix(self, matrix):return [[self.element_to_mobject(item, **self.element_to_mobject_config)@@ -212,8 +211,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):for row in matrix]- def organize_mob_matrix(self, matrix):- """Used internally."""+ def _organize_mob_matrix(self, matrix):for i, row in enumerate(matrix):for j, _ in enumerate(row):mob = matrix[i][j]@@ -223,8 +221,8 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):)return self- def add_brackets(self, left="[", right="]", **kwargs):- """Used internally. Adds the brackets to the Matrix mobject.+ def _add_brackets(self, left="[", right="]", **kwargs):+ """Adds the brackets to the Matrix mobject.See Latex document for various bracket types.diff --git a/manim/mobject/numbers.py b/manim/mobject/numbers.pyindex 521b89d4f..1c94a8621 100644--- a/manim/mobject/numbers.py+++ b/manim/mobject/numbers.py@@ -95,7 +95,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):},)- self.set_submobjects_from_number(number)+ self._set_submobjects_from_number(number)self.init_colors()@property@@ -115,21 +115,21 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):# font_size does not depend on current size.self.scale(font_val / self.font_size)- def set_submobjects_from_number(self, number):+ def _set_submobjects_from_number(self, number):self.number = numberself.submobjects = []- num_string = self.get_num_string(number)- self.add(*(map(self.string_to_mob, num_string)))+ num_string = self._get_num_string(number)+ self.add(*(map(self._string_to_mob, num_string)))# Add non-numerical bitsif self.show_ellipsis:self.add(- self.string_to_mob("\\dots", SingleStringMathTex, color=self.color),+ self._string_to_mob("\\dots", SingleStringMathTex, color=self.color),)if self.unit is not None:- self.unit_sign = self.string_to_mob(self.unit, SingleStringMathTex)+ self.unit_sign = self._string_to_mob(self.unit, SingleStringMathTex)self.add(self.unit_sign)self.arrange(@@ -154,11 +154,11 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):if self.include_background_rectangle:self.add_background_rectangle()- def get_num_string(self, number):+ def _get_num_string(self, number):if isinstance(number, complex):- formatter = self.get_complex_formatter()+ formatter = self._get_complex_formatter()else:- formatter = self.get_formatter()+ formatter = self._get_formatter()num_string = formatter.format(number)rounded_num = np.round(number, self.num_decimal_places)@@ -170,7 +170,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):return num_string- def string_to_mob(+ def _string_to_mob(self, string: str, mob_class: Optional[VMobject] = None, **kwargs):if mob_class is None:@@ -182,7 +182,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):mob.font_size = self._font_sizereturn mob- def get_formatter(self, **kwargs):+ def _get_formatter(self, **kwargs):"""Configuration is based first off instance attributes,but overwritten by any kew word argument. Relevant@@ -215,11 +215,11 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):],)- def get_complex_formatter(self):+ def _get_complex_formatter(self):return "".join([- self.get_formatter(field_name="0.real"),- self.get_formatter(field_name="0.imag", include_sign=True),+ self._get_formatter(field_name="0.real"),+ self._get_formatter(field_name="0.imag", include_sign=True),"i",],)@@ -244,7 +244,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):move_to_point = self.get_edge_center(self.edge_to_fix)old_submobjects = self.submobjects- self.set_submobjects_from_number(number)+ self._set_submobjects_from_number(number)self.font_size = old_font_sizeself.move_to(move_to_point, self.edge_to_fix)for sm1, sm2 in zip(self.submobjects, old_submobjects):diff --git a/manim/mobject/svg/code_mobject.py b/manim/mobject/svg/code_mobject.pyindex 3986c1f7d..2b20a23f9 100644--- a/manim/mobject/svg/code_mobject.py+++ b/manim/mobject/svg/code_mobject.py@@ -195,7 +195,7 @@ class Code(VGroup):self.file_path = Noneself.file_name = file_nameif self.file_name:- self.ensure_valid_file()+ self._ensure_valid_file()with open(self.file_path) as f:self.code_string = f.read()elif code:@@ -206,14 +206,14 @@ class Code(VGroup):)if isinstance(self.style, str):self.style = self.style.lower()- self.gen_html_string()+ self._gen_html_string()strati = self.html_string.find("background:")self.background_color = self.html_string[strati + 12 : strati + 19]- self.gen_code_json()+ self._gen_code_json()- self.code = self.gen_colored_lines()+ self.code = self._gen_colored_lines()if self.insert_line_no:- self.line_numbers = self.gen_line_numbers()+ self.line_numbers = self._gen_line_numbers()self.line_numbers.next_to(self.code, direction=LEFT, buff=self.line_no_buff)if self.background == "rectangle":if self.insert_line_no:@@ -276,7 +276,7 @@ class Code(VGroup):)self.move_to(np.array([0, 0, 0]))- def ensure_valid_file(self):+ def _ensure_valid_file(self):"""Function to validate file."""if self.file_name is None:raise Exception("Must specify file for Code")@@ -294,7 +294,7 @@ class Code(VGroup):)raise OSError(error)- def gen_line_numbers(self):+ def _gen_line_numbers(self):"""Function to generate line_numbers.Returns@@ -319,7 +319,7 @@ class Code(VGroup):i.set_color(self.default_color)return line_numbers- def gen_colored_lines(self):+ def _gen_colored_lines(self):"""Function to generate code.Returns@@ -353,9 +353,9 @@ class Code(VGroup):line_char_index += self.code_json[line_no][word_index][0].__len__()return code- def gen_html_string(self):+ def _gen_html_string(self):"""Function to generate html string with code highlighted and stores in variable html_string."""- self.html_string = hilite_me(+ self.html_string = _hilite_me(self.code_string,self.language,self.style,@@ -381,7 +381,7 @@ class Code(VGroup):) as file:file.write(self.html_string)- def gen_code_json(self):+ def _gen_code_json(self):"""Function to background_color, generate code_json and tab_spaces from html_string.background_color is just background color of displayed code.code_json is 2d array with rows as line numbers@@ -455,7 +455,7 @@ class Code(VGroup):indentation_chars_count = indentation_chars_count + 1self.tab_spaces.append(indentation_chars_count)# print(lines[line_index])- lines[line_index] = self.correct_non_span(lines[line_index])+ lines[line_index] = self._correct_non_span(lines[line_index])# print(lines[line_index])words = lines[line_index].split("<span")for word_index in range(1, words.__len__()):@@ -476,7 +476,7 @@ class Code(VGroup):self.code_json[code_json_line_index].append([text, color])# print(self.code_json)- def correct_non_span(self, line_str):+ def _correct_non_span(self, line_str):"""Function put text color to those strings that don't have one according to background_color of displayed code.Parameters@@ -528,7 +528,7 @@ class Code(VGroup):return line_str-def hilite_me(+def _hilite_me(code,language,style,@@ -577,12 +577,12 @@ def hilite_me(else:html = highlight(code, get_lexer_by_name(language, **{}), formatter)if insert_line_no:- html = insert_line_numbers_in_html(html, line_no_from)+ html = _insert_line_numbers_in_html(html, line_no_from)html = "<!-- HTML generated by Code() -->" + htmlreturn html-def insert_line_numbers_in_html(html, line_no_from):+def _insert_line_numbers_in_html(html, line_no_from):"""Function that inserts line numbers in the highlighted HTML code.Parametersdiff --git a/manim/mobject/svg/svg_mobject.py b/manim/mobject/svg/svg_mobject.pyindex 49edbbfb9..5cc7d2551 100644--- a/manim/mobject/svg/svg_mobject.py+++ b/manim/mobject/svg/svg_mobject.py@@ -1,7 +1,7 @@"""Mobjects generated from an SVG file."""-__all__ = ["SVGMobject", "string_to_numbers"]+__all__ = ["SVGMobject"]import itertools as it@@ -21,7 +21,7 @@ from ...mobject.geometry import Circle, Line, Rectangle, RoundedRectanglefrom ...mobject.types.vectorized_mobject import VMobjectfrom ..opengl_compatibility import ConvertToOpenGLfrom .style_utils import cascade_element_style, parse_style-from .svg_path import SVGPathMobject, string_to_numbers+from .svg_path import SVGPathMobjectclass SVGMobject(VMobject, metaclass=ConvertToOpenGL):@@ -80,7 +80,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):):self.def_map = {}self.file_name = file_name or self.file_name- self.ensure_valid_file()+ self._ensure_valid_file()self.should_center = should_centerself.unpack_groups = unpack_groupsself.path_string_config = (@@ -94,9 +94,9 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):super().__init__(color=color, fill_opacity=fill_opacity, stroke_width=stroke_width, **kwargs)- self.move_into_position(width, height)+ self._move_into_position(width, height)- def ensure_valid_file(self):+ def _ensure_valid_file(self):"""Reads self.file_name and determines whether the given input file_nameis valid."""@@ -134,7 +134,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):"""doc = minidom_parse(self.file_path)for svg in doc.getElementsByTagName("svg"):- mobjects = self.get_mobjects_from(svg, self.generate_style())+ mobjects = self._get_mobjects_from(svg, self.generate_style())if self.unpack_groups:self.add(*mobjects)else:@@ -143,7 +143,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):init_points = generate_points- def get_mobjects_from(+ def _get_mobjects_from(self,element: MinidomElement,inherited_style: Dict[str, str],@@ -183,7 +183,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):elif element.tagName in ["g", "svg", "symbol", "defs"]:result += it.chain(*(- self.get_mobjects_from(+ self._get_mobjects_from(child,style,within_defs=within_defs or is_defs,@@ -194,27 +194,27 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):elif element.tagName == "path":temp = element.getAttribute("d")if temp != "":- result.append(self.path_string_to_mobject(temp, style))+ result.append(self._path_string_to_mobject(temp, style))elif element.tagName == "use":# note, style is calcuated in a different way for `use` elements.- result += self.use_to_mobjects(element, style)+ result += self._use_to_mobjects(element, style)elif element.tagName in ["line"]:- result.append(self.line_to_mobject(element, style))+ result.append(self._line_to_mobject(element, style))elif element.tagName == "rect":- result.append(self.rect_to_mobject(element, style))+ result.append(self._rect_to_mobject(element, style))elif element.tagName == "circle":- result.append(self.circle_to_mobject(element, style))+ result.append(self._circle_to_mobject(element, style))elif element.tagName == "ellipse":- result.append(self.ellipse_to_mobject(element, style))+ result.append(self._ellipse_to_mobject(element, style))elif element.tagName in ["polygon", "polyline"]:- result.append(self.polygon_to_mobject(element, style))+ result.append(self._polygon_to_mobject(element, style))else:pass # TODOresult = [m for m in result if m is not None]group_cls = self.get_group_class()- self.handle_transforms(element, group_cls(*result))+ self._handle_transforms(element, group_cls(*result))if len(result) > 1 and not self.unpack_groups:result = [group_cls(*result)]@@ -241,7 +241,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):style["stroke"] = self.stroke_colorreturn style- def path_string_to_mobject(self, path_string: str, style: dict):+ def _path_string_to_mobject(self, path_string: str, style: dict):"""Converts a SVG path element's ``d`` attribute to a mobject.Parameters@@ -261,7 +261,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):path_string, **self.path_string_config, **parse_style(style))- def attribute_to_float(self, attr):+ def _attribute_to_float(self, attr):"""A helper method which converts the attribute to float.Parameters@@ -279,7 +279,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):)return float(stripped_attr)- def use_to_mobjects(+ def _use_to_mobjects(self,use_element: MinidomElement,local_style: Dict,@@ -318,9 +318,9 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):style = local_style.copy()style.update(def_style)- return self.get_mobjects_from(def_element, style)+ return self._get_mobjects_from(def_element, style)- def line_to_mobject(self, line_element: MinidomElement, style: dict):+ def _line_to_mobject(self, line_element: MinidomElement, style: dict):"""Creates a Line VMobject from an SVG <line> element.Parameters@@ -337,14 +337,14 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):A Line VMobject"""x1, y1, x2, y2 = (- self.attribute_to_float(line_element.getAttribute(key))+ self._attribute_to_float(line_element.getAttribute(key))if line_element.hasAttribute(key)else 0.0for key in ("x1", "y1", "x2", "y2"))return Line([x1, -y1, 0], [x2, -y2, 0], **parse_style(style))- def rect_to_mobject(self, rect_element: MinidomElement, style: dict):+ def _rect_to_mobject(self, rect_element: MinidomElement, style: dict):"""Converts a SVG <rect> command to a VMobject.Parameters@@ -378,14 +378,14 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):if corner_radius == 0:mob = Rectangle(- width=self.attribute_to_float(rect_element.getAttribute("width")),- height=self.attribute_to_float(rect_element.getAttribute("height")),+ width=self._attribute_to_float(rect_element.getAttribute("width")),+ height=self._attribute_to_float(rect_element.getAttribute("height")),**parsed_style,)else:mob = RoundedRectangle(- width=self.attribute_to_float(rect_element.getAttribute("width")),- height=self.attribute_to_float(rect_element.getAttribute("height")),+ width=self._attribute_to_float(rect_element.getAttribute("width")),+ height=self._attribute_to_float(rect_element.getAttribute("height")),corner_radius=corner_radius,**parsed_style,)@@ -393,7 +393,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):mob.shift(mob.get_center() - mob.get_corner(UP + LEFT))return mob- def circle_to_mobject(self, circle_element: MinidomElement, style: dict):+ def _circle_to_mobject(self, circle_element: MinidomElement, style: dict):"""Creates a Circle VMobject from a SVG <circle> command.Parameters@@ -410,14 +410,14 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):A Circle VMobject"""x, y, r = (- self.attribute_to_float(circle_element.getAttribute(key))+ self._attribute_to_float(circle_element.getAttribute(key))if circle_element.hasAttribute(key)else 0.0for key in ("cx", "cy", "r"))return Circle(radius=r, **parse_style(style)).shift(x * RIGHT + y * DOWN)- def ellipse_to_mobject(self, circle_element: MinidomElement, style: dict):+ def _ellipse_to_mobject(self, circle_element: MinidomElement, style: dict):"""Creates a stretched Circle VMobject from a SVG <circle> pathcommand.@@ -435,7 +435,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):A Circle VMobject"""x, y, rx, ry = (- self.attribute_to_float(circle_element.getAttribute(key))+ self._attribute_to_float(circle_element.getAttribute(key))if circle_element.hasAttribute(key)else 0.0for key in ("cx", "cy", "rx", "ry")@@ -446,7 +446,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):.shift(x * RIGHT + y * DOWN))- def polygon_to_mobject(self, polygon_element: MinidomElement, style: dict):+ def _polygon_to_mobject(self, polygon_element: MinidomElement, style: dict):"""Constructs a VMobject from a SVG <polygon> element.Parameters@@ -469,9 +469,9 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):path_string = "M" + path_stringif polygon_element.tagName == "polygon":path_string = path_string + "Z"- return self.path_string_to_mobject(path_string, style)+ return self._path_string_to_mobject(path_string, style)- def handle_transforms(self, element, mobject):+ def _handle_transforms(self, element, mobject):"""Applies the SVG transform to the specified mobject. Transforms include:``matrix``, ``translate``, and ``scale``.@@ -485,9 +485,9 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):"""if element.hasAttribute("x") and element.hasAttribute("y"):- x = self.attribute_to_float(element.getAttribute("x"))+ x = self._attribute_to_float(element.getAttribute("x"))# Flip y- y = -self.attribute_to_float(element.getAttribute("y"))+ y = -self._attribute_to_float(element.getAttribute("y"))mobject.shift(x * RIGHT + y * UP)transform_attr_value = element.getAttribute("transform")@@ -552,17 +552,17 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):op_name,)- def flatten(self, input_list):+ def _flatten(self, input_list):"""A helper method to flatten the ``input_list`` into an 1D array."""output_list = []for i in input_list:if isinstance(i, list):- output_list.extend(self.flatten(i))+ output_list.extend(self._flatten(i))else:output_list.append(i)return output_list- def move_into_position(self, width, height):+ def _move_into_position(self, width, height):"""Uses the SVGMobject's config dictionary to set the Mobject'swidth, height, and/or center it. Use ``width``, ``height``, and``should_center`` respectively to modify this.diff --git a/manim/mobject/svg/tex_mobject.py b/manim/mobject/svg/tex_mobject.pyindex 07017ad1c..e9fd3e2b1 100644--- a/manim/mobject/svg/tex_mobject.py+++ b/manim/mobject/svg/tex_mobject.py@@ -87,7 +87,7 @@ class SingleStringMathTex(SVGMobject):assert isinstance(tex_string, str)self.tex_string = tex_stringfile_name = tex_to_svg_file(- self.get_modified_expression(tex_string),+ self._get_modified_expression(tex_string),environment=self.tex_environment,tex_template=self.tex_template,)@@ -111,7 +111,7 @@ class SingleStringMathTex(SVGMobject):self.font_size = self._font_sizeif self.organize_left_to_right:- self.organize_submobjects_left_to_right()+ self._organize_submobjects_left_to_right()def __repr__(self):return f"{type(self).__name__}({repr(self.tex_string)})"@@ -133,13 +133,13 @@ class SingleStringMathTex(SVGMobject):# font_size does not depend on current size.self.scale(font_val / self.font_size)- def get_modified_expression(self, tex_string):+ def _get_modified_expression(self, tex_string):result = tex_stringresult = result.strip()- result = self.modify_special_strings(result)+ result = self._modify_special_strings(result)return result- def modify_special_strings(self, tex):+ def _modify_special_strings(self, tex):tex = tex.strip()should_add_filler = reduce(op.or_,@@ -180,7 +180,7 @@ class SingleStringMathTex(SVGMobject):tex = tex.replace("\\left", "\\big")tex = tex.replace("\\right", "\\big")- tex = self.remove_stray_braces(tex)+ tex = self._remove_stray_braces(tex)for context in ["array"]:begin_in = ("\\begin{%s}" % context) in tex@@ -192,7 +192,7 @@ class SingleStringMathTex(SVGMobject):tex = ""return tex- def remove_stray_braces(self, tex):+ def _remove_stray_braces(self, tex):r"""Makes :class:`~.MathTex` resilient to unmatched braces.@@ -211,6 +211,10 @@ class SingleStringMathTex(SVGMobject):num_rights += 1return tex+ def _organize_submobjects_left_to_right(self):+ self.sort(lambda p: p[0])+ return self+def get_tex_string(self):return self.tex_string@@ -219,10 +223,6 @@ class SingleStringMathTex(SVGMobject):# specialized path_string mobjectreturn TexSymbol(path_string, **self.path_string_config, **parse_style(style))- def organize_submobjects_left_to_right(self):- self.sort(lambda p: p[0])- return self-def init_colors(self, propagate_colors=True):super().init_colors(propagate_colors=propagate_colors)@@ -277,7 +277,7 @@ class MathTex(SingleStringMathTex):self.tex_to_color_map = {}self.tex_environment = tex_environmentself.brace_notation_split_occurred = False- self.tex_strings = self.break_up_tex_strings(tex_strings)+ self.tex_strings = self._break_up_tex_strings(tex_strings)try:super().__init__(self.arg_separator.join(self.tex_strings),@@ -285,7 +285,7 @@ class MathTex(SingleStringMathTex):tex_template=self.tex_template,**kwargs,)- self.break_up_by_substrings()+ self._break_up_by_substrings()except ValueError as compilation_error:if self.brace_notation_split_occurred:logger.error(@@ -304,9 +304,9 @@ class MathTex(SingleStringMathTex):self.set_color_by_tex_to_color_map(self.tex_to_color_map)if self.organize_left_to_right:- self.organize_submobjects_left_to_right()+ self._organize_submobjects_left_to_right()- def break_up_tex_strings(self, tex_strings):+ def _break_up_tex_strings(self, tex_strings):# Separate out anything surrounded in double bracespre_split_length = len(tex_strings)tex_strings = [re.split("{{(.*?)}}", str(t)) for t in tex_strings]@@ -335,7 +335,7 @@ class MathTex(SingleStringMathTex):pieces = tex_stringsreturn [p for p in pieces if p]- def break_up_by_substrings(self):+ def _break_up_by_substrings(self):"""Reorganize existing submobjects one layerdeeper based on the structure of tex_strings (as a listdiff --git a/manim/mobject/svg/text_mobject.py b/manim/mobject/svg/text_mobject.pyindex 33c1c0cb2..f5e478939 100644--- a/manim/mobject/svg/text_mobject.py+++ b/manim/mobject/svg/text_mobject.py@@ -150,7 +150,7 @@ class Paragraph(VGroup):lines_str = "\n".join(list(text))self.lines_text = Text(lines_str, line_spacing=line_spacing, **config)lines_str_list = lines_str.split("\n")- self.chars = self.gen_chars(lines_str_list)+ self.chars = self._gen_chars(lines_str_list)chars_lines_text_list = self.get_group_class()()char_index_counter = 0@@ -177,9 +177,9 @@ class Paragraph(VGroup):self.add(*self.lines[0])self.move_to(np.array([0, 0, 0]))if self.alignment:- self.set_all_lines_alignments(self.alignment)+ self._set_all_lines_alignments(self.alignment)- def gen_chars(self, lines_str_list):+ def _gen_chars(self, lines_str_list):"""Function to convert plain string to 2d-VGroup of chars. 2d-VGroup mean "VGroup of VGroup".Parameters@@ -206,7 +206,7 @@ class Paragraph(VGroup):char_index_counter += lines_str_list[line_no].__len__() + 1return chars- def set_all_lines_alignments(self, alignment):+ def _set_all_lines_alignments(self, alignment):"""Function to set all line's alignment to a specific value.Parameters@@ -215,10 +215,10 @@ class Paragraph(VGroup):Defines the alignment of paragraph. Possible values are "left", "right", "center"."""for line_no in range(0, self.lines[0].__len__()):- self.change_alignment_for_a_line(alignment, line_no)+ self._change_alignment_for_a_line(alignment, line_no)return self- def set_line_alignment(self, alignment, line_no):+ def _set_line_alignment(self, alignment, line_no):"""Function to set one line's alignment to a specific value.Parameters@@ -228,10 +228,10 @@ class Paragraph(VGroup):line_no : :class:`int`Defines the line number for which we want to set given alignment."""- self.change_alignment_for_a_line(alignment, line_no)+ self._change_alignment_for_a_line(alignment, line_no)return self- def set_all_lines_to_initial_positions(self):+ def _set_all_lines_to_initial_positions(self):"""Set all lines to their initial positions."""self.lines[1] = [None for _ in range(self.lines[0].__len__())]for line_no in range(0, self.lines[0].__len__()):@@ -240,7 +240,7 @@ class Paragraph(VGroup):)return self- def set_line_to_initial_position(self, line_no):+ def _set_line_to_initial_position(self, line_no):"""Function to set one line to initial positions.Parameters@@ -252,7 +252,7 @@ class Paragraph(VGroup):self[line_no].move_to(self.get_center() + self.lines_initial_positions[line_no])return self- def change_alignment_for_a_line(self, alignment, line_no):+ def _change_alignment_for_a_line(self, alignment, line_no):"""Function to change one line's alignment to a specific value.Parameters@@ -469,7 +469,7 @@ class Text(SVGMobject):)else:self.line_spacing = self._font_size + self._font_size * self.line_spacing- file_name = self.text2svg()+ file_name = self._text2svg()PangoUtils.remove_last_M(file_name)super().__init__(file_name,@@ -483,7 +483,7 @@ class Text(SVGMobject):)self.text = textif self.disable_ligatures:- self.submobjects = [*self.gen_chars()]+ self.submobjects = [*self._gen_chars()]self.chars = self.get_group_class()(*self.submobjects)self.text = text_without_tabs.replace(" ", "").replace("\n", "")if config.renderer == "opengl":@@ -533,7 +533,7 @@ class Text(SVGMobject):else:self.scale(font_val / self.font_size)- def gen_chars(self):+ def _gen_chars(self):chars = self.get_group_class()()submobjects_char_index = 0for char_index in range(self.text.__len__()):@@ -551,8 +551,8 @@ class Text(SVGMobject):submobjects_char_index += 1return chars- def find_indexes(self, word: str, text: str):- """Internally used function. Finds the indexes of ``text`` in ``word``."""+ def _find_indexes(self, word: str, text: str):+ """Finds the indexes of ``text`` in ``word``."""temp = re.match(r"\[([0-9\-]{0,}):([0-9\-]{0,})\]", word)if temp:start = int(temp.group(1)) if temp.group(1) != "" else 0@@ -572,11 +572,11 @@ class Text(SVGMobject):until="v0.15.0",message="This was internal function, you shouldn't be using it anyway.",)- def set_color_by_t2c(self, t2c=None):- """Internally used function. Sets color for specified strings."""+ def _set_color_by_t2c(self, t2c=None):+ """Sets color for specified strings."""t2c = t2c if t2c else self.t2cfor word, color in list(t2c.items()):- for start, end in self.find_indexes(word, self.text):+ for start, end in self._find_indexes(word, self.text):self.chars[start:end].set_color(color)@deprecated(@@ -584,18 +584,16 @@ class Text(SVGMobject):until="v0.15.0",message="This was internal function, you shouldn't be using it anyway.",)- def set_color_by_t2g(self, t2g=None):- """Internally used. Sets gradient colors for specified+ def _set_color_by_t2g(self, t2g=None):+ """Sets gradient colors for specifiedstrings. Behaves similarly to ``set_color_by_t2c``."""t2g = t2g if t2g else self.t2gfor word, gradient in list(t2g.items()):- for start, end in self.find_indexes(word, self.text):+ for start, end in self._find_indexes(word, self.text):self.chars[start:end].set_color_by_gradient(*gradient)- def text2hash(self):- """Internally used function.- Generates ``sha256`` hash for file name.- """+ def _text2hash(self):+ """Generates ``sha256`` hash for file name."""settings = ("PANGO" + self.font + self.slant + self.weight + self.color) # to differentiate Text and CairoText@@ -641,7 +639,7 @@ class Text(SVGMobject):for t2x, arg in t2xs}- for start, end in self.find_indexes(word, self.text):+ for start, end in self._find_indexes(word, self.text):settings.append(TextSetting(start, end, **setting_args))return settings@@ -665,15 +663,14 @@ class Text(SVGMobject):if len(gradient) != 1else len(word) * gradient)- for start, end in self.find_indexes(word, self.text):+ for start, end in self._find_indexes(word, self.text):for i in range(start, end):args["color"] = colors[i - start].hexsettings.append(TextSetting(i, i + 1, **args))return settings- def text2settings(self):- """Internally used function. Converts the texts and styles- to a setting for parsing."""+ def _text2settings(self):+ """Converts the texts and styles to a setting for parsing."""t2xs = [(self.t2f, "font"),(self.t2s, "slant"),@@ -716,7 +713,7 @@ class Text(SVGMobject):if re.search(r"\n", self.text):line_num = 0- for start, end in self.find_indexes("\n", self.text):+ for start, end in self._find_indexes("\n", self.text):for setting in settings:if setting.line_num == -1:setting.line_num = line_num@@ -734,7 +731,7 @@ class Text(SVGMobject):setting.line_num = 0return settings- def text2svg(self):+ def _text2svg(self):"""Convert the text to SVG using Pango."""size = self._font_sizeline_spacing = self.line_spacing@@ -744,13 +741,13 @@ class Text(SVGMobject):dir_name = config.get_dir("text_dir")if not os.path.exists(dir_name):os.makedirs(dir_name)- hash_name = self.text2hash()+ hash_name = self._text2hash()file_name = os.path.join(dir_name, hash_name) + ".svg"if os.path.exists(file_name):svg_file = file_nameelse:- settings = self.text2settings()+ settings = self._text2settings()width = config["pixel_width"]height = config["pixel_height"]@@ -1117,12 +1114,12 @@ class MarkupText(SVGMobject):if "\t" in text:text_without_tabs = text.replace("\t", " " * self.tab_width)- colormap = self.extract_color_tags()+ colormap = self._extract_color_tags()if len(colormap) > 0:logger.warning('Using <color> tags in MarkupText is deprecated. Please use <span foreground="..."> instead.',)- gradientmap = self.extract_gradient_tags()+ gradientmap = self._extract_gradient_tags()validate_error = MarkupUtils.validate(self.text)if validate_error:raise ValueError(validate_error)@@ -1134,7 +1131,7 @@ class MarkupText(SVGMobject):else:self.line_spacing = self._font_size + self._font_size * self.line_spacing- file_name = self.text2svg()+ file_name = self._text2svg()PangoUtils.remove_last_M(file_name)super().__init__(file_name,@@ -1213,7 +1210,7 @@ class MarkupText(SVGMobject):else:self.scale(font_val / self.font_size)- def text2hash(self):+ def _text2hash(self):"""Generates ``sha256`` hash for file name."""settings = ("MARKUPPANGO" + self.font + self.slant + self.weight + self.color@@ -1226,7 +1223,7 @@ class MarkupText(SVGMobject):hasher.update(id_str.encode())return hasher.hexdigest()[:16]- def text2svg(self):+ def _text2svg(self):"""Convert the text to SVG using Pango."""size = self._font_sizeline_spacing = self.line_spacing@@ -1236,7 +1233,7 @@ class MarkupText(SVGMobject):dir_name = config.get_dir("text_dir")if not os.path.exists(dir_name):os.makedirs(dir_name)- hash_name = self.text2hash()+ hash_name = self._text2hash()file_name = os.path.join(dir_name, hash_name) + ".svg"if os.path.exists(file_name):svg_file = file_name@@ -1278,7 +1275,7 @@ class MarkupText(SVGMobject):count += 1return count- def extract_gradient_tags(self):+ def _extract_gradient_tags(self):"""Used to determine which parts (if any) of the string should be formattedwith a gradient.@@ -1317,7 +1314,7 @@ class MarkupText(SVGMobject):else:return Colors[col.lower()].value- def extract_color_tags(self):+ def _extract_color_tags(self):"""Used to determine which parts (if any) of the string should be formattedwith a custom color.diff --git a/manim/mobject/three_dimensions.py b/manim/mobject/three_dimensions.pyindex 659661ca0..9ceaf1a78 100644--- a/manim/mobject/three_dimensions.py+++ b/manim/mobject/three_dimensions.py@@ -107,12 +107,12 @@ class Surface(VGroup, metaclass=ConvertToOpenGL):pre_function_handle_to_anchor_scale_factor)self.func = func- self.setup_in_uv_space()+ self._setup_in_uv_space()self.apply_function(lambda p: func(p[0], p[1]))if self.should_make_jagged:self.make_jagged()- def get_u_values_and_v_values(self):+ def _get_u_values_and_v_values(self):res = tuplify(self.resolution)if len(res) == 1:u_res = v_res = res[0]@@ -124,8 +124,8 @@ class Surface(VGroup, metaclass=ConvertToOpenGL):return u_values, v_values- def setup_in_uv_space(self):- u_values, v_values = self.get_u_values_and_v_values()+ def _setup_in_uv_space(self):+ u_values, v_values = self._get_u_values_and_v_values()faces = VGroup()for i in range(len(u_values) - 1):for j in range(len(v_values) - 1):