Skip to content

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

Description

@Drunsdo

Source

manim/mobject/graphing/coordinate_systems.py, line 159 (as of HEAD ):

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.
        raise NotImplementedError()

(Note: the "line 2065" reference in the original TODO is stale. The concrete implementations of coords_to_point live in subclasses such as Axes and NumberPlane, see def coords_to_point matches in the same file.)

Problem

The abstract coords_to_point declares a return type of Point3D (a single point), but the concrete implementations in subclasses return multiple points when given multiple input coordinates. The base class signature is inconsistent with the actual behaviour of its subclasses.

This affects:

  • Type checkers, which will accept code that breaks at runtime.
  • Users reading the API, who cannot infer that batch input is supported.
  • Future implementers of the abstract base, who may write a single-point-only override that is incompatible with how callers use the method.

Suggested approaches

  • Change the return type annotation in the base class to reflect the batch behaviour, e.g. Point3D | list[Point3D] or Point3D | npt.NDArray.
  • Audit all subclass implementations to confirm they handle both single-coord and multi-coord input consistently.
  • Update point_to_coords similarly if it has the same gap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions