Skip to content

Commit ab48557

Browse files
Improve Mobject.align_data docstring (#4152)
Co-authored-by: Francisco Manríquez Novoa <[email protected]>
1 parent f304bd9 commit ab48557

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

manim/mobject/mobject.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,11 +2705,11 @@ def construct(self):
27052705

27062706
# Alignment
27072707
def align_data(self, mobject: Mobject, skip_point_alignment: bool = False) -> None:
2708-
"""Aligns the data of this mobject with another mobject.
2708+
"""Aligns the family structure and data of this mobject with another mobject.
27092709
27102710
Afterwards, the two mobjects will have the same number of submobjects
2711-
(see :meth:`.align_submobjects`), the same parent structure (see
2712-
:meth:`.null_point_align`). If ``skip_point_alignment`` is false,
2711+
(see :meth:`.align_submobjects`) and the same parent structure (see
2712+
:meth:`.null_point_align`). If ``skip_point_alignment`` is ``False``,
27132713
they will also have the same number of points (see :meth:`.align_points`).
27142714
27152715
Parameters
@@ -2718,7 +2718,32 @@ def align_data(self, mobject: Mobject, skip_point_alignment: bool = False) -> No
27182718
The other mobject this mobject should be aligned to.
27192719
skip_point_alignment
27202720
Controls whether or not the computationally expensive
2721-
point alignment is skipped (default: False).
2721+
point alignment is skipped (default: ``False``).
2722+
2723+
2724+
.. note::
2725+
2726+
This method is primarily used internally by :meth:`.become` and the
2727+
:class:`~.Transform` animation to ensure that mobjects are structurally
2728+
compatible before transformation.
2729+
2730+
Examples
2731+
--------
2732+
::
2733+
2734+
>>> from manim import Rectangle, Line, ORIGIN, RIGHT
2735+
>>> rect = Rectangle(width=4.0, height=2.0, grid_xstep=1.0, grid_ystep=0.5)
2736+
>>> line = Line(start=ORIGIN,end=RIGHT)
2737+
>>> line.align_data(rect)
2738+
>>> len(line.get_family()) == len(rect.get_family())
2739+
True
2740+
>>> line.get_num_points() == rect.get_num_points()
2741+
True
2742+
2743+
See also
2744+
--------
2745+
:class:`~.Transform`, :meth:`~.Mobject.become`, :meth:`~.VMobject.align_points`, :meth:`~.Mobject.get_family`
2746+
27222747
"""
27232748
self.null_point_align(mobject)
27242749
self.align_submobjects(mobject)
@@ -2943,6 +2968,10 @@ def construct(self):
29432968
>>> result = rect.copy().become(circ, match_center=True)
29442969
>>> np.allclose(rect.get_center(), result.get_center())
29452970
True
2971+
2972+
See also
2973+
--------
2974+
:meth:`~.Mobject.align_data`, :meth:`~.VMobject.interpolate_color`
29462975
"""
29472976
mobject = mobject.copy()
29482977
if stretch:

0 commit comments

Comments
 (0)