Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Improved docstring of :meth:`.PMobject.add_points` (#2115)

Максим Заякин78dff97c51f0
diff --git a/manim/mobject/types/opengl_point_cloud_mobject.py b/manim/mobject/types/opengl_point_cloud_mobject.py
index 547c3ed3e..73a182822 100644
--- a/manim/mobject/types/opengl_point_cloud_mobject.py
+++ b/manim/mobject/types/opengl_point_cloud_mobject.py
@@ -40,8 +40,10 @@ class OpenGLPMobject(OpenGLMobject):
return ["points", "rgbas"]
def add_points(self, points, rgbas=None, color=None, opacity=None):
- """
- points must be a Nx3 numpy array, as must rgbas if it is not None
+ """Add points.
+
+ Points must be a Nx3 numpy array.
+ Rgbas must be a Nx4 numpy array if it is not None.
"""
if rgbas is None and color is None:
color = YELLOW
@@ -54,7 +56,7 @@ class OpenGLPMobject(OpenGLMobject):
elif rgbas is not None:
new_rgbas = rgbas
elif len(rgbas) != len(points):
- raise ValueError("points and rgbas must have same shape")
+ raise ValueError("points and rgbas must have same length")
self.rgbas = np.append(self.rgbas, new_rgbas, axis=0)
return self
diff --git a/manim/mobject/types/point_cloud_mobject.py b/manim/mobject/types/point_cloud_mobject.py
index 61782be18..cca230385 100644
--- a/manim/mobject/types/point_cloud_mobject.py
+++ b/manim/mobject/types/point_cloud_mobject.py
@@ -63,8 +63,10 @@ class PMobject(Mobject, metaclass=ConvertToOpenGL):
return super().get_array_attrs() + ["rgbas"]
def add_points(self, points, rgbas=None, color=None, alpha=1):
- """
- Points must be a Nx3 numpy array, as must rgbas if it is not None
+ """Add points.
+
+ Points must be a Nx3 numpy array.
+ Rgbas must be a Nx4 numpy array if it is not None.
"""
if not isinstance(points, np.ndarray):
points = np.array(points)
@@ -74,7 +76,7 @@ class PMobject(Mobject, metaclass=ConvertToOpenGL):
color = Color(color) if color else self.color
rgbas = np.repeat([color_to_rgba(color, alpha)], num_new_points, axis=0)
elif len(rgbas) != len(points):
- raise ValueError("points and rgbas must have same shape")
+ raise ValueError("points and rgbas must have same length")
self.rgbas = np.append(self.rgbas, rgbas, axis=0)
return self