From 17a9efd5269b879a27cd6820271a3f506547f244 Mon Sep 17 00:00:00 2001 From: Taksh Date: Wed, 1 Jul 2026 05:52:41 +0530 Subject: [PATCH] Align CoordinateSystem coord-conversion return types with subclasses The abstract CoordinateSystem.coords_to_point/point_to_coords (and the p2c alias) declared single-point return types (Point3D / list[ManimFloat]), but concrete implementations (Axes, NumberPlane) accept batched input and return np.ndarray. Widen the base signatures to match and drop the stale line-number TODO (#4804). Co-authored-by: Cursor --- manim/mobject/graphing/coordinate_systems.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/manim/mobject/graphing/coordinate_systems.py b/manim/mobject/graphing/coordinate_systems.py index 6b8237827f..103b5e19fc 100644 --- a/manim/mobject/graphing/coordinate_systems.py +++ b/manim/mobject/graphing/coordinate_systems.py @@ -155,12 +155,16 @@ def __init__( self.num_sampled_graph_points_per_tick = 10 self.x_axis: NumberLine - def coords_to_point(self, *coords: ManimFloat) -> Point3D: - # TODO: I think the method should be able to return more than just a single point. - # E.g. see the implementation of it on line 2065. + def coords_to_point( + self, *coords: float | Sequence[float] | Sequence[Sequence[float]] | np.ndarray + ) -> np.ndarray: + # Concrete subclasses (e.g. Axes, NumberPlane) return a single Point3D for + # a single coordinate and a stacked array for batched input. raise NotImplementedError() - def point_to_coords(self, point: Point3DLike) -> list[ManimFloat]: + def point_to_coords( + self, point: Point3DLike | Sequence[Point3DLike] | np.ndarray + ) -> np.ndarray: raise NotImplementedError() def polar_to_point(self, radius: float, azimuth: float) -> Point2D: @@ -216,7 +220,9 @@ def c2p( """Abbreviation for :meth:`coords_to_point`""" return self.coords_to_point(*coords) - def p2c(self, point: Point3DLike) -> list[ManimFloat]: + def p2c( + self, point: Point3DLike | Sequence[Point3DLike] | np.ndarray + ) -> np.ndarray: """Abbreviation for :meth:`point_to_coords`""" return self.point_to_coords(point)