Skip to content

Format rate-type validation rows as percentages - #96

Closed
DTrim99 wants to merge 1 commit into
PolicyEngine:mainfrom
DTrim99:unit-aware-level-formatting
Closed

Format rate-type validation rows as percentages#96
DTrim99 wants to merge 1 commit into
PolicyEngine:mainfrom
DTrim99:unit-aware-level-formatting

Conversation

@DTrim99

@DTrim99 DTrim99 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Companion to populace#348, which adds 104 Census state SPM poverty-rate backtests (out-of-sample) to the reform-validation payload. Those level rows carry unit: "percent" with decimal-fraction values (0.134), which the current views would render as $0.13.

  • Thread unit through the payload parser (lib/populace/reforms.ts) and both row interfaces.
  • New shared fmtUnitValue in components/shared/format.ts: "percent"13.4%, anything else → fmtMoney as before.
  • Applied to the Benchmark/populace value cells in the reforms view and the staging view.
  • Backward compatible: rows without unit (all existing payloads) render exactly as today. Error/trend columns are relative and unaffected.

Typecheck (npm run lint) and next build pass.

Motivation: the populace-vs-ECPS parity finding showed state poverty levels diverging up to 11.7pp with nothing on the dashboard to catch it — these rows put per-state poverty error on the board for every release.

🤖 Generated with Claude Code

Populace PR #348 adds Census state SPM poverty-rate backtests whose level
rows carry unit: "percent" with decimal-fraction values. Thread the unit
through the payload parser and row types, and format value cells with a
shared fmtUnitValue (0.134 -> "13.4%") in the reforms and staging views.
Rows without a unit keep the USD formatting, so pre-#348 payloads render
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Jul 23, 2026
…111)

* Format rate-type validation rows as percentages

Populace PR #348 adds Census state SPM poverty-rate backtests whose level
rows carry unit: "percent" with decimal-fraction values. Thread the unit
through the payload parser and row types, and format value cells with a
shared fmtUnitValue (0.134 -> "13.4%") in the reforms and staging views.
Rows without a unit keep the USD formatting, so pre-#348 payloads render
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Consolidate percent-unit cell formatting into shared fmtUnitValue

The reforms view (via #108) and staging view (via this branch) had two
identical local implementations of the same unit dispatch; keep the one
shared helper in components/shared/format.ts and add unit tests for it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: David Trimmer <david@policyengine.org>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@MaxGhenis

Copy link
Copy Markdown
Contributor

Thanks @DTrim99 — this landed in two pieces while you were out: #108 independently shipped the parser/type changes and reforms-view rendering earlier today, and #111 (merged) cherry-picked your commit for the remaining half — the shared fmtUnitValue helper and the staging-view cells — with your authorship preserved, then consolidated the reforms view onto your shared helper. Main now renders percent-unit rate rows correctly in both views. Closing as superseded by #108 + #111.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants