{{ message }}
Clarify how to use keyword arguments in FuncAnimation - #24139
Closed
oscargus wants to merge 1 commit into
Closed
Conversation
QuLogic
reviewed
Oct 12, 2022
Member
There was a problem hiding this comment.
Suggested change
| An option to *fargs* is to use `functools.partial`, with the added | |
| An alternative to *fargs* is to use `functools.partial`, with the added |
story645
reviewed
Oct 12, 2022
Comment on lines
+1521
to
+1522
| arguments can be supplied via the *fargs* parameter. See *fargs* for | ||
| how to use `functools.partial` to supply keyword arguments. |
Member
There was a problem hiding this comment.
Suggested change
| arguments can be supplied via the *fargs* parameter. See *fargs* for | |
| how to use `functools.partial` to supply keyword arguments. | |
| arguments can be supplied using `functools.partial` or via the *fargs* parameter. |
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:
To pass in a function with positional keywords, set func to the partial function::
func = partial(func, frame, **kwargs)
Comment on lines
+1568
to
+1575
| An option to *fargs* is to use `functools.partial`, with the added | ||
| benefit of also supporting keyword arguments. An example is to pass | ||
| something like:: | ||
|
|
||
| partial(func, **kwargs) | ||
|
|
||
| as *func*. | ||
|
|
Member
There was a problem hiding this comment.
I think if you move the intro of partial up to func, this can be simplified to
Suggested change
| An option to *fargs* is to use `functools.partial`, with the added | |
| benefit of also supporting keyword arguments. An example is to pass | |
| something like:: | |
| partial(func, **kwargs) | |
| as *func*. | |
| Passing in `functools.partial` as *func* is preferred to passing in *fargs* and supports keyword arguments. See *func* for an example. |
timhoffm
reviewed
Oct 12, 2022
| benefit of also supporting keyword arguments. An example is to pass | ||
| something like:: | ||
|
|
||
| partial(func, **kwargs) |
Member
There was a problem hiding this comment.
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
| partial(func, **kwargs) | |
| partial(func, my_kwarg='something') |
Maye even show a more complete FuncAnimation call to show this fits in.
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

PR Summary
Closes #20326
I didn't find a good animation example to modify...
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand runflake8 --docstring-convention=all).Documentation
doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).