Avoid running apply_reform on every baseline Simulation.__init__ (unconditional mi_surtax & combined_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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Tái cấu trúc
- Độ 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
- performance
Hướng nghiên cứu
Start in policyengine_us/system.py at the Simulation.__init__ call to create_structural_reforms_from_parameters, then read policyengine_us/reforms/reforms.py around lines 754–761 and policyengine_us/reforms/states/mi/surtax.py. Compare the proposed baseline mi_surtax variable location under policyengine_us/variables/gov/states/mi/tax/income/ with mi_income_tax.adds. Done means a baseline Simulation with no gov.contrib structural reform returns no reform and skips apply_reform, while the Michigan surtax still respects gov.contrib.states.mi.surtax.in_effect.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Every Simulation(...) construction in policyengine_us currently runs self.apply_reform(reform) even when using the unmodified baseline system and no user-supplied reform. In a cProfile trace of a single-household simulation, apply_reform inside Simulation.__init__ accounts for ~29 ms per call (~18% of Simulation.__init__).
Root Cause
There are two pieces causing apply_reform to run unconditionally on every baseline Simulation:
-
mi_surtaxis unconditionally returned bycreate_structural_reforms_from_parameters(policyengine_us/reforms/states/mi/surtax.py):- Of the ~140 parameter-driven reforms checked in
create_structural_reforms_from_parameters,mi_surtaxis the only reform returned on the default baselinesystem.parameters. - Following #7377 (which moved the
in_effectcheck intomi_surtax.formula) and #10039 (which addedmi_surtaxto the baselinegov.states.household.state_income_tax_before_refundable_creditslist),create_mi_surtax_reformunconditionally returnscreate_mi_surtax()somi_surtaxexists in every system. - Because
mi_surtaxis already part of every baseline system and gates onparameters(period).gov.contrib.states.mi.surtax.in_effectat calculation time, wrapping it in aReformis no longer needed.
- Of the ~140 parameter-driven reforms checked in
-
create_structural_reforms_from_parametersnever returnsNone(policyengine_us/reforms/reforms.py, lines 754–761):Simulation.__init__(policyengine_us/system.py, lines 356–360) checks:reform = create_structural_reforms_from_parameters( self.tax_benefit_system.parameters, start_instant ) if reform is not None: self.apply_reform(reform)- However,
create_structural_reforms_from_parameterscurrently returnscombined_reformeven ifreformsis empty (()), soif reform is not None:would still evaluate toTrue.
Proposed Fix
- Integrate
mi_surtaxas a standard baseline variable underpolicyengine_us/variables/gov/states/mi/tax/income/(and include"mi_surtax"inmi_income_tax.adds), keeping the calculation-timegov.contrib.states.mi.surtax.in_effectcheck insidemi_surtax.formula(short-circuiting to0before evaluatingmi_taxable_income/tax_unit_is_jointwhenin_effectis false). Removemi_surtaxfromcreate_structural_reforms_from_parameters(keeping any backwards-compatible import alias if needed). - Return
Nonewhen no structural reform is active inpolicyengine_us/reforms/reforms.py:reforms = tuple(filter(lambda x: x is not None, reforms)) if not reforms: return None
Expected Impact
- Baseline
Simulation(...)calls skipself.apply_reform(reform)completely when nogov.contribstructural reform is active. - Exact calculation behavior is preserved for both
in_effect = False(baseline) andin_effect = True(parameter-toggled Michigan surtax).
- Ngôn ngữ chính
- Python
- Star
- 178
- Fork
- 224
- Merge trung bình
- 2 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 296
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-us
-
Secondary earnings threshold description names a stale 2035 capCó thể đã có người làm @Prabh022 đã nhận 1 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
PolicyEngine/policyengine-us#11252 ·
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-us#11201 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Idaho BBCE households without an elderly or disabled member should face the SNAP net income testCó thể đã có người làm @DTrim99 đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
PolicyEngine/policyengine-us#11199 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
California's Medi-Cal immigration test passes pregnant people but not those in the postpartum periodĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
PolicyEngine/policyengine-us#11192 ·
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 90/100
PolicyEngine/policyengine-us#11084 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của PolicyEngine/policyengine-us
Issue tương tự
-
S2-12 Atualizar README.mdĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
bug help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
cofade/open-garden-planner#1044 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
python-commandline-toolsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
codecrafters-io/build-your-own-x#2126 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
julianleno/cortai#10 ·
-
difficulty:easy func:python os:windows prio:high type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NatronGitHub/Natron#2029 ·
Maintainer thường phản hồi trong vòng 1 ngày