Repository navigation
Add pause() and resume() methods to the base Animation class - #17826
Conversation
|
@tacaswell here is my first pass at adding the I had a few questions/issues before proceeding and wanted to open this to get feedback:
Thanks again for the opportunity to contribute to this awesome library! |
|
I would not worry too much about thread safety, Matplotlib is deeply non-thread safe (if you are trying to work on the same figure from multiple threads it is going to go badly in many many other places). While testing everything is good, there as a trade off when the effort of getting the testing working is worth the cost of getting it working. For this to work right you really need to have a running GUI event loop to manage the asynchronous nature of things. I would start by writing stand alone scripts that use timers (https://matplotlib.org/3.2.2/gallery/event_handling/timers.html) to start / stop a running animation. Once that is working we can sort out the best way to fold that into the test suite (or if having those scripts as an example is the practical option). |
Ack'd. I won't worry about it then.
Makes sense, what path in the project do these scripts normally go? |
dopplershift
left a comment
There was a problem hiding this comment.
👍 to the functionality. I think this would work, but would love to see an existence proof--even an example that uses this would be good.
I will get working on an example script then! |
|
@dopplershift example script for pausing/resuming animations in the latest set of commits. The example is a simplified version of the example used in #17689 |
dopplershift
left a comment
There was a problem hiding this comment.
Example works well from me. Just one minor comment to address and I'll be good with this.
dopplershift
left a comment
There was a problem hiding this comment.
Looks good to me! Thanks for working with us on the changes.
|
This seems good, except that the example doesn't animate? |
|
@QuLogic hmm, it worked for me on Linux (and I assume it worked for @dopplershift since he gave an LGTM), what platform are you using? |
|
It's working (starting up with an animation and responding to clicks for pause/resume) for me with both the macOS and Qt5Agg backends on my Mac running 10.15. |
|
You have a number of documentation build errors. Probably need to use double back quotes instead of single? |
|
I figured it out; it's the usual garbage collection issue for animations. You need to assign the |
|
I don't know why docs are failing though; can you try rebasing to the latest |
|
Oh, this is actually some missing references because the autosummary tries to put in base methods in subclasses. This is already ignored, but these new methods changed things a bit. You will need to update diff --git a/doc/missing-references.json b/doc/missing-references.json
index 77244902b..f6fffc11d 100644
--- a/doc/missing-references.json
+++ b/doc/missing-references.json
@@ -1136,6 +1136,12 @@
"matplotlib.animation.ArtistAnimation.to_jshtml": [
"doc/api/_as_gen/matplotlib.animation.ArtistAnimation.rst:21:<autosummary>:1"
],
+ "matplotlib.animation.ArtistAnimation.pause": [
+ "doc/api/_as_gen/matplotlib.animation.ArtistAnimation.rst:23:<autosummary>:1"
+ ],
+ "matplotlib.animation.ArtistAnimation.resume": [
+ "doc/api/_as_gen/matplotlib.animation.ArtistAnimation.rst:23:<autosummary>:1"
+ ],
"matplotlib.animation.FFMpegFileWriter.args_key": [
"lib/matplotlib/animation.py:docstring of matplotlib.animation.FFMpegFileWriter.supported_formats:1:<autosummary>:1"
],
@@ -1235,6 +1241,12 @@
"matplotlib.animation.FuncAnimation.to_jshtml": [
"lib/matplotlib/animation.py:docstring of matplotlib.animation.FuncAnimation.new_frame_seq:1:<autosummary>:1"
],
+ "matplotlib.animation.FuncAnimation.pause": [
+ "lib/matplotlib/animation.py:docstring of matplotlib.animation.FuncAnimation.new_frame_seq:1:<autosummary>:1:"
+ ],
+ "matplotlib.animation.FuncAnimation.resume": [
+ "lib/matplotlib/animation.py:docstring of matplotlib.animation.FuncAnimation.new_frame_seq:1:<autosummary>:1:"
+ ],
"matplotlib.animation.HTMLWriter.bin_path": [
"doc/api/_as_gen/matplotlib.animation.HTMLWriter.rst:28:<autosummary>:1"
],
@@ -1361,6 +1373,12 @@
"matplotlib.animation.TimedAnimation.to_jshtml": [
"doc/api/_as_gen/matplotlib.animation.TimedAnimation.rst:21:<autosummary>:1"
],
+ "matplotlib.animation.TimedAnimation.pause": [
+ "doc/api/_as_gen/matplotlib.animation.TimedAnimation.rst:23:<autosummary>:1"
+ ],
+ "matplotlib.animation.TimedAnimation.resume": [
+ "doc/api/_as_gen/matplotlib.animation.TimedAnimation.rst:23:<autosummary>:1"
+ ],
"matplotlib.cbook.ls_mapper": [
"doc/api/prev_api_changes/api_changes_1.5.0.rst:11",
"doc/api/prev_api_changes/api_changes_1.5.0.rst:8"or I can push these changes for you. |
|
Now I don't understand why it was working for me in the first place. Oh well. |
Done.
Done.
I'm willing to chalk it up to dark magic for now 😅 |
dopplershift
left a comment
There was a problem hiding this comment.
Looks good pending CI passing.
|
Thanks @DCtheTall! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again. |
|
Thanks for this @DCtheTall ! Sorry I instigated this work and then dropped off entirely. |
|
Thanks all! Happy to have contributed to a library I use pretty often these days, hope to be back for more in the future 😄 |
PR Summary
PR Checklist