Keep the inputs a reform applied after the build stores through reset_calculations
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start in core's Simulation.apply_reform and reset_calculations, then follow how input_variables is set at build time and how Holder._set stores values. Read the workaround in policyengine-uk's policyengine_uk/simulation.py to see which keys it logs. Done means a reform's stored inputs survive reset_calculations in core alone, with the override removed and test_reform_inputs_survive_reset.py passing.
索引モデルが issue の本文から書いたものです。
説明
A reform applied to a simulation after it is built (a Reform passed as reform=, or apply_reform on a built simulation, a clone or a branch) can store inputs with set_input. input_variables is taken when the simulation is built, and reset_calculations deletes the values of every variable it does not name, so a reset deletes what such a reform stored and recalculates the formula instead.
PolicyEngine/policyengine-uk#2075 works around this in policyengine_uk/simulation.py: while Simulation.apply_reform runs, _user_input_keys is replaced by a set subclass that logs each (variable, branch, period) key core adds, and afterwards apply_reform adds to input_variables every logged variable the simulation still holds under a branch it can see (_get_visible_branch_names). That relies on core internals: the name and shape of _user_input_keys, the fact that Holder._set adds a key on every storing route, and _get_visible_branch_names. The country package's tests fail if core changes them (the reform's inputs stop surviving a reset), but the logic belongs in core.
Proposal: core's Simulation.apply_reform records the input keys a reform stores and extends input_variables with them (with a new list, since a clone or branch shares its parent's), so every country package gets this, and policyengine-uk can drop its override. policyengine-uk's test_reform_inputs_survive_reset.py and test_a_reform_applied_later_keeps_what_it_sets_through_a_reset describe the expected behaviour, including inputs a reform replaces, values core does not store, nested reforms and a reform that raises.
Raised in Vahid Ahmadi's review of PolicyEngine/policyengine-uk#2075.
🤖 Generated with Claude Code
- 主要言語
- Python
- スター
- 22
- フォーク
- 30
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PolicyEngine/policyengine-core のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
PolicyEngine/policyengine-core#605 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
PolicyEngine/policyengine-core#549 ·
メンテナーはふだん 2 日以内に返信
-
`restore_simulation` silently drops memberless group entities対応中かも @Adelagric が 36 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
PolicyEngine/policyengine-core#547 ·
メンテナーはふだん 2 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
PolicyEngine/policyengine-core#621 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
PolicyEngine/policyengine-core#618 ·
メンテナーはふだん 2 日以内に返信
PolicyEngine/policyengine-core の issue をすべて見る
似ている issue
-
bot-triaged module: LrScheduler module: optimizer triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
documentation glm5 llm-model
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
vllm-project/vllm-ascend#19062 ·
メンテナーはふだん 1 日以内に返信
-
author-page correction
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
acl-org/acl-anthology#10496 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Issue Type: Bug Report
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
celery/celery#10875 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SasanLabs/VulnerableApp#836 ·
メンテナーはふだん 1 日以内に返信