3b1b/manim · error · Exception
Whoops, looks like you accidentally invoked the method you w
Error message
Whoops, looks like you accidentally invoked the method you want to animate
What it means
ApplyMethod wraps a bound mobject method (e.g. circle.shift) and animates applying it. check_validity_of_input requires inspect.ismethod(method): passing the method's *return value* — i.e. calling it — fails, because the animation needs the callable plus separate args to build the target state.
Source
Thrown at manimlib/animation/transform.py:173
class ApplyMethod(Transform):
def __init__(self, method: Callable, *args, **kwargs):
"""
method is a method of Mobject, *args are arguments for
that method. Key word arguments should be passed in
as the last arg, as a dict, since **kwargs is for
configuration of the transform itself
Relies on the fact that mobject methods return the mobject
"""
self.check_validity_of_input(method)
self.method = method
self.method_args = args
super().__init__(method.__self__, **kwargs)
def check_validity_of_input(self, method: Callable) -> None:
if not inspect.ismethod(method):
raise Exception(
"Whoops, looks like you accidentally invoked "
"the method you want to animate"
)
assert isinstance(method.__self__, Mobject)
def create_target(self) -> Mobject:
method = self.method
# Make sure it's a list so that args.pop() works
args = list(self.method_args)
if len(args) > 0 and isinstance(args[-1], dict):
method_kwargs = args.pop()
else:
method_kwargs = {}
target = method.__self__.copy()
method.__func__(target, *args, **method_kwargs)
return target
View on GitHub (pinned to dee01804d4)
Solutions
- Pass the method uninvoked with its arguments separately: ApplyMethod(circle.shift, RIGHT)
- Prefer the modern syntax: self.play(circle.animate.shift(RIGHT))
- For functions that are not mobject methods, use ApplyFunction(function, mobject) instead
Example fix
# before self.play(ApplyMethod(circle.shift(RIGHT))) # after self.play(ApplyMethod(circle.shift, RIGHT)) # or self.play(circle.animate.shift(RIGHT))
Defensive patterns
Strategy: type-guard
Validate before calling
import inspect assert inspect.ismethod(circle.shift), "pass the method itself, not its result"
Type guard
import inspect
def is_bound_mobject_method(f) -> bool:
return inspect.ismethod(f) and isinstance(f.__self__, Mobject) Prevention
- Standardize on mob.animate.method(args) — it removes the call-vs-reference ambiguity entirely
- In code review, flag any ApplyMethod(...) whose first argument ends in ')'
When it happens
Trigger: ApplyMethod(circle.shift(RIGHT)) instead of ApplyMethod(circle.shift, RIGHT); passing a free function or lambda instead of a bound method; passing mobject.copy() (returns a Mobject, not a method).
Common situations: Muscle memory from scene.play(circle.shift(RIGHT)); migrating old scripts that mixed direct method calls with ApplyMethod; using .animate and ApplyMethod inconsistently in the same file.
Related errors
- Functions passed to ApplyFunction must return object of type
- {self.__class__.__name__}.create_target not properly impleme
- MoveToTarget called on mobject without attribute 'target'
- Trying to restore without having saved
- Matrix has bad dimensions
AI-assisted analysis of 3b1b/manim@dee01804d4 (2026-08-14).
Data as JSON: /api/errors/a5feb485f26a194e.
Report an issue: GitHub.