17
17
from manim .mobject .types .vectorized_mobject import VMobject
18
18
19
19
if TYPE_CHECKING :
20
+ from typing import Any
21
+
20
22
from typing_extensions import Self
21
23
22
24
from manim .typing import Point3D , Point3DLike
25
+ from manim .utils .color import ParsableManimColor
23
26
24
27
from manim .utils .color import YELLOW
25
28
@@ -111,7 +114,7 @@ def __init__(
111
114
discontinuities : Iterable [float ] | None = None ,
112
115
use_smoothing : bool = True ,
113
116
use_vectorized : bool = False ,
114
- ** kwargs ,
117
+ ** kwargs : Any ,
115
118
):
116
119
def internal_parametric_function (t : float ) -> Point3D :
117
120
"""Wrap ``function``'s output inside a NumPy array."""
@@ -143,13 +146,13 @@ def generate_points(self) -> Self:
143
146
lambda t : self .t_min <= t <= self .t_max ,
144
147
self .discontinuities ,
145
148
)
146
- discontinuities = np .array (list (discontinuities ))
149
+ discontinuities_array = np .array (list (discontinuities ))
147
150
boundary_times = np .array (
148
151
[
149
152
self .t_min ,
150
153
self .t_max ,
151
- * (discontinuities - self .dt ),
152
- * (discontinuities + self .dt ),
154
+ * (discontinuities_array - self .dt ),
155
+ * (discontinuities_array + self .dt ),
153
156
],
154
157
)
155
158
boundary_times .sort ()
@@ -211,19 +214,29 @@ def construct(self):
211
214
self.add(cos_func, sin_func_1, sin_func_2)
212
215
"""
213
216
214
- def __init__ (self , function , x_range = None , color = YELLOW , ** kwargs ):
217
+ def __init__ (
218
+ self ,
219
+ function : Callable [[float ], Any ],
220
+ x_range : np .array | None = None ,
221
+ color : ParsableManimColor = YELLOW ,
222
+ ** kwargs : Any ,
223
+ ) -> None :
215
224
if x_range is None :
216
225
x_range = np .array ([- config ["frame_x_radius" ], config ["frame_x_radius" ]])
217
226
218
227
self .x_range = x_range
219
- self .parametric_function = lambda t : np .array ([t , function (t ), 0 ])
220
- self .function = function
228
+ self .parametric_function : Callable [[float ], np .array ] = lambda t : np .array (
229
+ [t , function (t ), 0 ]
230
+ )
231
+ # TODO:
232
+ # error: Incompatible types in assignment (expression has type "Callable[[float], Any]", variable has type "Callable[[Arg(float, 't')], Any]") [assignment]
233
+ self .function = function # type: ignore[assignment]
221
234
super ().__init__ (self .parametric_function , self .x_range , color = color , ** kwargs )
222
235
223
- def get_function (self ):
236
+ def get_function (self ) -> Callable [[ float ], Any ] :
224
237
return self .function
225
238
226
- def get_point_from_function (self , x ) :
239
+ def get_point_from_function (self , x : float ) -> np . array :
227
240
return self .parametric_function (x )
228
241
229
242
@@ -236,8 +249,8 @@ def __init__(
236
249
min_depth : int = 5 ,
237
250
max_quads : int = 1500 ,
238
251
use_smoothing : bool = True ,
239
- ** kwargs ,
240
- ):
252
+ ** kwargs : Any ,
253
+ ) -> None :
241
254
"""An implicit function.
242
255
243
256
Parameters
@@ -295,7 +308,7 @@ def construct(self):
295
308
296
309
super ().__init__ (** kwargs )
297
310
298
- def generate_points (self ):
311
+ def generate_points (self ) -> Self :
299
312
p_min , p_max = (
300
313
np .array ([self .x_range [0 ], self .y_range [0 ]]),
301
314
np .array ([self .x_range [1 ], self .y_range [1 ]]),
0 commit comments