Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions manim/mobject/graphing/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -103,7 +105,7 @@
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,
Expand All @@ -112,9 +114,8 @@
**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

Expand All @@ -122,17 +123,17 @@
self.discontinuities = discontinuities
self.use_smoothing = use_smoothing
self.use_vectorized = use_vectorized
self.t_min, self.t_max, self.t_step = t_range

Check failure

Code scanning / CodeQL

Mismatch in multiple assignment Error

Left hand side of assignment contains 3 variables, but right hand side is a
tuple
of length 2.

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,
Expand Down
4 changes: 2 additions & 2 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions manim/mobject/opengl/opengl_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading