Repository navigation
Add assert_plot_equal to compare a plot with a reference plot - #43
Merged
Merged
Conversation
It replaces the legacy grader's Feedback.check_plot. By default it compares the number of subplots, axis scales, and line, scatter and bar data, with options to check labels, titles, legends, limits and styles, require order, or allow extra series. matplotlib is still imported only when a plot is checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also remove a matched series by position instead of with list.remove, which compared series with == and raised for two lines with the same label. 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.
Adds
assertions.assert_plot_equal(plot, expected, ...), a replacement for the legacy grader'sFeedback.check_plot.numpy.allclose. Series can be in any order. A line also matches with its points reversed, but not scrambled. Scatter points and bars can be in any order.ordered,allow_extra, and opt-incheck_labels,check_titles,check_legend,check_limitsandcheck_styles.check_scalesandcheck_datacan be turned off.Expected a log scale on the y-axis of your plot, but found a linear scale.nameandmsgcustomize the message.plot_checks.py, whichassertionsimports only when the function is called. A new test imports the plugin,assertionsandfixturewith matplotlib and numpy blocked.check_plotprinted the list of lines instead of the expected count. Its point sort also went along the wrong axis.Unit tests cover each check, the failure messages, and a plot rebuilt from the sandbox's JSON with every check turned on. The
test_plain_matplotlibscenario adds a passing check and a failing one with friendly output. Documented inquick_start.mdunder "Comparing with a Reference Plot".🤖 Generated with Claude Code