fix: stop rendering "-0.0 pp" for tiny negative share changes in compare - #529
Merged
Merged
Conversation
A share_delta that rounds to 0.0 at one decimal place still carried its sign through Python's %+.1f formatting, so compare output printed "-0.0 pp" next to two identical-looking percentages (e.g. 50.0% -> 50.0%). Added a small _strip_neg_zero() helper that returns 0.0 when a value rounds to zero at the display precision, and applied it in both compare_to_terminal (the share_delta column) and compare_to_html's signed() helper (which also covers the score-delta rendering). Closes yakew7#515 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
@propcgamer20-png is attempting to deploy a commit to the yashkewlani2020-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
faircode/report.pyrenders a misleading-0.0 ppwhenever ashare_deltais a tiny negative float that rounds to0.0at one decimal place. Both surfaces are affected:compare_to_terminal- the{g['share_delta'] * 100:+5.1f}columncompare_to_html'ssigned()helper -prefix = "+" if val > 0 else ""thenf"{val:.1f}"Repro (before)
-0.0 ppnext to50.0% -> 50.0%reads as a rendering bug.Fix
New module-level helper:
Applied in
compare_to_terminal(share_delta column) and insigned()(so the HTML share-delta and score-delta paths are both covered). Non-zero values are untouched, so no other output changes.After
Test
test_compare_does_not_render_negative_zero_share_delta- asserts-0.0 ppappears in neithercompare_to_terminalnorcompare_to_htmlfor a dimension whose group share moves by -0.0001.pytest tests/test_report.py tests/test_compare.py-> 39 passed.ruffclean.Closes #515
🤖 Generated with Claude Code