Register weighted-microdata rules: weights aren't values
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 30/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 1
- Forks
- 1
- Merge medio
- 1 d 11 h
- PR fusionados (30 d)
- 50
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PolicyEngine/policyengine-sim-api
-
Integration tests fail due to missing UV virtual environment setupPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
PolicyEngine/policyengine-sim-api#314 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
PolicyEngine/policyengine-sim-api#814 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
PolicyEngine/policyengine-sim-api#805 ·
Los mantenedores suelen responder en 1 día
-
Refactor within ruff's complexity limits, then select every ruff rule (ALL)Posiblemente ocupada @anth-volk la tomó hace 1 día. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 15/100
PolicyEngine/policyengine-sim-api#803 ·
Los mantenedores suelen responder en 1 día
-
Enable ruff argument, idiom and pytest-style rules (ARG, B, C4, FBT, PERF, PLW, PT, PTH, RUF, SIM and others)Posiblemente ocupada @anth-volk la tomó hace 1 día. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
PolicyEngine/policyengine-sim-api#801 ·
Los mantenedores suelen responder en 1 día
Todos los issues de PolicyEngine/policyengine-sim-api
Issues similares
-
documentation good first issue
Dificultad 2/5 Medio día Aptitud para principiantes 72/100
sujithputta02/Esapay#13 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Flaky: credential-proxy admission metric test asserts a wall-clock bound it does not establishAbiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
gke-labs/kube-agents#3277 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
jbacalso24/mimry#291 ·
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 2/5 Menos de una hora Aptitud para principiantes 82/100
eli-alvarado/us-watchlist-alerts#14 ·
Los mantenedores suelen responder en 1 día