fix(site): round figures exactly as the report does, near ties included - #93
Merged
Merged
Conversation
fixed4's exact-tie test compared x * 10000 with itself, so it was always true and every near tie was rounded half to even, printing 0.00125 as 0.0012 where Python prints 0.0013. A double sits exactly on a four-place tie only when x * 32 is an odd integer, and that product is exact, so the formatter now checks that and otherwise leaves toFixed to round the exact value. The golden fixture carries 890 tie and near-tie values and two near-tie measured values, which the old formatter fails and this passes. Fixes #48. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.
Fixes #48.
The bug.
fixed4insite/floor.jsis meant to round half to even only on an exact tie, the way Python's:.4fdoes. Its tie test comparedx * 10000 === scaled, andscaledwas defined asx * 10000, so the test was always true. Every near tie was forced to half-even. For example, a measured ECE of0.00125printed as0.0012on the site, while the report prints0.0013.The fix.
toFixedalready rounds the exact binary value. It differs from Python only on an exact tie, where it rounds away from zero and Python rounds to even.x = (2k + 1) / 20000.20000 = 32 * 625, so a double can sit exactly on a tie only whenx * 32is an odd integer (0.03125, 0.09375, ...).toFixed.Evidence.
fixed4tableCoverage.
scripts/floor_golden.pynow exports afixed4table: every exact tie below 2, plus near ties with both float neighbours across the ECE range. It also adds0.00125and0.03125to the measured values each verdict sentence is exported for.--checkcompares the table too, andcheck_floor_parity.mjsfails on any disagreement.With the old
floor.js, the parity check now fails: 142 values are misformatted, and every case's verdict for ECE 0.00125 differs. The fixture grows by about 30 KB.Checks. ruff, format, mypy --strict and pytest pass. The site build, parity (including the worked example), links, search and the browser smoke test all pass.
🤖 Generated with Claude Code