Conversation
There was a problem hiding this comment.
Thanks for doing this--these are a huge improvement to what I wrote originally. The initial preamble with the example I think should help a lot of people.
One question: Should subclasses be duplicating the documentation of attributes from parent classes?
Otherwise, just a bunch of little stuff.
doc/api/animation_api.rst
Outdated
| FuncAnimation | ||
| ArtistAnimation | ||
|
|
||
| In both cases it is critical to keep a reference to tho instance |
doc/api/animation_api.rst
Outdated
| ax.set_ylim(-1, 1) | ||
| return ln, | ||
|
|
||
| def update(i): |
There was a problem hiding this comment.
Would it be better to replace i with something making it clear it's a value pulled from the frames kwarg?
doc/api/animation_api.rst
Outdated
|
|
||
| The second method is to us `functools.partial` to 'bind' artists to | ||
| function. A third method is to use closures to build up the required | ||
| artists and functions. A forth method is to create a class. |
lib/matplotlib/animation.py
Outdated
|
|
||
| # A registry for available MovieWriter classes | ||
| class MovieWriterRegistry(object): | ||
| '''Registry of of available writer classes by human readable name |
lib/matplotlib/animation.py
Outdated
| return list(self.avail.keys()) | ||
|
|
||
| def is_available(self, name): | ||
| '''If given writer is available |
There was a problem hiding this comment.
How about '''Check if given writer is available.''' ?
lib/matplotlib/animation.py
Outdated
|
|
||
| def func(fr: object, *fargs) -> iterable_of_artists: | ||
|
|
||
|
|
There was a problem hiding this comment.
Not Sure if this is an extra blank line or one needed to surround the above code block...
| If `None`, then equivalent to passing ``itertools.count`` | ||
|
|
||
| init_func : callable, optional | ||
|
|
lib/matplotlib/animation.py
Outdated
| The number of values from `frames` to cache. | ||
|
|
||
| interval : number, optional | ||
| Delay between frames. Defaults to 200 |
lib/matplotlib/animation.py
Outdated
| used. This function will be called once before the first frame. | ||
| repeat: bool, optional | ||
| controls whether the animation should repeat when the sequence | ||
| of frames is completed. |
There was a problem hiding this comment.
Add "Defaults to True."
lib/matplotlib/animation.py
Outdated
| *frames* can be a generator, an iterable, or a number of frames. | ||
| repeat_delay : number, optional | ||
| If the animation in repeated, adds a delay in milliseconds | ||
| before repeating the animation. Defaults to None |
doc/api/animation_api.rst
Outdated
| hence the timers), will be garbage collected which will stop the | ||
| animation. | ||
|
|
||
| To save an animation use to disk use |
doc/api/animation_api.rst
Outdated
| Animation | ||
| ========= | ||
|
|
||
| The easiest way to make a live animation in mpl is to use one of the |
doc/api/animation_api.rst
Outdated
| The inner workings of `FuncAnimation` is more-or-less:: | ||
|
|
||
| for d in frames: | ||
| arts = func(d, *fargs) |
There was a problem hiding this comment.
No reason why this can't say artists instead of arts.
doc/api/animation_api.rst
Outdated
|
|
||
| 'Blitting' is a `old technique | ||
| <https://en.wikipedia.org/wiki/Bit_blit>`__ in computer graphics. The | ||
| general gist is to take as existing bit map (in our case a mostly |
doc/api/animation_api.rst
Outdated
|
|
||
| ax = fig.gca() | ||
|
|
||
| def update_blit(arts): |
There was a problem hiding this comment.
Again, artists for this whole block.
lib/matplotlib/animation.py
Outdated
|
|
||
| If a generator function, then must have the signature :: | ||
|
|
||
| def gen_function(): |
There was a problem hiding this comment.
Should be -> int or -> float or anything?
lib/matplotlib/animation.py
Outdated
| The number of values from `frames` to cache. | ||
|
|
||
| interval : number, optional | ||
| Delay between frames. Defaults to 200 |
lib/matplotlib/animation.py
Outdated
| *init_func* is a function used to draw a clear frame. If not given, the | ||
| results of drawing from the first item in the frames sequence will be | ||
| used. This function will be called once before the first frame. | ||
| repeat: bool, optional |
lib/matplotlib/animation.py
Outdated
| other needed events. | ||
|
|
||
| interval : number, optional | ||
| Delay between frames. Defaults to 200 |
lib/matplotlib/animation.py
Outdated
| be disabled for other frames. | ||
|
|
||
| interval : number, optional | ||
| Delay between frames. Defaults to 200 |
|
I think I have addressed everything and re-worked the section on writers. |
doc/api/animation_api.rst
Outdated
| AVConvFileWriter | ||
|
|
||
|
|
||
| Fundamentally, a `MovieWriter` does is provide is a way to grab |
There was a problem hiding this comment.
The 'what' got removed, so now the sentence is a bit off.
There was a problem hiding this comment.
And the second 'is' is still there.
lib/matplotlib/animation.py
Outdated
| # Base class of ffmpeg information. Has the config keys and the common set | ||
| # of arguments that controls the *output* side of things. | ||
| class FFMpegBase(object): | ||
| '''Mixin class for FFMpeg output |
There was a problem hiding this comment.
It's a bit pedantic, but the first line on each of these newly documented classes sometimes does and sometimes doesn't end with a period.
lib/matplotlib/animation.py
Outdated
| be disabled for other frames. | ||
|
|
||
| interval : number, optional | ||
| Delay between frames in miliseconds. Defaults to 200. |
lib/matplotlib/animation.py
Outdated
| of frames is completed. | ||
| repeat_delay : number, optional | ||
| If the animation in repeated, adds a delay in milliseconds | ||
| before repeating the animation. Defaults to None |
There was a problem hiding this comment.
This one's missing the backticks on None.
lib/matplotlib/animation.py
Outdated
| used. This function will be called once before the first frame. | ||
| repeat : bool, optional | ||
| Controls whether the animation should repeat when the sequence | ||
| of frames is completed. Defaults to `True` |
doc/api/animation_api.rst
Outdated
| sequential frames from the same underlying `~matplotlib.figure.Figure` | ||
| object. The base class `MovieWriter` implements 3 methods and a | ||
| context manager. The only difference between the pipe-based and | ||
| file-based writers in the arguments to their respective ``setup`` |
doc/api/animation_api.rst
Outdated
| file to disk. For example :: | ||
|
|
||
| moviewriter = MovieWriter(...) | ||
| moveiewriter.setup(fig=fig, 'my_movie.ext', dpi=100) |
lib/matplotlib/animation.py
Outdated
| default to ``rcParams['animation.codec']`` | ||
|
|
||
| bitrate : number, optional | ||
| Specifies the amount of bits used per second in the |
dopplershift
left a comment
There was a problem hiding this comment.
A few truly pedantic things that I would feel back actually requiring before merging...
lib/matplotlib/animation.py
Outdated
| repeat_delay : number, optional | ||
| If the animation in repeated, adds a delay in milliseconds | ||
| before repeating the animation. Defaults to None | ||
| before repeating the animation. Defaults to `None` |
There was a problem hiding this comment.
Pedantic, but no period at the end.
| def __init__(self, fps=5, codec=None, bitrate=None, extra_args=None, | ||
| metadata=None): | ||
| ''' | ||
| '''MovieWriter |
There was a problem hiding this comment.
No period at the end--though not really a sentence, either. 😁
There was a problem hiding this comment.
I intentionally decided against a . here (due to it not being a sentence).
lib/matplotlib/animation.py
Outdated
|
|
||
| artists : list | ||
| with each list entry a collection of artists that | ||
| With each list entry a collection of artists that |
There was a problem hiding this comment.
Maybe instead just: Each list entry is a collection...
The plan (if I have time to get to it is to flesh out the FuncAnimation section with the same example implemented the other 3 ways, but I think that as-is it is still a major improvement.