Skip to content

Commit 1d3adc0

Browse files
committed
Improve docstring of align_data
1 parent 3c6a1ee commit 1d3adc0

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

manim/mobject/mobject.py

+31-1
Original file line numberDiff line numberDiff line change
@@ -2705,7 +2705,7 @@ 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
27112711
(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
27192719
skip_point_alignment
27202720
Controls whether or not the computationally expensive
27212721
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,11 @@ 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`
2975+
29462976
"""
29472977
mobject = mobject.copy()
29482978
if stretch:

0 commit comments

Comments
 (0)