Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

budget.households is the sum of squared household weights

Cerrado
#766 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@PavelMakarchuk ya está trabajando en esto.

Desde el 12/10/2026.

  • #767 de @PavelMakarchuk — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
20/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

Start in simulation_output_budget.build_budgetary_impact and inspect how _sum_output_variable handles the household MicroDataFrame and its household_weight column. The existing test test_builder_budgetary_impact_uses_materialized_columns_and_uk_state_tax_zero uses plain DataFrames; add coverage with a real MicroDataFrame and verify the household count is 3 for weights [1, 2]. An open linked pull request (#767) is already addressing this issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Problem

The economy comparison's budget.households is the sum of squared household weights, not the household count. It is about 10⁴ times too high on every run, national and state:

Run (/us/economy/{reform}/over/2) budget.households Actual households
region=state/ny, 2026 135,597,233,840 ~7.5 million
region=state/ca, 2026 197,620,236,261 ~13.5 million
region=state/va, 2027 44,192,009,994 ~3.3 million

Cause

simulation_output_budget.build_budgetary_impact sets households=_sum_output_variable(baseline, "household_weight", entity="household").

_sum_output_variable returns float(data[variable].sum()). Here data is the household MicroDataFrame, which policyengine weights by household_weight. So data["household_weight"] is a weighted MicroSeries, and its .sum() is Σ w × w.

Weights [1, 2] give 5.0 instead of 3.0. The existing test (test_builder_budgetary_impact_uses_materialized_columns_and_uk_state_tax_zero) uses plain pd.DataFrames, so it never caught this.

This came in with 36d3be0 ("adapt simulation worker to PolicyEngine v4 outputs").

The other budget fields are correct. They are meant to be weighted sums.

Impact

Clients divide by this field. For example, policyengine-app-v2 computes the headline average change per household as -budget.budgetary_impact / budget.households. That number is therefore about 10⁴ times too small on every report.

Fix

Count entities with a plain sum of their weight column, and test it on a real MicroDataFrame.

Lenguaje dominante
Python
Estrellas
1
Forks
1
Merge medio
1 d 4 h
PR fusionados (30 d)
27

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PolicyEngine/policyengine-sim-api

Todos los issues de PolicyEngine/policyengine-sim-api

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.