Register weighted-microdata rules: weights aren't values
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 30/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 1
- Forks
- 1
- Merge moyen
- 1 j 7 h
- PR mergées (30 j)
- 40
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de PolicyEngine/policyengine-sim-api
-
Integration tests fail due to missing UV virtual environment setupPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
PolicyEngine/policyengine-sim-api#314 ·
Les mainteneurs répondent en général sous 1 jour
-
Update policyengine to 6.4.3Peut-être pris @policyengine l’a pris aujourd’hui. Ouverte
Difficulté 1/5 1-3 heures Accessibilité débutants 35/100
PolicyEngine/policyengine-sim-api#812 ·
Les mainteneurs répondent en général sous 1 jour
-
Update policyengine to 6.4.2Peut-être pris @policyengine l’a pris aujourd’hui. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 40/100
PolicyEngine/policyengine-sim-api#810 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 25/100
PolicyEngine/policyengine-sim-api#805 ·
Les mainteneurs répondent en général sous 1 jour
-
Refactor within ruff's complexity limits, then select every ruff rule (ALL)Peut-être pris @anth-volk l’a pris il y a 1 jour. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 15/100
PolicyEngine/policyengine-sim-api#803 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de PolicyEngine/policyengine-sim-api
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
jbacalso24/mimry#291 ·
Les mainteneurs répondent en général sous 1 jour
-
good first issue
Difficulté 2/5 Moins d'une heure Accessibilité débutants 82/100
eli-alvarado/us-watchlist-alerts#14 ·
Les mainteneurs répondent en général sous 1 jour
-
from-review-extraction python severity:nit
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
LearningCircuit/local-deep-research#7462 ·
Les mainteneurs répondent en général sous 2 jours
-
mermaid_extract.py silently discards single-line state-diagram notes; sequence notes are keptOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
cathrynlavery/diagram-design#441 ·
Les mainteneurs répondent en général sous 2 jours
-
[Cleanup] Include the public header in work_split.cppPeut-être pris @blozano-tt l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
tenstorrent/tt-metal#60850 ·
Les mainteneurs répondent en général sous 1 jour