Skip to content

fix(graphing): align coords_to_point/point_to_coords base signatures with subclasses#4848

Open
Chessing234 wants to merge 1 commit into
ManimCommunity:mainfrom
Chessing234:fix/4804-coords-to-point-return-type
Open

fix(graphing): align coords_to_point/point_to_coords base signatures with subclasses#4848
Chessing234 wants to merge 1 commit into
ManimCommunity:mainfrom
Chessing234:fix/4804-coords-to-point-return-type

Conversation

@Chessing234

Copy link
Copy Markdown

Problem

The abstract CoordinateSystem.coords_to_point is annotated (*coords: ManimFloat) -> Point3D (a single point), and point_to_coords/p2c return list[ManimFloat]. But the concrete Axes/NumberPlane implementations accept batch coordinates and return np.ndarray (one point per input). Type checkers therefore accept batch usage against the base type that doesn't reflect runtime behaviour (#4804).

Fix

Align the base-class annotations with the concrete subclasses:

  • coords_to_point(*coords: float | Sequence[float] | Sequence[Sequence[float]] | np.ndarray) -> np.ndarray (matches c2p and Axes.coords_to_point)
  • point_to_coords(...) -> np.ndarray and p2c(...) -> np.ndarray (matches Axes.point_to_coords)

Also removes the stale "line 2065" TODO.

Closes #4804.

The abstract CoordinateSystem.coords_to_point declared a single Point3D
return and a scalar coord param, but Axes/NumberPlane accept batch coords
and return np.ndarray. Align the base (and p2c) annotations with the
concrete implementations and drop the stale TODO. Fixes ManimCommunity#4804.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

graphing: align coords_to_point return type in base class with subclass behaviour

1 participant