-
Notifications
You must be signed in to change notification settings - Fork 85
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
Matplotlib upgrade #270
base: main
Are you sure you want to change the base?
Matplotlib upgrade #270
Conversation
Wow this is an awesome addition, thanks @zombie-einstein! Which environments are still remaining? Also I think the way you've done it with |
Apart from rubix cube they all need a look at, with varying degrees of complexity. I think the general pattern needs to be something like a Some also currently have actors that are created dynamically during plotting I've been trying to work out the best pattern for, in some cases it seems it would be more efficient to initialise all the actors ahead of time, and update their states as needed. E.g. for the sudoko environment initialise all the text actors and update the text during animation (rather than create them on the fly). So there's a decent chunk of work to refactor all the plots. One option could be merge something like this PR, which will updated the requirement and passes linting/tests, and still create plots (just less efficiently), and then incrementally update the individual viewers in separate PRs to make best use of the new API. |
Hi @zombie-einstein sorry for leaving this hanging, I needed a bit of time off 😂 I'll have a deeper look at it this week and give some a proper opinion 😄 |
Sure no worries, let me know if you've any follow up questions on the API update. |
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.
I like the pattern, although seems like tetris is a special case?
One thing that I think would be nice to standardise is the name of the main draw function, many are called _add_foo
or _draw_xyz
. I think a good name would be _draw_state
or _draw_frame
?
As a function signature maybe:
def _draw_state(state: State, artist: Artist) -> Artist
Just going to check that everything is rendering properly
Ok I've run all of them and they look good to me except for:
Knapsack seems to just be because the knapsack image isn't added to the manifest which is an easy fix, the others seem to have deeper issues. I tested with the following notebook (we can add this to the examples folder for easy testing in the future) |
Yeah think this would be ideal, I think it should be something like a 'draw_frame(...) -> Sequence[Artist]` that draws the full frame/image and can be called to draw a single frame/image and returns any artists that can be updated (I think in principle this could be any data structure of artists). |
Yeah good shout, it was kind of painful to check all these manually. |
Hey @sash-a, thought I'd grab a look at #253.
Changes here update Matplotlib version and then makes changes to pass type checking, so it builds and passes tests.
But ...
The new API now requires that the animation update function returns a list of artists that have been updated, these are objects returned from plotting calls like a plot object, or text box (see the table here). The state/data of these objects can be updated without redrawing the whole thing.
I've done this rubiks cube environment:
Doing this for all environments is easier for some than others given how they've been written, it means passing all the relevant artists to the animate function when the plot is created, and then correctly updating them inside the update function.
I think the animations will still work as is, as they still generally update the axes by reference inside the animation function, it's just less efficient then the new API that just updates the relevant artists.