A community-maintained Python framework for creating mathematical animations.
Fix typehints of `ParametricFunction` (#3926)
Aarush Deshpande96e58aeb053c
diff --git a/manim/mobject/graphing/functions.py b/manim/mobject/graphing/functions.pyindex 8ed4b43c2..1cd660b89 100644--- a/manim/mobject/graphing/functions.py+++ b/manim/mobject/graphing/functions.py@@ -17,7 +17,9 @@ from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGLfrom manim.mobject.types.vectorized_mobject import VMobjectif TYPE_CHECKING:- from manim.typing import Point2D, Point3D+ from typing_extensions import Self++ from manim.typing import Point3Dfrom manim.utils.color import YELLOW@@ -103,7 +105,7 @@ class ParametricFunction(VMobject, metaclass=ConvertToOpenGL):def __init__(self,function: Callable[[float], Point3D],- t_range: Point2D | Point3D = (0, 1),+ t_range: tuple[float, float] | tuple[float, float, float] = (0, 1),scaling: _ScaleBase = LinearBase(),dt: float = 1e-8,discontinuities: Iterable[float] | None = None,@@ -112,9 +114,8 @@ class ParametricFunction(VMobject, metaclass=ConvertToOpenGL):**kwargs,):self.function = function- t_range = (0, 1, 0.01) if t_range is None else t_rangeif len(t_range) == 2:- t_range = np.array([*t_range, 0.01])+ t_range = (*t_range, 0.01)self.scaling = scaling@@ -126,13 +127,13 @@ class ParametricFunction(VMobject, metaclass=ConvertToOpenGL):super().__init__(**kwargs)- def get_function(self):+ def get_function(self) -> Callable[[float], Point3D]:return self.function- def get_point_from_function(self, t):+ def get_point_from_function(self, t: float) -> Point3D:return self.function(t)- def generate_points(self):+ def generate_points(self) -> Self:if self.discontinuities is not None:discontinuities = filter(lambda t: self.t_min <= t <= self.t_max,diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.pyindex cf8a11310..2079de792 100644--- a/manim/mobject/mobject.py+++ b/manim/mobject/mobject.py@@ -406,14 +406,14 @@ class Mobject:"""Sets :attr:`points` to be an empty array."""self.points = np.zeros((0, self.dim))- def init_colors(self) -> None:+ def init_colors(self) -> object:"""Initializes the colors.Gets called upon creation. This is an empty method that can be implemented bysubclasses."""- def generate_points(self) -> None:+ def generate_points(self) -> object:"""Initializes :attr:`points` and therefore the shape.Gets called upon creation. This is an empty method that can be implemented bydiff --git a/manim/mobject/opengl/opengl_mobject.py b/manim/mobject/opengl/opengl_mobject.pyindex 67404d763..1f7d44d6a 100644--- a/manim/mobject/opengl/opengl_mobject.py+++ b/manim/mobject/opengl/opengl_mobject.py@@ -327,14 +327,14 @@ class OpenGLMobject:self.bounding_box = np.zeros((3, 3))self.rgbas = np.zeros((1, 4))- def init_colors(self) -> None:+ def init_colors(self) -> object:"""Initializes the colors.Gets called upon creation"""self.set_color(self.color, self.opacity)- def init_points(self):+ def init_points(self) -> object:"""Initializes :attr:`points` and therefore the shape.Gets called upon creation. This is an empty method that can be implemented by