Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c8a2228
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Jan 20, 2025
8249c13
Add type annotations to camera/camera.py
henrikmidtiby Jan 10, 2025
bddb6ad
Part 2
henrikmidtiby Jan 20, 2025
ea60db4
Part 3
henrikmidtiby Jan 20, 2025
d9dcb3d
Part 1
henrikmidtiby Jan 17, 2025
97cc36a
Add type annotations to mobject/graphing/scale.py
henrikmidtiby Jan 17, 2025
65129cc
Add type annotations to most of mobject/graphing/probability.py
henrikmidtiby Jan 17, 2025
785ad1a
Add type annotations to mobject/graphing/number_line.py
henrikmidtiby Jan 17, 2025
859358e
Avoid a circular import.
henrikmidtiby Jan 21, 2025
f8e1bae
Add type annotations to mobject/graphing/functions.py
henrikmidtiby Jan 17, 2025
d5d3928
In progress: Add typehints to graphing/coordinate_systems.py part1
henrikmidtiby Jan 20, 2025
3969b7e
In progress: Add typehints to graphing/coordinate_systems.py part 2
henrikmidtiby Jan 21, 2025
90f0dec
Add type annotations to manim/camera/multi_camera.py - part 1
henrikmidtiby Jan 17, 2025
b1a3508
Add type annotations to manim/camera/multi_camera.py - part 2
henrikmidtiby Jan 21, 2025
f767e8a
Add type annotations to manim/camera/multi_camera.py - part 3
henrikmidtiby Jan 21, 2025
8d13460
Merge branch 'main' into Typing_graphing_and_camera
chopan050 Mar 11, 2025
7edb642
Merge branch 'main' into Typing_graphing_and_camera
chopan050 Jul 29, 2025
9db34ef
Reducing the scope of the PR and fixed a number of small items
henrikmidtiby Jul 30, 2025
3ff1095
Removing type ignore statements.
henrikmidtiby Jul 30, 2025
967ef1e
Fixing two type issues
henrikmidtiby Jul 30, 2025
9f148ea
...
henrikmidtiby Jul 30, 2025
297be56
Merge branch 'main' into Typing_graphing_and_camera
henrikmidtiby Jul 30, 2025
efe5565
Updates based on input from Chopan50
henrikmidtiby Jul 30, 2025
e613eb1
Reverting to type ignores and assert statements to fix the last type …
henrikmidtiby Jul 30, 2025
a673de3
Merge remote-tracking branch 'upstream/main' into Typing_graphing_and…
henrikmidtiby Jul 30, 2025
c03c8d8
Update manim/mobject/graphing/functions.py
henrikmidtiby Jul 31, 2025
0da8a6a
Update manim/mobject/graphing/functions.py
henrikmidtiby Jul 31, 2025
9a9e412
Update manim/mobject/graphing/functions.py
henrikmidtiby Jul 31, 2025
efc7a61
Update manim/mobject/graphing/number_line.py
henrikmidtiby Jul 31, 2025
14c339a
Update manim/mobject/graphing/number_line.py
henrikmidtiby Jul 31, 2025
ff789bb
Update manim/mobject/graphing/number_line.py
henrikmidtiby Jul 31, 2025
1b1798d
Suggestions from Chopan50
henrikmidtiby Jul 31, 2025
9263abd
More suggestions from Chopan50
henrikmidtiby Jul 31, 2025
8309fe9
Updates
henrikmidtiby Jul 31, 2025
1c582b7
Minor improvements to coordinate_systems.py
henrikmidtiby Jul 31, 2025
603779c
Minor improvements to number_line.py
henrikmidtiby Jul 31, 2025
3307494
Minor improvements to functions.py
henrikmidtiby Jul 31, 2025
55dac2f
Update manim/mobject/graphing/scale.py
chopan050 Aug 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions manim/mobject/graphing/coordinate_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __init__(
x_length: float | None = None,
y_length: float | None = None,
dimension: int = 2,
) -> None:
):
self.dimension = dimension

default_step = 1
Expand Down Expand Up @@ -156,6 +156,8 @@ def __init__(
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.
Comment on lines +159 to +160
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this function (or rather its descendants) should be able to return more than a single point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually correct. The Axes.coords_to_points() method I optimized in #3286 also uses that behavior. Thanks for reminding me of it.

This behavior is probably too complex to type for now, so let's leave the TODO there.

raise NotImplementedError()

def point_to_coords(self, point: Point3DLike) -> list[ManimFloat]:
Expand Down Expand Up @@ -202,7 +204,7 @@ def point_to_polar(self, point: Point2DLike) -> Point2D:

Returns
-------
Tuple[:class:`float`, :class:`float`]
Point2D
The coordinate radius (:math:`r`) and the coordinate azimuth (:math:`\theta`).
"""
x, y = self.point_to_coords(point)
Expand Down Expand Up @@ -261,8 +263,8 @@ def get_y_unit_size(self) -> float:
def get_x_axis_label(
self,
label: float | str | VMobject,
edge: Sequence[float] = UR,
direction: Sequence[float] = UR,
edge: Vector3D = UR,
direction: Vector3D = UR,
buff: float = SMALL_BUFF,
**kwargs: Any,
) -> Mobject:
Expand Down Expand Up @@ -304,8 +306,8 @@ def construct(self):
def get_y_axis_label(
self,
label: float | str | VMobject,
edge: Sequence[float] = UR,
direction: Sequence[float] = UP * 0.5 + RIGHT,
edge: Vector3D = UR,
direction: Vector3D = UP * 0.5 + RIGHT,
buff: float = SMALL_BUFF,
**kwargs: Any,
) -> Mobject:
Expand Down Expand Up @@ -351,8 +353,8 @@ def _get_axis_label(
self,
label: float | str | VMobject,
axis: Mobject,
edge: Sequence[float],
direction: Sequence[float],
edge: Vector3D,
direction: Vector3D,
buff: float = SMALL_BUFF,
) -> Mobject:
"""Gets the label for an axis.
Expand Down Expand Up @@ -457,7 +459,7 @@ def add_coordinates(
def get_line_from_axis_to_point(
self,
index: int,
point: Sequence[float],
point: Point3DLike,
line_config: dict | None = ...,
color: ParsableManimColor | None = ...,
stroke_width: float = ...,
Expand All @@ -467,7 +469,7 @@ def get_line_from_axis_to_point(
def get_line_from_axis_to_point(
self,
index: int,
point: Sequence[float],
point: Point3DLike,
line_func: type[LineType],
line_config: dict | None = ...,
color: ParsableManimColor | None = ...,
Expand Down Expand Up @@ -522,7 +524,7 @@ def get_line_from_axis_to_point( # type: ignore[no-untyped-def]
line = line_func(axis.get_projection(point), point, **line_config)
return line

def get_vertical_line(self, point: Sequence[float], **kwargs: Any) -> Line:
def get_vertical_line(self, point: Point3DLike, **kwargs: Any) -> Line:
"""A vertical line from the x-axis to a given point in the scene.

Parameters
Expand Down Expand Up @@ -556,7 +558,7 @@ def construct(self):
"""
return self.get_line_from_axis_to_point(0, point, **kwargs)

def get_horizontal_line(self, point: Sequence[float], **kwargs: Any) -> Line:
def get_horizontal_line(self, point: Point3DLike, **kwargs: Any) -> Line:
"""A horizontal line from the y-axis to a given point in the scene.

Parameters
Expand Down Expand Up @@ -588,7 +590,7 @@ def construct(self):
"""
return self.get_line_from_axis_to_point(1, point, **kwargs)

def get_lines_to_point(self, point: Sequence[float], **kwargs: Any) -> VGroup:
def get_lines_to_point(self, point: Point3DLike, **kwargs: Any) -> VGroup:
"""Generate both horizontal and vertical lines from the axis to a point.

Parameters
Expand Down Expand Up @@ -634,7 +636,9 @@ def plot(
function: Callable[[float], float],
x_range: Sequence[float] | None = None,
use_vectorized: bool = False,
colorscale: Union[Iterable[Color], Iterable[Color, float]] | None = None,
colorscale: Iterable[ParsableManimColor]
| Iterable[ParsableManimColor, float]
| None = None,
colorscale_axis: int = 1,
**kwargs: Any,
) -> ParametricFunction:
Expand Down Expand Up @@ -1595,7 +1599,7 @@ def antideriv(x):
x_vals = np.linspace(0, x, samples, axis=1 if use_vectorized else 0)
f_vec = np.vectorize(graph.underlying_function)
y_vals = f_vec(x_vals)
return np.trapz(y_vals, x_vals) + y_intercept
return np.trapezoid(y_vals, x_vals) + y_intercept

return self.plot(antideriv, use_vectorized=use_vectorized, **kwargs)

Expand Down Expand Up @@ -1929,7 +1933,7 @@ def __init__(
y_axis_config: dict | None = None,
tips: bool = True,
**kwargs: Any,
) -> None:
):
VGroup.__init__(self, **kwargs)
CoordinateSystem.__init__(self, x_range, y_range, x_length, y_length)

Expand Down Expand Up @@ -2430,12 +2434,12 @@ def __init__(
z_axis_config: dict[str, Any] | None = None,
z_normal: Vector3D = DOWN,
num_axis_pieces: int = 20,
light_source: Sequence[float] = 9 * DOWN + 7 * LEFT + 10 * OUT,
light_source: Point3DLike = 9 * DOWN + 7 * LEFT + 10 * OUT,
# opengl stuff (?)
depth: Any = None,
gloss: float = 0.5,
**kwargs: dict[str, Any],
) -> None:
):
super().__init__(
x_range=x_range,
x_length=x_length,
Expand All @@ -2457,7 +2461,7 @@ def __init__(
self.z_normal = z_normal
self.num_axis_pieces = num_axis_pieces

self.light_source = light_source
self.light_source = np.array(light_source)

self.dimension = 3

Expand Down Expand Up @@ -2515,8 +2519,8 @@ def make_func(axis):
def get_y_axis_label(
self,
label: float | str | VMobject,
edge: Sequence[float] = UR,
direction: Sequence[float] = UR,
edge: Vector3D = UR,
direction: Vector3D = UR,
buff: float = SMALL_BUFF,
rotation: float = PI / 2,
rotation_axis: Vector3D = OUT,
Expand Down Expand Up @@ -3023,7 +3027,7 @@ def __init__(
faded_line_ratio: int = 1,
make_smooth_after_applying_functions: bool = True,
**kwargs: Any,
) -> None:
):
# error catching
if azimuth_units in ["PI radians", "TAU radians", "degrees", "gradians", None]:
self.azimuth_units = azimuth_units
Expand Down Expand Up @@ -3377,7 +3381,7 @@ def construct(self):

"""

def __init__(self, **kwargs: Any) -> None:
def __init__(self, **kwargs: Any):
super().__init__(
**kwargs,
)
Expand Down