Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Keep the inputs a reform applied after the build stores through reset_calculations

Đang mở
#617 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PolicyEngine/policyengine-core

Tất cả issue của PolicyEngine/policyengine-core

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.