Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Add type annotations to ```rotation.py``` (#4535)

F. Muenkeld938533742e2
diff --git a/manim/animation/rotation.py b/manim/animation/rotation.py
index 2673c8cba..f47b0b694 100644
--- a/manim/animation/rotation.py
+++ b/manim/animation/rotation.py
@@ -4,11 +4,9 @@ from __future__ import annotations
__all__ = ["Rotating", "Rotate"]
-from collections.abc import Callable, Sequence
+from collections.abc import Callable
from typing import TYPE_CHECKING, Any
-import numpy as np
-
from ..animation.animation import Animation
from ..animation.transform import Transform
from ..constants import OUT, PI, TAU
@@ -16,6 +14,8 @@ from ..utils.rate_functions import linear
if TYPE_CHECKING:
from ..mobject.mobject import Mobject
+ from ..mobject.opengl.opengl_mobject import OpenGLMobject
+ from ..typing import Point3DLike, Vector3DLike
class Rotating(Animation):
@@ -89,9 +89,9 @@ class Rotating(Animation):
self,
mobject: Mobject,
angle: float = TAU,
- axis: np.ndarray = OUT,
- about_point: np.ndarray | None = None,
- about_edge: np.ndarray | None = None,
+ axis: Vector3DLike = OUT,
+ about_point: Point3DLike | None = None,
+ about_edge: Vector3DLike | None = None,
run_time: float = 5,
rate_func: Callable[[float], float] = linear,
**kwargs: Any,
@@ -156,9 +156,9 @@ class Rotate(Transform):
self,
mobject: Mobject,
angle: float = PI,
- axis: np.ndarray = OUT,
- about_point: Sequence[float] | None = None,
- about_edge: Sequence[float] | None = None,
+ axis: Vector3DLike = OUT,
+ about_point: Point3DLike | None = None,
+ about_edge: Vector3DLike | None = None,
**kwargs: Any,
) -> None:
if "path_arc" not in kwargs:
@@ -173,7 +173,7 @@ class Rotate(Transform):
self.about_point = mobject.get_center()
super().__init__(mobject, path_arc_centers=self.about_point, **kwargs)
- def create_target(self) -> Mobject:
+ def create_target(self) -> Mobject | OpenGLMobject:
target = self.mobject.copy()
target.rotate(
self.angle,
diff --git a/manim/animation/transform.py b/manim/animation/transform.py
index e8d1ab319..a4e548a4c 100644
--- a/manim/animation/transform.py
+++ b/manim/animation/transform.py
@@ -51,6 +51,7 @@ from ..utils.rate_functions import smooth, squish_rate_func
if TYPE_CHECKING:
from ..scene.scene import Scene
+ from ..typing import Point3DLike, Point3DLike_Array
class Transform(Animation):
@@ -137,12 +138,12 @@ class Transform(Animation):
path_func: Callable | None = None,
path_arc: float = 0,
path_arc_axis: np.ndarray = OUT,
- path_arc_centers: np.ndarray = None,
+ path_arc_centers: Point3DLike | Point3DLike_Array | None = None,
replace_mobject_with_target_in_scene: bool = False,
**kwargs,
) -> None:
self.path_arc_axis: np.ndarray = path_arc_axis
- self.path_arc_centers: np.ndarray = path_arc_centers
+ self.path_arc_centers: Point3DLike | Point3DLike_Array | None = path_arc_centers
self.path_arc: float = path_arc
# path_func is a property a few lines below so it doesn't need to be set in any case
diff --git a/mypy.ini b/mypy.ini
index 4977b894e..379400f82 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -70,9 +70,6 @@ ignore_errors = True
[mypy-manim.animation.indication]
ignore_errors = True
-[mypy-manim.animation.rotation]
-ignore_errors = True
-
[mypy-manim.animation.specialized]
ignore_errors = True