A simulation built from a situation keeps the old system's defaults after apply_reform
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
- 57/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, backend-api-design
Hướng nghiên cứu
Start with SimulationBuilder, Simulation.apply_reform, and _invalidate_all_caches, then read the changes in #613 to understand _build_from_situation and skip_rejected_inputs. Reproduce the examples in the issue with the stated Python command, including a set_input call after construction. Done when applying a reform rebuilds situation inputs under the new system while preserving inputs added afterward, and the three salary calculations match the expected values.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
A simulation built from a situation keeps, after its system changes, the inputs the situation builder made under the old system. SimulationBuilder gives the people a situation gives no value for a variable it gives others (or sets along axes) that variable's default and stores the whole array as an input, so those people keep the old system's default. #612 is the same leak into a reform simulation's baseline; this is the other direction, into the reformed simulation.
Reproduced on master b909d5a60 (and on #613's branch, which does not change it), from the repository root with uv run --frozen --extra dev python:
import sys; sys.path.insert(0, ".")
from policyengine_core.country_template import CountryTaxBenefitSystem, Simulation
from tests.core.test_reform_baseline_system import change_salary_default # salary default 0 -> 1000
P = "2022-01"
sit = {"persons": {"a": {"salary": {P: 3000.0}}, "b": {}}, "households": {"h": {"parents": ["a", "b"]}}}
print(Simulation(situation=sit, reform=change_salary_default).calculate("salary", P)) # [3000. 1000.]
s = Simulation(situation=sit)
s.apply_reform(change_salary_default)
print(s.calculate("salary", P)) # [3000. 0.]: the reform's default is 1000
s2 = Simulation(tax_benefit_system=CountryTaxBenefitSystem(), situation=sit, reform=change_salary_default)
print(s2.calculate("salary", P)) # [3000. 0.]
apply_reformchanges the system in place, and_invalidate_all_cachesreplays every recorded input, including the arrays the builder filled with the old default.Simulation.__init__with bothtax_benefit_systemandreformbuilds the situation under the system it was given, then applies the reform to that system (apply_reform_set).
policyengine-us applies its structural reforms with apply_reform right after Simulation.__init__, so a structural reform that changes an input variable's default (or neutralizes one the situation gives) reaches its household simulations this way.
Expected
After its system changes, a simulation built from a situation holds what the builder makes of that situation under the new system, plus any inputs set on it afterwards.
Notes
#613 adds Simulation._build_from_situation and SimulationBuilder.skip_rejected_inputs, which build a situation into a simulation under its own system. Rebuilding on apply_reform also needs to keep the inputs set after construction (set_input calls, which _invalidate_all_caches replays today) apart from the builder's.
- Ngôn ngữ chính
- Python
- Star
- 22
- Fork
- 30
- Merge trung bình
- 2 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 25
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 33 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
-
A reform simulation's baseline reads the reform's default for people the situation gives no valueCó thể đã có người làm @MaxGhenis đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
PolicyEngine/policyengine-core#612 ·
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 35/100
PolicyEngine/policyengine-core#609 ·
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 78/100
aws-samples/sample-per-model-bedrock#191 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docs viewer: inverted grey colormap, Phantom CT window -20 to 35 HU, smoothing up to 40 mmCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởarea: docs enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
PyTomography/PyTomography#331 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
effort: low prio: low ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
digitalfabrik/integreat-cms#4616 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
FuRongJun-1999/dsh-memory#226 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug difficulty:2 good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
MakazhanAlpamys/Soup#1865 ·
Maintainer thường phản hồi trong vòng 1 ngày