@@ -4,7 +4,7 @@ Choosing Typehints
4
4
In order to provide the best user experience,
5
5
it's important that typehints are chosen correctly.
6
6
With the large variety of types provided by Manim, choosing
7
- which one to use can be difficult. This guide aims to
7
+ which one to use can be difficult. This guide aims to
8
8
aid you in the process.
9
9
10
10
@@ -23,21 +23,23 @@ in space. For example:
23
23
.. code-block :: python
24
24
25
25
def status2D (coord : Point2D) -> None :
26
- x, y = coord
27
- print (f " Point at { x= } , { y= } " )
26
+ x, y = coord
27
+ print (f " Point at { x= } , { y= } " )
28
+
28
29
29
30
def status3D (coord : Point3D) -> None :
30
- x, y, z = coord
31
- print (f " Point at { x= } , { y= } , { z= } " )
31
+ x, y, z = coord
32
+ print (f " Point at { x= } , { y= } , { z= } " )
33
+
32
34
33
35
def get_statuses (coords : Point2D_Array | Point3D_Array) -> None :
34
- for coord in coords:
35
- if len (coord) == 2 :
36
- # it's a Point2D
37
- status2D(coord)
38
- else :
39
- # it's a point3D
40
- status3D(coord)
36
+ for coord in coords:
37
+ if len (coord) == 2 :
38
+ # it's a Point2D
39
+ status2D(coord)
40
+ else :
41
+ # it's a point3D
42
+ status3D(coord)
41
43
42
44
It's important to realize that the status functions worked with both
43
45
tuples/lists of the correct length, and ``NDArray ``'s of the correct shape.
@@ -56,7 +58,7 @@ consider this slightly contrived function:
56
58
.. code-block :: python
57
59
58
60
def shift_mobject (mob : Mobject, direction : Vector3D, scale_factor : float = 1 ) -> mob:
59
- return mob.shift(direction * scale_factor)
61
+ return mob.shift(direction * scale_factor)
60
62
61
63
Here we see an important example of the difference. ``direction `` can not, and
62
64
should not, be typed as a ``Point3D `` because it does not work with something
@@ -83,5 +85,3 @@ Béziers
83
85
84
86
Functions
85
87
---------
86
-
87
-
0 commit comments