Register weighted-microdata rules: weights aren't values
Maintainer antworten meist innerhalb von 1 Tag
Ein zugehöriger Pull Request wurde bereits gemerged.
- #807 von @anth-volk — gemerged
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 30/100
Rechercherichtung
Start with rules/registry.toml to see how existing rules and their AST guards and proofs are declared, then read simulation_output_common.py, where raw values are read from weighted frames. The output-builder tests that currently use plain pd.DataFrames are the other place to look. Done means the four named rules are registered with guards and proofs, the confined-read exception list is in place, and the builder tests use one shared weighted factory.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Problem
The executor's entity frames are microdf MicroDataFrames weighted by <entity>_weight, so .sum(), .mean() and .count() on any column are already weighted.
In #766 (fixed by #767), build_budgetary_impact passed "household_weight" to _sum_output_variable, the helper it uses for ordinary values. That weighted the weight column by itself, giving the sum of squared weights.
- Effect:
budget.householdswas about 10^4 times too high on every run (New York 2026: 135.6 billion, against about 7.5 million households). Clients divide by it, so the average change per household was about 10^4 times too small. - Why it escaped: the builder test used plain
pd.DataFrames, which carry no weights.
Nothing stops the same class of mistake from coming back.
Proposal
Phase 1 step 1.9. Register the rule that weights aren't values in rules/registry.toml, with AST guards and proofs:
sim.microdata.weights-not-values(doc-only): weights, values, labels and counts each allow different operations.sim.microdata.weights-not-aggregated-as-values: a weight is never the variable of a weighted aggregator, and neverframe[<weight>]followed by a weighted reduction.sim.microdata.weight-stripping-confined: raw values are read from a weighted frame only insimulation_output_common.py.- Counting entities is always allowed there.
- Any other read there is a recorded exception, in a list that may only shrink.
sim.microdata.builder-tests-use-weighted-frames: output-builder tests build entity frames through one shared weighted factory, never as plainpd.DataFrames.
Alongside, two cheap runtime checks that the AST guards can't replace:
- change totals (reform minus baseline) log a warning when the two sides carry different weights;
- an implausible published household count fails the run.
Decisions
- UK local-authority handoff. The breakdown hands policyengine's longwise geography impact a plain household frame, and that function weights by
household_weightitself. The handoff moves intosimulation_output_common.pyas the stripping rule's one recorded exception. Removing it is tracked separately. - Weight mismatch: warn first. It logs a warning and still publishes the total. It becomes an error once logs show that no legitimate run produces a mismatch.
- Household count: fail the run. A failed run is better than a headline that's 10^4 times wrong.
- Vorherrschende Sprache
- Python
- Sterne
- 1
- Forks
- 1
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 77
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus PolicyEngine/policyengine-sim-api
-
Accept the withheld-area code lists on UK local-area breakdown results before any executor sends themEvtl. vergeben @anth-volk hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
PolicyEngine/policyengine-sim-api#977 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Update policyengine to 6.11.1Evtl. vergeben @policyengine hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 68/100
PolicyEngine/policyengine-sim-api#916 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Update policyengine to 6.7.3Evtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 70/100
PolicyEngine/policyengine-sim-api#823 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Integration tests fail due to missing UV virtual environment setupEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
PolicyEngine/policyengine-sim-api#314 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Move the changelog to Towncrier fragments and build CHANGELOG.md at each deployEvtl. vergeben @anth-volk hat das vor 1 Tag übernommen. Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
PolicyEngine/policyengine-sim-api#978 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in PolicyEngine/policyengine-sim-api
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
ComposioHQ/awesome-claude-skills#2398 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bug converter
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
grafana/sigma-rule-deployment#435 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
datamodel-code-generator/datamodel-code-generator#5589 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Shell: serve the home app's Cookie Policy on a hard reloadEvtl. vergeben @2001anshkaushik hat das heute übernommen. Offenfeature module:ai
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
rocketride-org/rocketride-server#2899 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
GEFSv12
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100