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

Code before:
        if color is not None:
            if opacity is None:
                opacity = self.data["rgbas"][-1, 3]
            new_rgbas = np.repeat([color_to_rgba(color, opacity)], len(points), axis=0)
        elif rgbas is not None:
            new_rgbas = rgbas
        elif len(rgbas) != len(points):
            raise ValueError("points and rgbas must have same shape")
        self.data["rgbas"] = np.append(self.data["rgbas"], new_rgbas, axis=0)
        return self

    def thin_out(self, factor=5):
        """
        Removes all but every nth point for n = factor
        """
        for mob in self.family_members_with_points():
            num_points = mob.get_num_points()
            thin_func = lambda: np.arange(0, num_points, factor)
            if len(mob.data["points"]) == len(mob.data["rgbas"]):
                mob.set_rgba_array_direct(mob.data["rgbas"][thin_func()])
            mob.set_points(mob.data["points"][thin_func()])

        return self

    def set_color_by_gradient(self, *colors):
        self.data["rgbas"] = np.array(
            list(map(color_to_rgba, color_gradient(*colors, self.get_num_points())))
        )
        return self

    def set_colors_by_radial_gradient(
        self, center=None, radius=1, inner_color=WHITE, outer_color=BLACK
    ):
        start_rgba, end_rgba = list(map(color_to_rgba, [inner_color, outer_color]))
        if center is None:
            center = self.get_center()
        for mob in self.family_members_with_points():
            distances = np.abs(self.data["points"] - center)
            alphas = np.linalg.norm(distances, axis=1) / radius

            mob.data["rgbas"] = np.array(
                np.array([interpolate(start_rgba, end_rgba, alpha) for alpha in alphas])
            )
        return self

    def match_colors(self, pmobject):
        self.data["rgbas"][:] = resize_with_interpolation(
            pmobject.data["rgbas"], self.get_num_points()
        )
        return self


Review comment (suggestion):
```suggestion
        self.rgbas = np.array(
```

Code after:
        if color is not None:
            if opacity is None:
                opacity = self.rgbas[-1, 3]
            new_rgbas = np.repeat([color_to_rgba(color, opacity)], len(points), axis=0)
        elif rgbas is not None:
            new_rgbas = rgbas
        elif len(rgbas) != len(points):
            raise ValueError("points and rgbas must have same shape")
        self.rgbas = np.append(self.rgbas, new_rgbas, axis=0)
        return self

    def thin_out(self, factor=5):
        """
        Removes all but every nth point for n = factor
        """
        for mob in self.family_members_with_points():
            num_points = mob.get_num_points()

            def thin_func():
                return np.arange(0, num_points, factor)

            if len(mob.points) == len(mob.rgbas):
                mob.set_rgba_array_direct(mob.rgbas[thin_func()])
            mob.set_points(mob.points[thin_func()])

        return self

    def set_color_by_gradient(self, *colors):
        self.rgbas = np.array(
            list(map(color_to_rgba, color_gradient(*colors, self.get_num_points())))
        )
        return self

    def set_colors_by_radial_gradient(
        self, center=None, radius=1, inner_color=WHITE, outer_color=BLACK
    ):
        start_rgba, end_rgba = list(map(color_to_rgba, [inner_color, outer_color]))
        if center is None:
            center = self.get_center()
        for mob in self.family_members_with_points():
            distances = np.abs(self.points - center)
            alphas = np.linalg.norm(distances, axis=1) / radius

            mob.rgbas = np.array(
                np.array([interpolate(start_rgba, end_rgba, alpha) for alpha in alphas])
            )
        return self

    def match_colors(self, pmobject):
        self.rgbas[:] = resize_with_interpolation(pmobject.rgbas, self.get_num_points())
        return self