Repository navigation
Support text, annotations, axhline and axvline in plots, and fix a startup timeout race - #44
Draft
eliotwrobson wants to merge 2 commits into
Draft
eliotwrobson wants to merge 2 commits into
eliotwrobson wants to merge 2 commits into
Conversation
Plain text and annotations in data or axes coordinates, and lines from axhline and axvline, are now sent to the test instead of rejecting the whole plot. assert_plot_equal compares the new lines with the other data, and a new check_texts option compares text and annotations. Extra text is ignored unless check_texts is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The parent read the start response with the same timeout the sandbox used for the student code, so a slow submission got either message at random. Wait a little longer so the sandbox's timeout response arrives first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A correct plot that also has
plt.text(...)is currently rejected when it's sent to the test, so the student scores 0 with "text and annotations aren't supported". A review comment on PrairieLearn/PrairieLearn#16284 found this.axhlineandaxvline, which students often use for reference lines, are rejected the same way.textin data or axes coordinates, with its alignment and rotation.annotate, with its point in data or axes coordinates, its text position in data or axes coordinates or offset points, and whether it has an arrow. Every arrow comes back as a plain->arrow.axhlineandaxvline, with their position, extent, label, color, width and style. A line is treated as one only if it uses their blended transform and has a constant value, so other blended lines are still rejected.axline,errorbarandfill_betweenare still rejected.assert_plot_equal:axhlineandaxvlinelines are compared as their own kinds, with the same rules as other lines.check_textsoption, off by default, compares the strings of text and annotations, and the point each annotation points at. The position of plain text isn't compared.check_textsis on, which covers the review comment's case.test_timeoutflaky. The read now waits an extra 0.5 seconds, so the sandbox's own message is reported. "No response" is now only for a sandbox that doesn't answer at all.Testing
With an image built from this branch, the converted
plotsquestion gives:plt.textannotatewith an arrowaxhlineExpected 0 horizontal lines in your plot, but found 1.The
axhlineresult is intended: extra lines fail unless the test setsallow_extra. In all three cases, the image shown with the results matched the student's plot.The timeout scenarios failed about 1 run in 12 before the race fix, and passed 40 runs in a row after it.
🤖 Generated with Claude Code