Keep the inputs a reform applied after the build stores through reset_calculations
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 22
- Fork
- 30
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 26
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PolicyEngine/policyengine-core
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
PolicyEngine/policyengine-core#605 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
PolicyEngine/policyengine-core#549 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`restore_simulation` silently drops memberless group entitiesCó thể đã có người làm @Adelagric đã nhận 36 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
PolicyEngine/policyengine-core#547 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 8/100
PolicyEngine/policyengine-core#621 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
PolicyEngine/policyengine-core#618 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của PolicyEngine/policyengine-core
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
UKGovernmentBEIS/control-arena#917 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
debpalash/VoiceStudio#2937 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws-samples/sample-per-model-bedrock#261 ·
Maintainer thường phản hồi trong vòng 1 ngày