Skip to content

Commit 3377f6c

Browse files
Replace exceptions, remove unused parameters, and fix type hints in Animation, ShowPartial, Create, ShowPassingFlash, and DrawBorderThenFill (#4214)
Co-authored-by: Francisco Manríquez Novoa <[email protected]> Co-authored-by: Francisco Manríquez <[email protected]>
1 parent e4b1d10 commit 3377f6c

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

manim/animation/animation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __new__(
120120
if func is not None:
121121
anim = func(mobject, *args, **kwargs)
122122
logger.debug(
123-
f"The {cls.__name__} animation has been is overridden for "
123+
f"The {cls.__name__} animation has been overridden for "
124124
f"{type(mobject).__name__} mobjects. use_override = False can "
125125
f" be used as keyword argument to prevent animation overriding.",
126126
)
@@ -140,7 +140,7 @@ def __init__(
140140
introducer: bool = False,
141141
*,
142142
_on_finish: Callable[[], None] = lambda _: None,
143-
**kwargs,
143+
use_override: bool = True, # included here to avoid TypeError if passed from a subclass' constructor
144144
) -> None:
145145
self._typecheck_input(mobject)
146146
self.run_time: float = run_time
@@ -160,8 +160,6 @@ def __init__(
160160
else:
161161
self.starting_mobject: Mobject = Mobject()
162162
self.mobject: Mobject = mobject if mobject is not None else Mobject()
163-
if kwargs:
164-
logger.debug("Animation received extra kwargs: %s", kwargs)
165163

166164
if hasattr(self, "CONFIG"):
167165
logger.error(
@@ -498,6 +496,8 @@ def __init_subclass__(cls, **kwargs) -> None:
498496

499497
cls._original__init__ = cls.__init__
500498

499+
_original__init__ = __init__ # needed if set_default() is called with no kwargs directly from Animation
500+
501501
@classmethod
502502
def set_default(cls, **kwargs) -> None:
503503
"""Sets the default values of keyword arguments.

manim/animation/creation.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __init__(
120120
):
121121
pointwise = getattr(mobject, "pointwise_become_partial", None)
122122
if not callable(pointwise):
123-
raise NotImplementedError("This animation is not defined for this Mobject.")
123+
raise TypeError(f"{self.__class__.__name__} only works for VMobjects.")
124124
super().__init__(mobject, **kwargs)
125125

126126
def interpolate_submobject(
@@ -133,7 +133,7 @@ def interpolate_submobject(
133133
starting_submobject, *self._get_bounds(alpha)
134134
)
135135

136-
def _get_bounds(self, alpha: float) -> None:
136+
def _get_bounds(self, alpha: float) -> tuple[float, float]:
137137
raise NotImplementedError("Please use Create or ShowPassingFlash")
138138

139139

@@ -173,7 +173,7 @@ def __init__(
173173
) -> None:
174174
super().__init__(mobject, lag_ratio=lag_ratio, introducer=introducer, **kwargs)
175175

176-
def _get_bounds(self, alpha: float) -> tuple[int, float]:
176+
def _get_bounds(self, alpha: float) -> tuple[float, float]:
177177
return (0, alpha)
178178

179179

@@ -229,8 +229,6 @@ def __init__(
229229
rate_func: Callable[[float], float] = double_smooth,
230230
stroke_width: float = 2,
231231
stroke_color: str = None,
232-
draw_border_animation_config: dict = {}, # what does this dict accept?
233-
fill_animation_config: dict = {},
234232
introducer: bool = True,
235233
**kwargs,
236234
) -> None:
@@ -244,8 +242,6 @@ def __init__(
244242
)
245243
self.stroke_width = stroke_width
246244
self.stroke_color = stroke_color
247-
self.draw_border_animation_config = draw_border_animation_config
248-
self.fill_animation_config = fill_animation_config
249245
self.outline = self.get_outline()
250246

251247
def _typecheck_input(self, vmobject: VMobject | OpenGLVMobject) -> None:

manim/animation/indication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def __init__(self, mobject: VMobject, time_width: float = 0.1, **kwargs) -> None
307307
self.time_width = time_width
308308
super().__init__(mobject, remover=True, introducer=True, **kwargs)
309309

310-
def _get_bounds(self, alpha: float) -> tuple[float]:
310+
def _get_bounds(self, alpha: float) -> tuple[float, float]:
311311
tw = self.time_width
312312
upper = interpolate(0, 1 + tw, alpha)
313313
lower = upper - tw

manim/animation/transform_matching_parts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ def __init__(
9696
# target_map
9797
transform_source = group_type()
9898
transform_target = group_type()
99-
kwargs["final_alpha_value"] = 0
10099
for key in set(source_map).intersection(target_map):
101100
transform_source.add(source_map[key])
102101
transform_target.add(target_map[key])

manim/mobject/mobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ def update_label(mobject):
10111011
label.add_updater(update_label)
10121012
self.add(dot, label)
10131013
1014-
self.play(Rotating(dot, about_point=ORIGIN, angle=TAU, run_time=TAU, rate_func=linear))
1014+
self.play(Rotating(dot, about_point=ORIGIN, run_time=TAU, rate_func=linear))
10151015
10161016
.. manim:: DtUpdater
10171017

0 commit comments

Comments
 (0)