A reform applied after holders exist leaves them on the old variable, so a variable's default depends on who else is in the simulation
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 simulations/simulation.py at apply_reform (around line 927) and _invalidate_all_caches, then populations/population.py at get_holder (around line 169) to see why existing holders keep their old variable. Compare the holder.default_array() path with the np.where(mask, array, variable.default_value) path in _calculate. Done means one reform gives the same result whether every row or only some rows fail defined_for, with a regression test added.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Simulation.apply_reform replaces variables on the tax-benefit system but leaves any holder that already exists pointing at the old variable. Holder.default_array() then returns the old default, while Simulation._calculate reads the new one, so one calculation can use both.
We traced this in policyengine-core 3.33.12 and confirmed the lines below at 3.34.1, in simulations/simulation.py unless noted:
apply_reform(line 927) runs the reform, then_invalidate_all_caches(line 940). That clears stored values and keeps eachHolder.variable.Population.get_holder(populations/population.py, line 169) returns an existing holder unchanged.- When every row fails
defined_for,_calculatereturnsholder.default_array()(line 1779), which reads the holder's old variable. - When only some rows fail,
_calculatereachesnp.where(mask, array, variable.default_value)(line 1933), which reads the system's new variable.
policyengine-uk exposes this because Simulation.get_known_variables creates a holder for every variable before its after-data reform runs.
Example
We ran policyengine-uk 2da212abc on Core 3.33.12 with a reform that gives pension_credit_entitlement a default of £2,000, applied after data load. A man aged 40 fails that variable's defined_for.
| Simulation | The man's pension_credit_entitlement |
|---|---|
| Alone, reform applied after data load | £0 |
| With two men aged 63, reform applied after data load | £2,000 |
| Alone, reform applied before data load | £2,000 |
Alone, reform applied after data load, then _bind_to_tax_benefit_system() |
£2,000 |
His result depends on who else the simulation holds, and the system's default reads £2,000 throughout.
What to change
- Rebind holders after a reform: have
apply_reformcall_bind_to_tax_benefit_system()(line 1307), or haveget_holderreplace a holder whose variable has left the system. - Add a test: apply a reform that changes a
defined_forvariable's default after a holder exists, and assert one result for a population where every row fails and for a population where some do.
Related: #612, #632.
🤖 Generated with Claude Code
- Ngôn ngữ chính
- Python
- Star
- 22
- Fork
- 30
- Merge trung bình
- 4 ngày 20 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 55 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
-
Parameter loader turns __pycache__ directories into parameter nodesCó thể đã có người làm @anth-volk đã nhận 6 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
PolicyEngine/policyengine-core#638 ·
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 45/100
PolicyEngine/policyengine-core#636 ·
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ự
-
needs-area-label
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Official-Space-AI/OpenPhysGraspGen#114 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
changelog investigate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ramnes/notion-sdk-py#441 ·
-
qa_bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NVIDIA-NeMo/Gym#5644 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
BUG: catalog database credentials printed to logs at startupCó thể đã có người làm @cjboyle đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày