Repository navigation
Fix the flaky red badge: compare figures by content, not bytes - #1
Conversation
Commit 4071c1e failed the figure step on Nov 29 (one PNG, 3 bytes) and passed it on Nov 30 with the same runner image and pins, so byte equality is not stable even in CI. tools/check_figures.py still fails on any content change (a swapped digit in a 10 pt label moves ~200 pixels) and passes antialiasing noise (25 pixels or fewer), with a self-test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 905d551160
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
|
|
||
| def changed_figures() -> list[str]: | ||
| out = _git("diff", "--name-only", "--", "*/figures/*.png").decode().split() |
There was a problem hiding this comment.
Include staged figure changes in the comparison
When a contributor stages regenerated PNGs before running this documented checker, git diff compares the worktree to the index, while git ls-files --others omits staged files. changed_figures() can therefore be empty and the check falsely succeeds without inspecting the staged image. CI currently runs from a clean checkout, but the local check should include staged changes when comparing against HEAD.
Useful? React with 👍 / 👎.
Before: the README badge has been red since Nov 29. The only failing step was "Committed figures are exactly what the code produces":
tariff-explorer/figures/01_regime_bill_curves.pngcame out 141094 -> 141097 bytes. I re-ran CI on the same commit (4071c1e) today with the same runner image (ubuntu-26 20261111.635), Python 3.12.16 and identical matplotlib 3.10.8 / numpy 2.4.4 / pandas 2.3.3 / pillow 12.1.1, and it passed. A one-off workflow on a scratch branch also regenerated every figure on a runner and found none that differed. So the figures are current and the check itself is flaky.After:
tools/check_figures.pyreplacesgit diff --exit-code. A regenerated figure fails if its size changes or if more than 25 pixels move by more than 16/255 on any channel. It still catches the case the check exists for: its self-test shows a corrected title moves 2,081 pixels and a single swapped digit in a 10 pt label ("$1,234" to "$1,243") moves 202. Thegit diff --statline still prints, and the upload-on-failure step is unchanged. The three study READMEs now say figures are "checked against the code in CI" instead of "byte-for-byte".How: Pillow and numpy, both already pinned through matplotlib. I couldn't run
check_bundle.pyorupdate_manifest.py --checklocally (they import pandapower), so this PR's CI run is the real test.Cleanup for you: the scratch branch
claude/ci-rendered-figureis still on GitHub because branch deletion is blocked from my side. It holds only the one-off workflow; delete it from the branches page.Generated by Claude Code