A community-maintained Python framework for creating mathematical animations.
Some more typehints (#1351)
kolibril13cf67876ea137
diff --git a/manim/animation/movement.py b/manim/animation/movement.pyindex 1ed440ecf..3ca1e7bf0 100644--- a/manim/animation/movement.py+++ b/manim/animation/movement.py@@ -8,8 +8,8 @@ __all__ = ["MoveAlongPath",]-import typing+from typing import Any, Callable, Dict, Optional, Tupleimport numpy as np@@ -23,12 +23,10 @@ if typing.TYPE_CHECKING:class Homotopy(Animation):def __init__(self,- homotopy: typing.Callable[- [float, float, float, float], typing.Tuple[float, float, float]- ],+ homotopy: Callable[[float, float, float, float], Tuple[float, float, float]],mobject: "Mobject",run_time: float = 3,- apply_function_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None,+ apply_function_kwargs: Optional[Dict[str, Any]] = None,**kwargs) -> None:"""@@ -41,7 +39,7 @@ class Homotopy(Animation):)super().__init__(mobject, run_time=run_time, **kwargs)- def function_at_time_t(self, t: float) -> typing.Tuple[float, float, float]:+ def function_at_time_t(self, t: float) -> Tuple[float, float, float]:return lambda p: self.homotopy(*p, t)def interpolate_submobject(@@ -63,10 +61,7 @@ class SmoothedVectorizedHomotopy(Homotopy):class ComplexHomotopy(Homotopy):def __init__(- self,- complex_homotopy: typing.Callable[[complex], float],- mobject: "Mobject",- **kwargs+ self, complex_homotopy: Callable[[complex], float], mobject: "Mobject", **kwargs) -> None:"""Complex Homotopy a function Cx[0, 1] to C@@ -74,7 +69,7 @@ class ComplexHomotopy(Homotopy):def homotopy(x: float, y: float, z: float, t: float- ) -> typing.Tuple[float, float, float]:+ ) -> Tuple[float, float, float]:c = complex_homotopy(complex(x, y), t)return (c.real, c.imag, z)@@ -84,13 +79,11 @@ class ComplexHomotopy(Homotopy):class PhaseFlow(Animation):def __init__(self,- function: typing.Callable[[np.ndarray], np.ndarray],+ function: Callable[[np.ndarray], np.ndarray],mobject: "Mobject",virtual_time: float = 1,suspend_mobject_updating: bool = False,- rate_func: typing.Callable[- [typing.Union[np.ndarray, float]], typing.Union[np.ndarray, float]- ] = linear,+ rate_func: Callable[[float], float] = linear,**kwargs) -> None:self.virtual_time = virtual_time@@ -129,7 +122,7 @@ class MoveAlongPath(Animation):self,mobject: "Mobject",path: np.ndarray,- suspend_mobject_updating: typing.Optional[bool] = False,+ suspend_mobject_updating: Optional[bool] = False,**kwargs) -> None:self.path = pathdiff --git a/manim/animation/rotation.py b/manim/animation/rotation.pyindex a0ab8789e..043b4349b 100644--- a/manim/animation/rotation.py+++ b/manim/animation/rotation.py@@ -3,6 +3,7 @@__all__ = ["Rotating", "Rotate"]import typing+from typing import Callable, Optional, Sequenceimport numpy as np@@ -21,12 +22,10 @@ class Rotating(Animation):mobject: "Mobject",axis: np.ndarray = OUT,radians: np.ndarray = TAU,- about_point: typing.Optional[np.ndarray] = None,- about_edge: typing.Optional[np.ndarray] = None,+ about_point: Optional[np.ndarray] = None,+ about_edge: Optional[np.ndarray] = None,run_time: float = 5,- rate_func: typing.Callable[- [typing.Union[np.ndarray, float]], typing.Union[np.ndarray, float]- ] = linear,+ rate_func: Callable[[float], float] = linear,**kwargs) -> None:self.axis = axis@@ -51,8 +50,8 @@ class Rotate(Transform):mobject: "Mobject",angle: np.ndarray = PI,axis: np.ndarray = OUT,- about_point: typing.Optional[np.ndarray] = None,- about_edge: typing.Optional[np.ndarray] = None,+ about_point: Optional[Sequence[float]] = None,+ about_edge: Optional[Sequence[float]] = None,**kwargs) -> None:if "path_arc" not in kwargs:diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.pyindex 7cdb7c854..bfb1277f8 100644--- a/manim/mobject/mobject.py+++ b/manim/mobject/mobject.py@@ -13,7 +13,7 @@ import typesimport warningsfrom functools import reducefrom pathlib import Path-from typing import Callable, List, Optional, TypeVar, Union+from typing import Callable, List, Optional, Sequence, TypeVar, Unionimport numpy as npfrom colour import Color@@ -1067,7 +1067,7 @@ class Mobject(Container):self,angle,axis=OUT,- about_point: Union[np.ndarray, List, None] = None,+ about_point: Optional[Sequence[float]] = None,**kwargs,):"""Rotates the :class:`~.Mobject` about a certain point."""@@ -2004,7 +2004,7 @@ class Mobject(Container):def arrange(self,- direction: Union[np.ndarray, List] = RIGHT,+ direction: Sequence[float] = RIGHT,buff=DEFAULT_MOBJECT_TO_MOBJECT_BUFFER,center=True,**kwargs,