fix(pyplot): robot.plot(..., movie=...) crashes on save - #645
Merged
Conversation
Two real, independent bugs in the movie-recording path, both surfaced by real reproduction of #405: - BaseRobot.plot() referenced PyPlot in an isinstance check (`isinstance(env, PyPlot)`) with no import of PyPlot anywhere in the module -- immediate NameError the instant movie= was used, on every platform. - PyPlot.getframe() called canvas.tostring_rgb(), removed from matplotlib's Agg canvas in a later release (the w_xaxis-era API this issue's traceback also shows). Replaced with the modern canvas.buffer_rgba() (RGBA -> converted to RGB for GIF saving). Verified end-to-end: a real trajectory now saves a valid multi-frame GIF via robot.plot(qt.q, backend="pyplot", movie=path). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Aug 26, 2026
…t_movie Image.open() keeps a lazy file handle open on multi-frame images to support seek(). Windows refuses to delete a file while a handle to it is still open, so tempfile.TemporaryDirectory()'s cleanup raised PermissionError [WinError 32] on Windows CI. macOS/Linux allow unlinking an open file (POSIX semantics), which is why this only failed on windows-latest. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner
Author
|
Closing and reopening to force a fresh CI run against the latest commit (a direct push to this branch didn't trigger the pull_request workflow event for some reason). |
Resolves trivial conflict in tests/test_PyPlot.py: both this branch and main (via #642) added a new test method at the same location. Kept both test_plot_movie and test_options_scalar_override.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #645 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 143 143
Lines 14026 14029 +3
=====================================
- Misses 14026 14029 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
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.
Summary
Two real, independent bugs in the movie-recording path (
robot.plot(q, backend="pyplot", movie=...)), both found by actually reproducing #405 rather than assuming the originalw_xaxistraceback was the whole story:BaseRobot.plot()referencedPyPlotin anisinstancecheck with no import ofPyPlotanywhere in the module — an immediateNameErrorthe instantmovie=was used, on any platform, regardless of matplotlib version.PyPlot.getframe()calledcanvas.tostring_rgb(), which no longer exists on matplotlib's Agg canvas (removed after being deprecated). Replaced with the moderncanvas.buffer_rgba(), converting the resulting RGBA image to RGB before saving (GIFs don't need the alpha channel).Test plan
test_plot_movieintests/test_PyPlot.py: runs a real 3-frame trajectory throughrobot.plot(..., movie=path), confirms the output is a valid multi-frame GIF (not just "no exception").NameErroragainst the pre-fix code, and passes with the fix.tests/test_PyPlot.pysuite green (6 passed).Fixes #405.
🤖 Generated with Claude Code