Repository navigation
fix(plot): PyPlot and PyPlot2 step() raise ValueError for a dt of zero or less - #875
Merged
Merged
Conversation
…o or less plt.pause(0) does not return, because a timeout of zero means to wait until the event loop is stopped, so env.step(0) hung with no message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
petercorke
enabled auto-merge (squash)
October 21, 2026 07:05
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 10 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
2 tasks
… an error The notebook animation draws a frame for each step and does not pause, and its tests (and users) pass dt=0. Raising for every render mode broke them on CI. The hang is plt.pause(0), which is only called in the window render mode. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…x/pyplot-step-zero-dt
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #875 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 146 146
Lines 17096 17100 +4
=====================================
- Misses 17096 17100 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
PyPlot.step(0)andPyPlot2.step(0)hung with no message:stepends withplt.pause(dt), and Matplotlib'spause(0)does not return, because a timeout of zero means "wait until the event loop is stopped". Found while writing tests for #873.Both
stepmethods now raiseValueError("dt is 0, it must be greater than zero: ...")for adtof zero or less in the window render mode, which is the only mode that callsplt.pause; in a notebook there is no pause anddt=0is fine (the notebook animation tests passdt=0.0, which the first version of this PR broke on CI). Documented in the docstring.robot.plot(q, dt=0)raises the same way (after the scene is made). Swift is not affected and itsstep(0)is unchanged; the one example that callsenv.step(0)(examples/mexican-wave.py) uses Swift.Not changed: other
plt.pausecalls that take a caller's value; they are listed in #876 (PoseGraph.plot_scan(pause=0)and theVehicleanimation).Changes public behaviour: a zero or negative
dtraised nothing and never returned; it now raisesValueError. No change to anything that worked.Ran: the full test suite (all pass except the 20 known
test_servo_half_turnfailures from a stale compiled extension in my worktree) and mypy (clean, 165 files); the real-kernel notebook tests (test_notebook_animation.py,test_swift_notebook.py) against this branch's code, by a kernelspec that imports the worktree, since the default kernel imports the editable install. Newtests/test_step_dt.py(14 tests, each with a timeout so that a regression fails instead of hanging).Written with Claude Code.
🤖 Generated with Claude Code