From e2e51672a59a836d4d9cf263a0a0b2b26097290e Mon Sep 17 00:00:00 2001 From: Irvanal Haq Date: Tue, 4 Feb 2025 15:34:41 +0700 Subject: [PATCH 1/3] improve align_data() docstring --- manim/mobject/mobject.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index 6ad3ece777..217e037afb 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -2705,7 +2705,7 @@ def construct(self): # Alignment def align_data(self, mobject: Mobject, skip_point_alignment: bool = False) -> None: - """Aligns the data of this mobject with another mobject. + """Aligns the family structure and data of this mobject with another mobject. Afterwards, the two mobjects will have the same number of submobjects (see :meth:`.align_submobjects`), the same parent structure (see @@ -2719,6 +2719,31 @@ def align_data(self, mobject: Mobject, skip_point_alignment: bool = False) -> No skip_point_alignment Controls whether or not the computationally expensive point alignment is skipped (default: False). + + + .. note:: + + This method is primarily used internally by :meth:`.become` and the + :class:`~.Transform` animation to ensure that mobjects are structurally + compatible before transformation. + + Examples + -------- + :: + + >>> from manim import Rectangle, Line, ORIGIN, RIGHT + >>> rect = Rectangle(width=4.0, height=2.0, grid_xstep=1.0, grid_ystep=0.5) + >>> line = Line(start=ORIGIN,end=RIGHT) + >>> line.align_data(rect) + >>> len(line.get_family()) == len(rect.get_family()) + True + >>> line.get_num_points() == rect.get_num_points() + True + + See also + -------- + :class:`~.Transform`, :meth:`~.Mobject.become`, :meth:`~.VMobject.align_points`, :meth:`~.Mobject.get_family` + """ self.null_point_align(mobject) self.align_submobjects(mobject) From 5b31b0153c0372cf61e6f7816b7d5aca12f2f625 Mon Sep 17 00:00:00 2001 From: Irvanal Haq Date: Sun, 20 Apr 2025 23:32:31 +0700 Subject: [PATCH 2/3] add relate See also in .become() --- manim/mobject/mobject.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index 217e037afb..b24dc53198 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -2968,6 +2968,10 @@ def construct(self): >>> result = rect.copy().become(circ, match_center=True) >>> np.allclose(rect.get_center(), result.get_center()) True + + See also + -------- + :meth:`~.Mobject.align_data`, :meth:`~.VMobject.interpolate_color` """ mobject = mobject.copy() if stretch: From 2e7066d54e109b84b9e34b48f594010a16887ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Manr=C3=ADquez=20Novoa?= <49853152+chopan050@users.noreply.github.com> Date: Wed, 21 May 2025 17:57:35 -0400 Subject: [PATCH 3/3] Small changes to docstring of Mobject.align_data() --- manim/mobject/mobject.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py index b24dc53198..81cdafa48b 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -2708,8 +2708,8 @@ def align_data(self, mobject: Mobject, skip_point_alignment: bool = False) -> No """Aligns the family structure and data of this mobject with another mobject. Afterwards, the two mobjects will have the same number of submobjects - (see :meth:`.align_submobjects`), the same parent structure (see - :meth:`.null_point_align`). If ``skip_point_alignment`` is false, + (see :meth:`.align_submobjects`) and the same parent structure (see + :meth:`.null_point_align`). If ``skip_point_alignment`` is ``False``, they will also have the same number of points (see :meth:`.align_points`). Parameters @@ -2718,7 +2718,7 @@ def align_data(self, mobject: Mobject, skip_point_alignment: bool = False) -> No The other mobject this mobject should be aligned to. skip_point_alignment Controls whether or not the computationally expensive - point alignment is skipped (default: False). + point alignment is skipped (default: ``False``). .. note::