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

Code before:

        class VectorExample(Scene):
            def construct(self):
                plane = NumberPlane()
                vector_1 = Vector([1,2])
                vector_2 = Vector([-5,-2])
                self.add(plane, vector_1, vector_2)
    """

    def __init__(self, direction=RIGHT, buff=0, **kwargs):
        self.buff = buff
        if len(direction) == 2:
            direction = np.append(np.array(direction), 0)
        Arrow.__init__(self, ORIGIN, direction, buff=buff, **kwargs)

    def coordinate_label(self, integer_labels=True, n_dim=2, color=WHITE):
        """A label based on the coordinates of the vector.

        Parameters
        ----------
        integer_labels : :class:`bool`, optional
            Whether or not to round the coordinates to integers.
        n_dim : `class`:`int`, optional
            The number of dimensions of the vector.
        color : :class:`~.Colors`, optional
            The color of the label.

        Examples
        --------

        .. manim VectorCoordinateLabel
            :save_last_frame:

            class VectorCoordinateLabel(Scene):
                def construct(self):
                    plane = NumberPlane()

                    vect_1 = Vector([1, 2])
                    label_1 = vect1.coordinate_label()
                    vect_2 = Vector([-3, -2])
                    label_2 = vect2.coordinate_label(color=YELLOW)
                    self.add(plane, vect_1, label_1, vect_2, label_2)
        """
        # avoiding circular imports
        from .matrix import Matrix

        vect = np.array(self.get_end())
        if integer_labels:
            vect = np.round(vect).astype(int)
        vect = vect[:n_dim]
        vect = vect.reshape((n_dim, 1))

Review comment (suggestion):
I'd rather have the types as actual type hints. Also, I'm pretty sure that WHITE is just a `str`.

```suggestion
    def coordinate_label(self, integer_labels: bool = True, n_dim : int = 2, color: str = WHITE):
        """A label based on the coordinates of the vector.

        Parameters
        ----------
        integer_labels
            Whether or not to round the coordinates to integers.
        n_dim
            The number of dimensions of the vector.
        color
            The color of the label.
```

Code after:

        class VectorExample(Scene):
            def construct(self):
                plane = NumberPlane()
                vector_1 = Vector([1,2])
                vector_2 = Vector([-5,-2])
                self.add(plane, vector_1, vector_2)
    """

    def __init__(self, direction=RIGHT, buff=0, **kwargs):
        self.buff = buff
        if len(direction) == 2:
            direction = np.append(np.array(direction), 0)
        Arrow.__init__(self, ORIGIN, direction, buff=buff, **kwargs)

    def coordinate_label(
        self, integer_labels: bool = True, n_dim: int = 2, color: str = WHITE
    ):
        """Creates a label based on the coordinates of the vector.

        Parameters
        ----------
        integer_labels
            Whether or not to round the coordinates to integers.
        n_dim
            The number of dimensions of the vector.
        color
            The color of the label.

        Examples
        --------

        .. manim VectorCoordinateLabel
            :save_last_frame:

            class VectorCoordinateLabel(Scene):
                def construct(self):
                    plane = NumberPlane()

                    vect_1 = Vector([1, 2])
                    vect_2 = Vector([-3, -2])
                    label_1 = vect1.coordinate_label()
                    label_2 = vect2.coordinate_label(color=YELLOW)

                    self.add(plane, vect_1, vect_2, label_1, label_2)
        """
        # avoiding circular imports
        from .matrix import Matrix

        vect = np.array(self.get_end())
        if integer_labels: