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

Code before:
    def match_width(self, mobject: "Mobject", **kwargs):
        return self.match_dim_size(mobject, 0, **kwargs)

    def match_height(self, mobject: "Mobject", **kwargs):
        return self.match_dim_size(mobject, 1, **kwargs)

    def match_depth(self, mobject: "Mobject", **kwargs):
        return self.match_dim_size(mobject, 2, **kwargs)

    def match_coord(self, mobject: "Mobject", dim, direction=ORIGIN):
        return self.set_coord(
            mobject.get_coord(dim, direction),
            dim=dim,
            direction=direction,
        )

    def match_x(self, mobject:"Mobject", direction=ORIGIN):
        return self.match_coord(mobject, 0, direction)

    def match_y(self, mobject:"Mobject", direction=ORIGIN):
        return self.match_coord(mobject, 1, direction)

    def match_z(self, mobject:"Mobject", direction=ORIGIN):
        return self.match_coord(mobject, 2, direction)

    def align_to(self, mobject_or_point:Union["Mobject",np.ndarray, List], direction=ORIGIN, alignment_vect=UP):
        """Examples:
        mob1.align_to(mob2, UP) moves mob1 vertically so that its
        top edge lines ups with mob2's top edge.

        mob1.align_to(mob2, alignment_vect = RIGHT) moves mob1
        horizontally so that it's center is directly above/below
        the center of mob2
        """
        if isinstance(mobject_or_point, Mobject):
            point = mobject_or_point.get_critical_point(direction)
        else:
            point = mobject_or_point

        for dim in range(self.dim):
            if direction[dim] != 0:
                self.set_coord(point[dim], dim, direction)
        return self

    # Family matters

    def __getitem__(self, value):
        self_list = self.split()
        if isinstance(value, slice):
            GroupClass = self.get_group_class()
            return GroupClass(*self_list.__getitem__(value))

Review comment (suggestion):
As I am using type hints the first time, I am not sure if this is the best way to add them in this way `Union["Mobject",np.ndarray, List]`, or if it is even possible to specify that the list/array needs to have exactly 3 entries. 

Code after:
        return self.rescale_to_fit(mobject.length_over_dim(dim), dim, **kwargs)

    def match_width(self, mobject: "Mobject", **kwargs):
        return self.match_dim_size(mobject, 0, **kwargs)

    def match_height(self, mobject: "Mobject", **kwargs):
        return self.match_dim_size(mobject, 1, **kwargs)

    def match_depth(self, mobject: "Mobject", **kwargs):
        return self.match_dim_size(mobject, 2, **kwargs)

    def match_coord(self, mobject: "Mobject", dim, direction=ORIGIN):
        return self.set_coord(
            mobject.get_coord(dim, direction),
            dim=dim,
            direction=direction,
        )

    def match_x(self, mobject: "Mobject", direction=ORIGIN):
        return self.match_coord(mobject, 0, direction)

    def match_y(self, mobject: "Mobject", direction=ORIGIN):
        return self.match_coord(mobject, 1, direction)

    def match_z(self, mobject: "Mobject", direction=ORIGIN):
        return self.match_coord(mobject, 2, direction)

    def align_to(
        self,
        mobject_or_point: Union["Mobject", np.ndarray, List],
        direction=ORIGIN,
        alignment_vect=UP,
    ):
        """Examples:
        mob1.align_to(mob2, UP) moves mob1 vertically so that its
        top edge lines ups with mob2's top edge.

        mob1.align_to(mob2, alignment_vect = RIGHT) moves mob1
        horizontally so that it's center is directly above/below
        the center of mob2
        """
        if isinstance(mobject_or_point, Mobject):
            point = mobject_or_point.get_critical_point(direction)
        else:
            point = mobject_or_point

        for dim in range(self.dim):
            if direction[dim] != 0:
                self.set_coord(point[dim], dim, direction)
        return self