Register weighted-microdata rules: weights aren't values
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 1
- フォーク
- 1
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 40
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PolicyEngine/policyengine-sim-api のほかの issue
-
Integration tests fail due to missing UV virtual environment setup対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
PolicyEngine/policyengine-sim-api#314 ·
メンテナーはふだん 1 日以内に返信
-
Update policyengine to 6.4.3対応中かも @policyengine が今日担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 35/100
PolicyEngine/policyengine-sim-api#812 ·
メンテナーはふだん 1 日以内に返信
-
Update policyengine to 6.4.2対応中かも @policyengine が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 40/100
PolicyEngine/policyengine-sim-api#810 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
PolicyEngine/policyengine-sim-api#805 ·
メンテナーはふだん 1 日以内に返信
-
Refactor within ruff's complexity limits, then select every ruff rule (ALL)対応中かも @anth-volk が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
PolicyEngine/policyengine-sim-api#803 ·
メンテナーはふだん 1 日以内に返信
PolicyEngine/policyengine-sim-api の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
aws-samples/sample-per-model-bedrock#243 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
FuRongJun-1999/dsh-memory#404 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
PennyLaneAI/catalyst#3337 ·
メンテナーはふだん 1 日以内に返信
-
Workflow.schedule stops when a cron deadline passes before sleep対応中かも @HuaTNA が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信