diff --git a/manim/mobject/graphing/functions.py b/manim/mobject/graphing/functions.py index 8ed4b43c2e..1cd660b894 100644 --- a/manim/mobject/graphing/functions.py +++ b/manim/mobject/graphing/functions.py @@ -17,7 +17,9 @@ from manim.mobject.types.vectorized_mobject import VMobject if TYPE_CHECKING: - from manim.typing import Point2D, Point3D + from typing_extensions import Self + + from manim.typing import Point3D from manim.utils.color import YELLOW @@ -103,7 +105,7 @@ def construct(self): 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 @@ def __init__( **kwargs, ): self.function = function - t_range = (0, 1, 0.01) if t_range is None else t_range if 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 @@ def __init__( 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.py index cf8a113104..2079de7923 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -406,14 +406,14 @@ def reset_points(self) -> None: """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 by subclasses. """ - 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 by diff --git a/manim/mobject/opengl/opengl_mobject.py b/manim/mobject/opengl/opengl_mobject.py index 67404d763d..1f7d44d6a3 100644 --- a/manim/mobject/opengl/opengl_mobject.py +++ b/manim/mobject/opengl/opengl_mobject.py @@ -327,14 +327,14 @@ def init_data(self) -> None: 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