Repository: ManimCommunity/manim
File: manim/mobject/mobject.py (Python)

Code before:
                    self.add(circ)
                    self.wait(0.5)
                    circ.become(square)
                    self.wait(0.5)
        """
        self.align_data(mobject)
        for sm1, sm2 in zip(self.get_family(), mobject.get_family()):
            sm1.points = np.array(sm2.points)
            sm1.interpolate_color(sm1, sm2, 1)
        return self

    def match_points(self, mobject: "Mobject", copy_submobjects: bool = True):
        """Edit points, positions, and submobjects to be identical
        to another :class:`~.Mobject`, while keeping the style unchanged.

        Examples
        --------
        .. manim:: BecomeScene

            class MatchPointsScene(Scene):
                def construct(self):
                    circ = Circle(fill_color=RED, fill_opacity=0.8)
                    square = Square(fill_color=BLUE, fill_opacity=0.2)
                    self.add(circ)
                    self.wait(0.5)
                    circ.match_points(square)
                    self.wait(0.5)
        """
        self.align_data(mobject)
        for sm1, sm2 in zip(self.get_family(), mobject.get_family()):
            sm1.points = np.array(sm2.points)
        return self

    # Errors
    def throw_error_if_no_points(self):
        if config.renderer == "opengl":
            if len(self.data["points"]) == 0:
                caller_name = sys._getframe(1).f_code.co_name
                raise Exception(
                    f"Cannot call Mobject.{caller_name} for a Mobject with no points"
                )
        else:
            if self.has_no_points():
                caller_name = sys._getframe(1).f_code.co_name
                raise Exception(
                    f"Cannot call Mobject.{caller_name} for a Mobject with no points"
                )

    # About z-index
    def set_z_index(self, z_index_value: Union[int, float]):
        """Sets the :class:`~.Mobject`'s :attr:`z_index` to the value specified in `z_index_value`.

Review comment (suggestion):
Wouldn't it be better if we actually show the transformation?
```suggestion
                    self.play(circ.animate.match_points(square))
```

Code after:
                    self.add(circ)
                    self.wait(0.5)
                    circ.become(square)
                    self.wait(0.5)
        """
        self.align_data(mobject)
        for sm1, sm2 in zip(self.get_family(), mobject.get_family()):
            sm1.points = np.array(sm2.points)
            sm1.interpolate_color(sm1, sm2, 1)
        return self

    def match_points(self, mobject: "Mobject", copy_submobjects: bool = True):
        """Edit points, positions, and submobjects to be identical
        to another :class:`~.Mobject`, while keeping the style unchanged.

        Examples
        --------
        .. manim:: MatchPointsScene

            class MatchPointsScene(Scene):
                def construct(self):
                    circ = Circle(fill_color=RED, fill_opacity=0.8)
                    square = Square(fill_color=BLUE, fill_opacity=0.2)
                    self.add(circ)
                    self.wait(0.5)
                    self.play(circ.animate.match_points(square))
                    self.wait(0.5)
        """
        self.align_data(mobject)
        for sm1, sm2 in zip(self.get_family(), mobject.get_family()):
            sm1.points = np.array(sm2.points)
        return self

    # Errors
    def throw_error_if_no_points(self):
        if config.renderer == "opengl":
            if len(self.data["points"]) == 0:
                caller_name = sys._getframe(1).f_code.co_name
                raise Exception(
                    f"Cannot call Mobject.{caller_name} for a Mobject with no points"
                )
        else:
            if self.has_no_points():
                caller_name = sys._getframe(1).f_code.co_name
                raise Exception(
                    f"Cannot call Mobject.{caller_name} for a Mobject with no points"
                )

    # About z-index
    def set_z_index(self, z_index_value: Union[int, float]):
        """Sets the :class:`~.Mobject`'s :attr:`z_index` to the value specified in `z_index_value`.