Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

cleaning typehints (#1439)

Jan-Hendrik Müller8750cd33e9c5
diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.py
index 304a59a4e..629cd605c 100644
--- a/manim/mobject/coordinate_systems.py
+++ b/manim/mobject/coordinate_systems.py
@@ -5,7 +5,7 @@ __all__ = ["CoordinateSystem", "Axes", "ThreeDAxes", "NumberPlane", "ComplexPlan
import math
import numbers
-from typing import Iterable, Optional
+from typing import Iterable, Optional, Sequence
import numpy as np
@@ -174,9 +174,9 @@ class Axes(VGroup, CoordinateSystem):
Parameters
----------
- x_range : Optional[Union[:class:`list`, :class:`numpy.ndarray`]]
+ x_range :
The :code:`[x_min, x_max, x_step]` values of the x-axis.
- y_range : Optional[Union[:class:`list`, :class:`numpy.ndarray`]]
+ y_range :
The :code:`[y_min, y_max, y_step]` values of the y-axis.
x_length : Optional[:class:`float`]
The length of the x-axis.
@@ -194,8 +194,8 @@ class Axes(VGroup, CoordinateSystem):
def __init__(
self,
- x_range=None,
- y_range=None,
+ x_range: Optional[Sequence[float]] = None,
+ y_range: Optional[Sequence[float]] = None,
x_length=round(config.frame_width) - 2,
y_length=round(config.frame_height) - 2,
axis_config=None,
@@ -373,11 +373,11 @@ class ThreeDAxes(Axes):
Parameters
----------
- x_range : Optional[Union[:class:`list`, :class:`numpy.ndarray`]]
+ x_range :
The :code:`[x_min, x_max, x_step]` values of the x-axis.
- y_range : Optional[Union[:class:`list`, :class:`numpy.ndarray`]]
+ y_range :
The :code:`[y_min, y_max, y_step]` values of the y-axis.
- z_range : Optional[Union[:class:`list`, :class:`numpy.ndarray`]]
+ z_range :
The :code:`[z_min, z_max, z_step]` values of the z-axis.
x_length : Optional[:class:`float`]
The length of the x-axis.
@@ -403,9 +403,9 @@ class ThreeDAxes(Axes):
def __init__(
self,
- x_range=(-6, 6, 1),
- y_range=(-5, 5, 1),
- z_range=(-4, 4, 1),
+ x_range: Optional[Sequence[float]] = (-6, 6, 1),
+ y_range: Optional[Sequence[float]] = (-5, 5, 1),
+ z_range: Optional[Sequence[float]] = (-4, 4, 1),
x_length=config.frame_height + 2.5,
y_length=config.frame_height + 2.5,
z_length=config.frame_height - 1.5,
@@ -480,9 +480,9 @@ class NumberPlane(Axes):
Parameters
----------
- x_range : Optional[Union[:class:`list`, :class:`numpy.ndarray`]]
+ x_range :
The :code:`[x_min, x_max, x_step]` values of the plane in the horizontal direction.
- y_range : Optional[Union[:class:`list`, :class:`numpy.ndarray`]]
+ y_range :
The :code:`[y_min, y_max, y_step]` values of the plane in the vertical direction.
x_length : Optional[:class:`float`]
The width of the plane.
@@ -509,8 +509,16 @@ class NumberPlane(Axes):
def __init__(
self,
- x_range=(-config["frame_x_radius"], config["frame_x_radius"], 1),
- y_range=(-config["frame_y_radius"], config["frame_y_radius"], 1),
+ x_range: Optional[Sequence[float]] = (
+ -config["frame_x_radius"],
+ config["frame_x_radius"],
+ 1,
+ ),
+ y_range: Optional[Sequence[float]] = (
+ -config["frame_y_radius"],
+ config["frame_y_radius"],
+ 1,
+ ),
x_length=None,
y_length=None,
axis_config=None,
diff --git a/manim/mobject/svg/brace.py b/manim/mobject/svg/brace.py
index 8a7c64f2c..99bcaf27f 100644
--- a/manim/mobject/svg/brace.py
+++ b/manim/mobject/svg/brace.py
@@ -2,6 +2,7 @@
__all__ = ["Brace", "BraceLabel", "BraceText", "BraceBetweenPoints"]
+from typing import Optional, Sequence
import numpy as np
@@ -26,7 +27,7 @@ class Brace(SVGPathMobject):
----------
mobject : :class:`~.Mobject`
The mobject adjacent to which the brace is placed.
- direction : Optional[Union[:class:`list`, :class:`numpy.array`]]
+ direction :
The direction from which the brace faces the mobject.
See Also
@@ -54,7 +55,7 @@ class Brace(SVGPathMobject):
def __init__(
self,
mobject,
- direction=DOWN,
+ direction: Optional[Sequence[float]] = DOWN,
buff=0.2,
sharpness=2,
stroke_width=0,
@@ -195,11 +196,11 @@ class BraceBetweenPoints(Brace):
Parameters
----------
- point_1 : Union[:class:`list`, :class:`numpy.array`]
+ point_1 :
The first point.
- point_2 : Union[:class:`list`, :class:`numpy.array`]
+ point_2 :
The second point.
- direction : Optional[Union[:class:`list`, :class:`numpy.array`]]
+ direction :
The direction from which the brace faces towards the points.
Examples
@@ -216,7 +217,13 @@ class BraceBetweenPoints(Brace):
self.wait(2)
"""
- def __init__(self, point_1, point_2, direction=ORIGIN, **kwargs):
+ def __init__(
+ self,
+ point_1: Optional[Sequence[float]],
+ point_2: Optional[Sequence[float]],
+ direction: Optional[Sequence[float]] = ORIGIN,
+ **kwargs
+ ):
if all(direction == ORIGIN):
line_vector = np.array(point_2) - np.array(point_1)
direction = np.array([line_vector[1], -line_vector[0], 0])