fix(histogram): SI prefix labels, step-based precision, correct percentage display#884
fix(histogram): SI prefix labels, step-based precision, correct percentage display#884paddymul wants to merge 2 commits into
Conversation
…ntage display
- Add fmt_num/fmt_bucket helpers to histogram.py: SI prefix (K/M/B/T)
for large values, step-based decimal precision (D3-style), no scientific
notation. Use <> separator when the high bound is negative to avoid the
ambiguous double-dash (-100--80).
- Apply fmt_bucket in xorq_stats_v2._numeric_histogram (was using .3g,
producing 1.99e+03 for year ranges etc.). Also fixes cat_pop → population
key so numeric histograms render as grey bars, not categorical pink.
- Apply fmt_bucket in histogram.py numeric_histogram_labels and tail labels
(was using fixed {:.0f} which dropped all decimal places for floats).
- Fix tooltip percentage in HistogramCell.tsx: value is a 0-1 fraction,
multiply by 100 and toFixed(1) before appending %. Was showing
0.10008342602028921023% instead of 10.0%.
- Update test_xorq_stats_v2 assertions from cat_pop to population key.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📦 TestPyPI package publishedpip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.14.10.dev26770660679or with uv: uv pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.14.10.dev26770660679MCP server for Claude Codeclaude mcp add buckaroo-table -- uvx --from "buckaroo[mcp]==0.14.10.dev26770660679" --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo-table📖 Docs preview🎨 Storybook preview |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a952fad694
ℹ️ 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".
| }} | ||
| > | ||
| <p className="label">{`${name} : ${payload[0].value}%`}</p> | ||
| <p className="label">{`${name} : ${(payload[0].value * 100).toFixed(1)}%`}</p> |
There was a problem hiding this comment.
Avoid re-scaling percent histogram values
When the tooltip is shown for the normal pandas/polars histogram paths, population/cat_pop values are already emitted as percent values (for example numeric_histogram stores np.round(pop * 100, 0), and the JS fixtures use values like 29.0). Multiplying every Recharts value by 100 here fixes the new xorq 0–1 numeric output but regresses existing histograms by displaying values such as 2900.0% instead of 29%; either keep a consistent unit upstream or only scale the 0–1 xorq values.
Useful? React with 👍 / 👎.
The JS tooltip was multiplying all values by 100 to fix xorq's 0-1 fractions, which doubled the pandas/polars values (already 0-100) to 2900% etc. Move the *100 to the Python side so all backends emit the same unit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Addressed the Codex inline comment (discussion_r3335904009) in 254743d. Root cause: pandas/polars already emit Fix: moved the |
Summary
0.10008342602028921023%(raw 0–1 fraction with%appended). Now multiplies by 100 and rounds to 1dp:10.0%..3gformat, producing1.99e+03–2e+03for year ranges,2.18e+03for prices, etc. Replaced withfmt_bucketfromhistogram.py.{:.0f}(always 0 decimal places), dropping all precision for float columns like carat. Also replaced withfmt_bucket.histogram.py): SI prefix (K/M/B/T) for values ≥ 1K; step-based decimal precision (D3-style: precision scales with bucket width, not absolute magnitude);<>separator when the high bound is negative to avoid the ambiguous double-dash (-100--80→-100<>-80); strips trailing decimal zeros.xorq_stats_v2._numeric_histogram: numeric histogram bars were keyed ascat_pop, causing the frontend to render them with the categorical pink style instead of grey. Fixed.Test plan
pytest tests/unit/test_xorq_stats_v2.py— updatedcat_pop→populationassertions, all passpytest tests/unit/(excluding unrelatedcontrib/file_cachecollection errors) — 1097 passed, 1 pre-existing unrelated failure10.0%style in browser0.3K–2.2Kstyle labels; year shows1.99K–2.02K; carat shows0.2–0.68🤖 Generated with Claude Code