-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Clarify how to use keyword arguments in FuncAnimation #24139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1518,7 +1518,8 @@ class FuncAnimation(TimedAnimation): | |||||||||||||||||
func : callable | ||||||||||||||||||
The function to call at each frame. The first argument will | ||||||||||||||||||
be the next value in *frames*. Any additional positional | ||||||||||||||||||
arguments can be supplied via the *fargs* parameter. | ||||||||||||||||||
arguments can be supplied via the *fargs* parameter. See *fargs* for | ||||||||||||||||||
how to use `functools.partial` to supply keyword arguments. | ||||||||||||||||||
|
||||||||||||||||||
The required signature is:: | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -1564,6 +1565,14 @@ def init_func() -> iterable_of_artists | |||||||||||||||||
fargs : tuple or None, optional | ||||||||||||||||||
Additional arguments to pass to each call to *func*. | ||||||||||||||||||
|
||||||||||||||||||
An option to *fargs* is to use `functools.partial`, with the added | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
benefit of also supporting keyword arguments. An example is to pass | ||||||||||||||||||
something like:: | ||||||||||||||||||
|
||||||||||||||||||
partial(func, **kwargs) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't you normally have the case that you want to set some kwargs explicitly? Then I suggest to make the example more concrete:
Suggested change
Maye even show a more complete |
||||||||||||||||||
|
||||||||||||||||||
as *func*. | ||||||||||||||||||
|
||||||||||||||||||
Comment on lines
+1568
to
+1575
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if you move the intro of partial up to func, this can be simplified to
Suggested change
|
||||||||||||||||||
save_count : int, default: 100 | ||||||||||||||||||
Fallback for the number of values from *frames* to cache. This is | ||||||||||||||||||
only used if the number of frames cannot be inferred from *frames*, | ||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flipped because I think the functools version is preferred. I think it's gonna be clearer to add the information about partial in this section since it's passed in as the func keyword, Maybe after the required signature, something like: