fix(graphing): align coords_to_point/point_to_coords base signatures with subclasses#4848
Open
Chessing234 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The abstract
CoordinateSystem.coords_to_pointis annotated(*coords: ManimFloat) -> Point3D(a single point), andpoint_to_coords/p2creturnlist[ManimFloat]. But the concreteAxes/NumberPlaneimplementations accept batch coordinates and returnnp.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(matchesc2pandAxes.coords_to_point)point_to_coords(...) -> np.ndarrayandp2c(...) -> np.ndarray(matchesAxes.point_to_coords)Also removes the stale "line 2065" TODO.
Closes #4804.