ManimCommunity / ManimCommunity/manim
graphing: align coords_to_point return type in base class with subclass behaviour
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 40.9k
- Forks
- 3.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 25
Description
## 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in manim/mobject/graphing/coordinate_systems.py at the base coords_to_point definition around line 159, then compare the subclass coords_to_point implementations mentioned in the issue. Audit whether point_to_coords has the same gap and determine the return forms used for single and multiple coordinates. Done means the base annotations accurately describe the subclass behavior and the affected API is consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100