diff --git a/changelog.d/fix-reform-build-failures.changed.md b/changelog.d/fix-reform-build-failures.changed.md new file mode 100644 index 00000000000..15b8680b277 --- /dev/null +++ b/changelog.d/fix-reform-build-failures.changed.md @@ -0,0 +1 @@ +Set the default calculation and input year of `Simulation` to 2026, keep `Microsimulation` on its dataset's base year, and check structural reforms from 2024 through 2033 by default. diff --git a/changelog.d/fix-reform-build-failures.fixed.md b/changelog.d/fix-reform-build-failures.fixed.md new file mode 100644 index 00000000000..c029285a75a --- /dev/null +++ b/changelog.d/fix-reform-build-failures.fixed.md @@ -0,0 +1 @@ +Fix state EITC and Utah HB210 Substitute 2 structural reforms that failed to build in a Simulation. diff --git a/docs/usage/microsimulation.md b/docs/usage/microsimulation.md index 558b0d467f8..c2b8c71ae9b 100644 --- a/docs/usage/microsimulation.md +++ b/docs/usage/microsimulation.md @@ -98,7 +98,7 @@ Known limitations, which callers avoid by supplying `marital_units`: formulas run again in any year without a role input. So a calculation for another year can give roles the units don't match. For example, a grandchild's undated `is_tax_unit_spouse: false` lands in the default input - year (2024), so the grandparents get their own units, while a 2026 + year (2026), so the grandparents get their own units, while a 2025 calculation still makes them head and spouse. These rules apply to Python household simulations and entity-form YAML tests, diff --git a/docs/usage/structural_reform_dating.ipynb b/docs/usage/structural_reform_dating.ipynb index 7889ada554e..379c1ebb0aa 100644 --- a/docs/usage/structural_reform_dating.ipynb +++ b/docs/usage/structural_reform_dating.ipynb @@ -8,7 +8,7 @@ "\n", "\"Structural\" reforms are those reforms that modify not only set values in the tax-benefit system, but also the formulas used to calculate taxes and benefits. These are typcially larger, more involved reforms that require custom coding.\n", "\n", - "Due to the current limitations of the `Microsimulation` class, a code patch is required when running structural reforms with parameters that begin at any date other than January 1st of the current year. \n", + "Most structural reforms are found by checking their parameters on January 1 of ten consecutive years from `start_instant`, which defaults to January 1, 2024. Some reforms check only `start_instant` itself. A code patch is required when a reform's parameters begin outside the dates it checks. \n", "\n", "For example, the code cell below illustrates a standard way to instantiating a structural reform, without the patch, when simulating in 2024:" ] @@ -69,7 +69,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The cell below shows a series of reforms that begin in 2026, later than the current year. To effectively handle this case, we need to add an argument to the `Microsimulation` classes that we call. \n", + "The cell below shows a series of reforms that begin in 2026. To start the check on that date, which reforms that check a single date require, we add an argument to the `Microsimulation` classes that we call. \n", "\n", "This argument, called `start_instant`, should be set to the same date as the start of the reforms, in ISO date format. In the case of the example below, this is `2026-01-01`, so our altered call to `Microsimulation` looks like:\n", "\n", diff --git a/policyengine_us/data/dataset_schema.py b/policyengine_us/data/dataset_schema.py index d3f2ac2e1b3..c65709b047d 100644 --- a/policyengine_us/data/dataset_schema.py +++ b/policyengine_us/data/dataset_schema.py @@ -15,7 +15,7 @@ # spm_unit, family, marital_unit are optional and default to empty. _REQUIRED_ENTITIES = ("person", "household", "tax_unit") -# Sync with CURRENT_YEAR in system.py +# The default dataset's base year, which does not follow CURRENT_YEAR. _DEFAULT_TIME_PERIOD = 2024 diff --git a/policyengine_us/model_api.py b/policyengine_us/model_api.py index 5bcf5df7f0c..f09e855802e 100644 --- a/policyengine_us/model_api.py +++ b/policyengine_us/model_api.py @@ -5,6 +5,7 @@ from policyengine_core.model_api import * from policyengine_us.entities import * from policyengine_us.tools.general import * +from policyengine_us.tools.parameters import STRUCTURAL_REFORM_CHECK_YEARS from pathlib import Path from policyengine_us.typing import * import warnings diff --git a/policyengine_us/reforms/aca/aca_ptc_700_fpl_cliff.py b/policyengine_us/reforms/aca/aca_ptc_700_fpl_cliff.py index 38002e777ac..b7de5621884 100644 --- a/policyengine_us/reforms/aca/aca_ptc_700_fpl_cliff.py +++ b/policyengine_us/reforms/aca/aca_ptc_700_fpl_cliff.py @@ -92,9 +92,9 @@ def create_aca_ptc_700_fpl_cliff_reform(parameters, period, bypass: bool = False p = parameters.gov.contrib.aca.ptc_700_fpl_cliff current_period = period_(period) - # Check if reform is active within a 5-year lookahead window + # Check if reform is active within the lookahead window reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/aca/aca_ptc_additional_bracket.py b/policyengine_us/reforms/aca/aca_ptc_additional_bracket.py index 6eed748d546..a21da87dce9 100644 --- a/policyengine_us/reforms/aca/aca_ptc_additional_bracket.py +++ b/policyengine_us/reforms/aca/aca_ptc_additional_bracket.py @@ -89,11 +89,11 @@ def create_aca_ptc_additional_bracket_reform(parameters, period, bypass: bool = p = parameters.gov.contrib.aca.ptc_additional_bracket current_period = period_(period) - # Check if reform is active within a 5-year lookahead window + # Check if reform is active within the lookahead window # This allows the reform to be selected in the web app interface # even if it's scheduled to start in a future year reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/aca/aca_ptc_minimum_premium.py b/policyengine_us/reforms/aca/aca_ptc_minimum_premium.py index 0680b90de6e..64fa285318a 100644 --- a/policyengine_us/reforms/aca/aca_ptc_minimum_premium.py +++ b/policyengine_us/reforms/aca/aca_ptc_minimum_premium.py @@ -118,9 +118,9 @@ def create_aca_ptc_minimum_premium_reform(parameters, period, bypass: bool = Fal p = parameters.gov.contrib.aca.minimum_premium current_period = period_(period) - # Check if reform is active within a 5-year lookahead window + # Check if reform is active within the lookahead window reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/aca/aca_ptc_simplified_bracket.py b/policyengine_us/reforms/aca/aca_ptc_simplified_bracket.py index 8a35a350349..a0821cdcc08 100644 --- a/policyengine_us/reforms/aca/aca_ptc_simplified_bracket.py +++ b/policyengine_us/reforms/aca/aca_ptc_simplified_bracket.py @@ -90,11 +90,11 @@ def create_aca_ptc_simplified_bracket_reform(parameters, period, bypass: bool = p = parameters.gov.contrib.aca.ptc_simplified_bracket current_period = period_(period) - # Check if reform is active within a 5-year lookahead window + # Check if reform is active within the lookahead window # This allows the reform to be selected in the web app interface # even if it's scheduled to start in a future year reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/additional_tax_bracket/additional_tax_bracket_reform.py b/policyengine_us/reforms/additional_tax_bracket/additional_tax_bracket_reform.py index 8cd60d4f0ee..b6d6c267213 100644 --- a/policyengine_us/reforms/additional_tax_bracket/additional_tax_bracket_reform.py +++ b/policyengine_us/reforms/additional_tax_bracket/additional_tax_bracket_reform.py @@ -101,7 +101,7 @@ def create_additional_tax_bracket_reform(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/cdcc/cdcc_single_parent_work_requirement.py b/policyengine_us/reforms/cdcc/cdcc_single_parent_work_requirement.py index a84182005de..0dd0e2ffe2b 100644 --- a/policyengine_us/reforms/cdcc/cdcc_single_parent_work_requirement.py +++ b/policyengine_us/reforms/cdcc/cdcc_single_parent_work_requirement.py @@ -60,11 +60,11 @@ def create_cdcc_single_parent_work_requirement_reform( p = parameters.gov.contrib.cdcc.single_parent_work_requirement - # Check if reform is active in current period or next 5 years + # Check if reform is active in the lookahead window reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/congress/afa/afa_other_dependent_credit.py b/policyengine_us/reforms/congress/afa/afa_other_dependent_credit.py index fcc0247149b..701440c5fc9 100644 --- a/policyengine_us/reforms/congress/afa/afa_other_dependent_credit.py +++ b/policyengine_us/reforms/congress/afa/afa_other_dependent_credit.py @@ -302,7 +302,7 @@ def create_afa_other_dependent_credit_reform(parameters, period, bypass: bool = reform_active = False current_period = period_(period) - for i in range(10): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p.in_effect(current_period): reform_active = True break diff --git a/policyengine_us/reforms/congress/delauro/american_family_act.py b/policyengine_us/reforms/congress/delauro/american_family_act.py index 33be681195f..4b2c11f6bab 100644 --- a/policyengine_us/reforms/congress/delauro/american_family_act.py +++ b/policyengine_us/reforms/congress/delauro/american_family_act.py @@ -43,7 +43,7 @@ def create_american_family_act_with_baby_bonus_reform( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).baby_bonus > 0: reform_active = True break diff --git a/policyengine_us/reforms/congress/golden/fisc_act.py b/policyengine_us/reforms/congress/golden/fisc_act.py index d2115faa88c..74071233e88 100644 --- a/policyengine_us/reforms/congress/golden/fisc_act.py +++ b/policyengine_us/reforms/congress/golden/fisc_act.py @@ -96,7 +96,7 @@ def create_fisc_act_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/congress/hawley/awra/american_worker_rebate_act.py b/policyengine_us/reforms/congress/hawley/awra/american_worker_rebate_act.py index 691268a715d..6eef96777a6 100644 --- a/policyengine_us/reforms/congress/hawley/awra/american_worker_rebate_act.py +++ b/policyengine_us/reforms/congress/hawley/awra/american_worker_rebate_act.py @@ -128,7 +128,7 @@ def create_american_worker_rebate_act_reform(parameters, period, bypass: bool = reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/congress/mcdonald_rivet/working_parents_tax_relief_act/working_parents_tax_relief_act.py b/policyengine_us/reforms/congress/mcdonald_rivet/working_parents_tax_relief_act/working_parents_tax_relief_act.py index 8b9414a00ba..52cda5ccbb4 100644 --- a/policyengine_us/reforms/congress/mcdonald_rivet/working_parents_tax_relief_act/working_parents_tax_relief_act.py +++ b/policyengine_us/reforms/congress/mcdonald_rivet/working_parents_tax_relief_act/working_parents_tax_relief_act.py @@ -132,7 +132,7 @@ def create_working_parents_tax_relief_act_reform( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/congress/romney/family_security_act/remove_head_of_household.py b/policyengine_us/reforms/congress/romney/family_security_act/remove_head_of_household.py index 23927edabd6..3b901edf8bc 100644 --- a/policyengine_us/reforms/congress/romney/family_security_act/remove_head_of_household.py +++ b/policyengine_us/reforms/congress/romney/family_security_act/remove_head_of_household.py @@ -14,12 +14,12 @@ def create_remove_head_of_household_reform(parameters, period, bypass: bool = Fa if bypass: return create_remove_head_of_household() - # Look ahead for the next five years + # Check each year of the lookahead window p = parameters.gov.contrib.congress.romney.family_security_act reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).remove_head_of_household: reform_active = True break diff --git a/policyengine_us/reforms/congress/romney/family_security_act_2024/ctc/family_security_act_2024_ctc.py b/policyengine_us/reforms/congress/romney/family_security_act_2024/ctc/family_security_act_2024_ctc.py index e4befb61ce5..853bc02fed9 100644 --- a/policyengine_us/reforms/congress/romney/family_security_act_2024/ctc/family_security_act_2024_ctc.py +++ b/policyengine_us/reforms/congress/romney/family_security_act_2024/ctc/family_security_act_2024_ctc.py @@ -138,12 +138,12 @@ def create_family_security_act_2024_ctc_reform( if bypass: return create_family_security_act_2024_ctc() - # Look ahead for the next five years + # Check each year of the lookahead window p = parameters.gov.contrib.congress.romney.family_security_act_2_0.ctc reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).apply_ctc_structure: reform_active = True break diff --git a/policyengine_us/reforms/congress/romney/family_security_act_2024/eitc/family_security_act_2024_eitc.py b/policyengine_us/reforms/congress/romney/family_security_act_2024/eitc/family_security_act_2024_eitc.py index 3e821a82f8b..d1b52f10edb 100644 --- a/policyengine_us/reforms/congress/romney/family_security_act_2024/eitc/family_security_act_2024_eitc.py +++ b/policyengine_us/reforms/congress/romney/family_security_act_2024/eitc/family_security_act_2024_eitc.py @@ -33,12 +33,12 @@ def create_family_security_act_2024_eitc_reform( if bypass: return create_family_security_act_2024_eitc() - # Look ahead for the next five years + # Check each year of the lookahead window p = parameters.gov.contrib.congress.romney.family_security_act_2_0.eitc reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).apply_eitc_structure: reform_active = True break diff --git a/policyengine_us/reforms/congress/tlaib/economic_dignity_for_all_agenda/edaa_end_child_poverty_act.py b/policyengine_us/reforms/congress/tlaib/economic_dignity_for_all_agenda/edaa_end_child_poverty_act.py index bbaf2632ee0..314b07e6203 100644 --- a/policyengine_us/reforms/congress/tlaib/economic_dignity_for_all_agenda/edaa_end_child_poverty_act.py +++ b/policyengine_us/reforms/congress/tlaib/economic_dignity_for_all_agenda/edaa_end_child_poverty_act.py @@ -231,7 +231,7 @@ def create_end_child_poverty_act_reform(parameters, period, bypass: bool = False reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).end_child_poverty_act.in_effect: reform_active = True break diff --git a/policyengine_us/reforms/congress/watca/working_americans_tax_cut_act.py b/policyengine_us/reforms/congress/watca/working_americans_tax_cut_act.py index 27becb3a73f..3739a642ca6 100644 --- a/policyengine_us/reforms/congress/watca/working_americans_tax_cut_act.py +++ b/policyengine_us/reforms/congress/watca/working_americans_tax_cut_act.py @@ -176,7 +176,7 @@ def create_watca_reform(parameters, period, bypass: bool = False): current_period = period_(period) reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if parameter(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/congress/wyden_smith/ctc_expansion.py b/policyengine_us/reforms/congress/wyden_smith/ctc_expansion.py index 59953499494..ab4b4c345f9 100644 --- a/policyengine_us/reforms/congress/wyden_smith/ctc_expansion.py +++ b/policyengine_us/reforms/congress/wyden_smith/ctc_expansion.py @@ -93,14 +93,14 @@ def create_ctc_expansion_reform(parameters, period, bypass: bool = False): if bypass: return create_ctc_expansion() - # Look ahead for the next five years + # Check each year of the lookahead window p = parameters.gov.contrib.congress.wyden_smith reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).actc_lookback or p(current_period).per_child_actc_phase_in: reform_active = True break diff --git a/policyengine_us/reforms/crfb/agi_surtax.py b/policyengine_us/reforms/crfb/agi_surtax.py index f10e1f63f72..46681d4a988 100644 --- a/policyengine_us/reforms/crfb/agi_surtax.py +++ b/policyengine_us/reforms/crfb/agi_surtax.py @@ -65,9 +65,9 @@ def create_agi_surtax_reform(parameters, period, bypass: bool = False): current_period = period_(period) reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if parameter(current_period).in_effect: - # If in any of the next five years, the boolean is true, + # If in any year of the lookahead window, the boolean is true, # set the boolean reform_active to true, and stop the check, # i.e., assume the reform is active in all subsequent years. reform_active = True diff --git a/policyengine_us/reforms/crfb/non_refundable_ss_credit.py b/policyengine_us/reforms/crfb/non_refundable_ss_credit.py index 8977c44c42a..1455c7d4ef5 100644 --- a/policyengine_us/reforms/crfb/non_refundable_ss_credit.py +++ b/policyengine_us/reforms/crfb/non_refundable_ss_credit.py @@ -143,9 +143,9 @@ def create_non_refundable_ss_credit_reform(parameters, period, bypass: bool = Fa current_period = period_(period) reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if parameter(current_period).in_effect: - # If in any of the next five years, the boolean is true, + # If in any year of the lookahead window, the boolean is true, # set the boolean reform_active to true, and stop the check, # i.e., assume the reform is active in all subsequent years. reform_active = True diff --git a/policyengine_us/reforms/crfb/senior_deduction_extension.py b/policyengine_us/reforms/crfb/senior_deduction_extension.py index 4a607773150..389c2df384d 100644 --- a/policyengine_us/reforms/crfb/senior_deduction_extension.py +++ b/policyengine_us/reforms/crfb/senior_deduction_extension.py @@ -50,7 +50,7 @@ def create_senior_deduction_extension_reform(parameters, period, bypass: bool = reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).applies: reform_active = True break diff --git a/policyengine_us/reforms/crfb/tax_employer_medicare_tax.py b/policyengine_us/reforms/crfb/tax_employer_medicare_tax.py index 599adf29ef2..a288339e939 100644 --- a/policyengine_us/reforms/crfb/tax_employer_medicare_tax.py +++ b/policyengine_us/reforms/crfb/tax_employer_medicare_tax.py @@ -83,9 +83,9 @@ def create_tax_employer_medicare_tax_reform(parameters, period, bypass: bool = F current_period = period_(period) reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if parameter(current_period).in_effect: - # If in any of the next five years, the boolean is true, + # If in any year of the lookahead window, the boolean is true, # set the boolean reform_active to true, and stop the check, # i.e., assume the reform is active in all subsequent years. reform_active = True diff --git a/policyengine_us/reforms/crfb/tax_employer_payroll_tax.py b/policyengine_us/reforms/crfb/tax_employer_payroll_tax.py index febe0411f6f..26b15daf755 100644 --- a/policyengine_us/reforms/crfb/tax_employer_payroll_tax.py +++ b/policyengine_us/reforms/crfb/tax_employer_payroll_tax.py @@ -94,9 +94,9 @@ def create_tax_employer_payroll_tax_reform(parameters, period, bypass: bool = Fa current_period = period_(period) reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if parameter(current_period).in_effect: - # If in any of the next five years, the boolean is true, + # If in any year of the lookahead window, the boolean is true, # set the boolean reform_active to true, and stop the check, # i.e., assume the reform is active in all subsequent years. reform_active = True diff --git a/policyengine_us/reforms/crfb/tax_employer_social_security_tax.py b/policyengine_us/reforms/crfb/tax_employer_social_security_tax.py index ae7730c7782..87f5915954d 100644 --- a/policyengine_us/reforms/crfb/tax_employer_social_security_tax.py +++ b/policyengine_us/reforms/crfb/tax_employer_social_security_tax.py @@ -85,9 +85,9 @@ def create_tax_employer_social_security_tax_reform( current_period = period_(period) reform_active = False - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if parameter(current_period).in_effect: - # If in any of the next five years, the boolean is true, + # If in any year of the lookahead window, the boolean is true, # set the boolean reform_active to true, and stop the check, # i.e., assume the reform is active in all subsequent years. reform_active = True diff --git a/policyengine_us/reforms/ctc/ctc_additional_bracket.py b/policyengine_us/reforms/ctc/ctc_additional_bracket.py index 660a5d46fe8..7a3ce50e885 100644 --- a/policyengine_us/reforms/ctc/ctc_additional_bracket.py +++ b/policyengine_us/reforms/ctc/ctc_additional_bracket.py @@ -56,7 +56,7 @@ def create_ctc_additional_bracket_reform(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/ctc/ctc_linear_phase_out.py b/policyengine_us/reforms/ctc/ctc_linear_phase_out.py index 903b303526f..ff36c654482 100644 --- a/policyengine_us/reforms/ctc/ctc_linear_phase_out.py +++ b/policyengine_us/reforms/ctc/ctc_linear_phase_out.py @@ -69,7 +69,7 @@ def create_ctc_linear_phase_out_reform(parameters, period, bypass: bool = False) reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/ctc/ctc_minimum_refundable_amount.py b/policyengine_us/reforms/ctc/ctc_minimum_refundable_amount.py index 7e10bd4938c..c421d01ec2b 100644 --- a/policyengine_us/reforms/ctc/ctc_minimum_refundable_amount.py +++ b/policyengine_us/reforms/ctc/ctc_minimum_refundable_amount.py @@ -118,7 +118,7 @@ def create_ctc_minimum_refundable_amount_reform( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/ctc/ctc_per_child_phase_in.py b/policyengine_us/reforms/ctc/ctc_per_child_phase_in.py index 495483ae7c5..f61e8be3e3e 100644 --- a/policyengine_us/reforms/ctc/ctc_per_child_phase_in.py +++ b/policyengine_us/reforms/ctc/ctc_per_child_phase_in.py @@ -38,7 +38,7 @@ def create_ctc_per_child_phase_in_reform(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/ctc/ctc_per_child_phase_out.py b/policyengine_us/reforms/ctc/ctc_per_child_phase_out.py index 3a87e3ba5b6..bdbf6eb69a7 100644 --- a/policyengine_us/reforms/ctc/ctc_per_child_phase_out.py +++ b/policyengine_us/reforms/ctc/ctc_per_child_phase_out.py @@ -102,7 +102,7 @@ def create_ctc_per_child_phase_out_reform(parameters, period, bypass: bool = Fal reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/deductions/salt/limit_salt_deduction_to_property_taxes.py b/policyengine_us/reforms/deductions/salt/limit_salt_deduction_to_property_taxes.py index 3b05c1af3e6..b9042eafcfa 100644 --- a/policyengine_us/reforms/deductions/salt/limit_salt_deduction_to_property_taxes.py +++ b/policyengine_us/reforms/deductions/salt/limit_salt_deduction_to_property_taxes.py @@ -30,7 +30,7 @@ def create_limit_salt_deduction_to_property_taxes_reform( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).limit_salt_deduction_to_property_taxes: reform_active = True break diff --git a/policyengine_us/reforms/eitc/streamlined_eitc.py b/policyengine_us/reforms/eitc/streamlined_eitc.py index bd23a7d9ec3..f54a8f971c8 100644 --- a/policyengine_us/reforms/eitc/streamlined_eitc.py +++ b/policyengine_us/reforms/eitc/streamlined_eitc.py @@ -54,7 +54,7 @@ def create_streamlined_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/local/ny/mamdani_income_tax.py b/policyengine_us/reforms/local/ny/mamdani_income_tax.py index 5520582d75f..7974cd7579e 100644 --- a/policyengine_us/reforms/local/ny/mamdani_income_tax.py +++ b/policyengine_us/reforms/local/ny/mamdani_income_tax.py @@ -16,7 +16,7 @@ def formula(tax_unit, period, parameters): taxable_income = tax_unit("nyc_taxable_income", period) p = parameters(period).gov.local.ny.mamdani_income_tax # The factory installs the reform for the whole simulation when - # in_effect is true on January 1 of any of the five years from the + # in_effect is true on January 1 of any year checked from the # simulation's start instant, so gate each period on its own # in_effect value. return where(p.in_effect, p.rate.calc(taxable_income), 0) @@ -70,7 +70,7 @@ def create_nyc_mamdani_income_tax_reform(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/local/nyc/stc/phase_out/nyc_school_tax_credit_with_phase_out.py b/policyengine_us/reforms/local/nyc/stc/phase_out/nyc_school_tax_credit_with_phase_out.py index 0ddd5500ed9..28fd8e5ed7c 100644 --- a/policyengine_us/reforms/local/nyc/stc/phase_out/nyc_school_tax_credit_with_phase_out.py +++ b/policyengine_us/reforms/local/nyc/stc/phase_out/nyc_school_tax_credit_with_phase_out.py @@ -67,7 +67,7 @@ def create_nyc_school_tax_credit_with_phase_out_reform( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/reconciliation/reconciled_ssn_for_llc_and_aoc.py b/policyengine_us/reforms/reconciliation/reconciled_ssn_for_llc_and_aoc.py index b145dbd15f7..2b84ba07b07 100644 --- a/policyengine_us/reforms/reconciliation/reconciled_ssn_for_llc_and_aoc.py +++ b/policyengine_us/reforms/reconciliation/reconciled_ssn_for_llc_and_aoc.py @@ -120,7 +120,7 @@ def create_reconciled_ssn_for_llc_and_aoc_reform( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/refundable_credit_conversion/refundable_credit_conversion.py b/policyengine_us/reforms/refundable_credit_conversion/refundable_credit_conversion.py index 3b9a255cff1..c335d9f872f 100644 --- a/policyengine_us/reforms/refundable_credit_conversion/refundable_credit_conversion.py +++ b/policyengine_us/reforms/refundable_credit_conversion/refundable_credit_conversion.py @@ -131,7 +131,7 @@ def create_refundable_credit_conversion_reform( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/state_dependent_exemptions/repeal_state_dependent_exemptions.py b/policyengine_us/reforms/state_dependent_exemptions/repeal_state_dependent_exemptions.py index a921c8bc66b..94b10442a0f 100644 --- a/policyengine_us/reforms/state_dependent_exemptions/repeal_state_dependent_exemptions.py +++ b/policyengine_us/reforms/state_dependent_exemptions/repeal_state_dependent_exemptions.py @@ -565,7 +565,7 @@ def create_repeal_state_dependent_exemptions_reform( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/al/dependent_exemption/al_dependent_exemption_reform.py b/policyengine_us/reforms/states/al/dependent_exemption/al_dependent_exemption_reform.py index 42cf2203a87..ec3527bd861 100644 --- a/policyengine_us/reforms/states/al/dependent_exemption/al_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/al/dependent_exemption/al_dependent_exemption_reform.py @@ -44,7 +44,7 @@ def create_al_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/al/eitc/al_eitc_reform.py b/policyengine_us/reforms/states/al/eitc/al_eitc_reform.py index ca6229b9cbc..48880ffec88 100644 --- a/policyengine_us/reforms/states/al/eitc/al_eitc_reform.py +++ b/policyengine_us/reforms/states/al/eitc/al_eitc_reform.py @@ -48,7 +48,7 @@ def create_al_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/al/hb527/al_hb527_overtime_deduction.py b/policyengine_us/reforms/states/al/hb527/al_hb527_overtime_deduction.py index 0dce861037d..eb630e3ecae 100644 --- a/policyengine_us/reforms/states/al/hb527/al_hb527_overtime_deduction.py +++ b/policyengine_us/reforms/states/al/hb527/al_hb527_overtime_deduction.py @@ -66,7 +66,7 @@ def create_al_hb527_overtime_deduction_reform(parameters, period, bypass: bool = reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ar/dependent_credit/ar_dependent_credit_reform.py b/policyengine_us/reforms/states/ar/dependent_credit/ar_dependent_credit_reform.py index 0225d496bd4..e5b9fc48912 100644 --- a/policyengine_us/reforms/states/ar/dependent_credit/ar_dependent_credit_reform.py +++ b/policyengine_us/reforms/states/ar/dependent_credit/ar_dependent_credit_reform.py @@ -49,7 +49,7 @@ def create_ar_dependent_credit_reform_fn(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ar/eitc/ar_eitc_reform.py b/policyengine_us/reforms/states/ar/eitc/ar_eitc_reform.py index 911c954e7a3..de189f53f29 100644 --- a/policyengine_us/reforms/states/ar/eitc/ar_eitc_reform.py +++ b/policyengine_us/reforms/states/ar/eitc/ar_eitc_reform.py @@ -48,7 +48,7 @@ def create_ar_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/az/dependent_credit/az_dependent_credit_reform.py b/policyengine_us/reforms/states/az/dependent_credit/az_dependent_credit_reform.py index 9021e4cc595..cbbcde12d2a 100644 --- a/policyengine_us/reforms/states/az/dependent_credit/az_dependent_credit_reform.py +++ b/policyengine_us/reforms/states/az/dependent_credit/az_dependent_credit_reform.py @@ -63,7 +63,7 @@ def create_az_dependent_credit_reform_fn(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break @@ -123,7 +123,7 @@ def formula(tax_unit, period, parameters): unused_credit = max_(potential - non_refundable, 0) # Only pay the refund in periods where the reform is in effect. # The reform is installed for the whole simulation whenever it - # activates in any of the next five years (see + # activates in any year of the lookahead window (see # create_az_refundable_dependent_credit_reform_fn), so this # per-period gate prevents a refund leaking into # pre-activation years. @@ -161,7 +161,7 @@ def create_az_refundable_dependent_credit_reform_fn( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).refundable.in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/az/eitc/az_eitc_reform.py b/policyengine_us/reforms/states/az/eitc/az_eitc_reform.py index d8db7e6188f..669169cae5b 100644 --- a/policyengine_us/reforms/states/az/eitc/az_eitc_reform.py +++ b/policyengine_us/reforms/states/az/eitc/az_eitc_reform.py @@ -60,7 +60,7 @@ def create_az_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/ca/ab2591/ab2591.py b/policyengine_us/reforms/states/ca/ab2591/ab2591.py index 2dade84f10d..dbc52e1e30e 100644 --- a/policyengine_us/reforms/states/ca/ab2591/ab2591.py +++ b/policyengine_us/reforms/states/ca/ab2591/ab2591.py @@ -80,7 +80,7 @@ def create_ca_ab2591_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/ca/dependent_credit/ca_dependent_credit_reform.py b/policyengine_us/reforms/states/ca/dependent_credit/ca_dependent_credit_reform.py index c773745e64d..3cd8591e835 100644 --- a/policyengine_us/reforms/states/ca/dependent_credit/ca_dependent_credit_reform.py +++ b/policyengine_us/reforms/states/ca/dependent_credit/ca_dependent_credit_reform.py @@ -94,7 +94,7 @@ def create_ca_dependent_credit_reform_fn(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ct/hb5009/ct_hb5009.py b/policyengine_us/reforms/states/ct/hb5009/ct_hb5009.py index 66dbdafb57c..e413c6ffb75 100644 --- a/policyengine_us/reforms/states/ct/hb5009/ct_hb5009.py +++ b/policyengine_us/reforms/states/ct/hb5009/ct_hb5009.py @@ -69,7 +69,7 @@ def create_ct_hb5009_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ct/hb5114/ct_hb5114.py b/policyengine_us/reforms/states/ct/hb5114/ct_hb5114.py index c95f0f8a032..8fa170a95b0 100644 --- a/policyengine_us/reforms/states/ct/hb5114/ct_hb5114.py +++ b/policyengine_us/reforms/states/ct/hb5114/ct_hb5114.py @@ -91,7 +91,7 @@ def create_ct_hb5114_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ct/refundable_ctc/ct_refundable_ctc.py b/policyengine_us/reforms/states/ct/refundable_ctc/ct_refundable_ctc.py index dfe15111414..f38e6959843 100644 --- a/policyengine_us/reforms/states/ct/refundable_ctc/ct_refundable_ctc.py +++ b/policyengine_us/reforms/states/ct/refundable_ctc/ct_refundable_ctc.py @@ -73,7 +73,7 @@ def create_ct_refundable_ctc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ct/sb100/ct_sb100.py b/policyengine_us/reforms/states/ct/sb100/ct_sb100.py index 0faaf8a0f50..fbe5807668b 100644 --- a/policyengine_us/reforms/states/ct/sb100/ct_sb100.py +++ b/policyengine_us/reforms/states/ct/sb100/ct_sb100.py @@ -94,7 +94,7 @@ def create_ct_sb100_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ct/tax_rebate_2026/ct_tax_rebate_2026.py b/policyengine_us/reforms/states/ct/tax_rebate_2026/ct_tax_rebate_2026.py index ec44585d90e..291da9e484a 100644 --- a/policyengine_us/reforms/states/ct/tax_rebate_2026/ct_tax_rebate_2026.py +++ b/policyengine_us/reforms/states/ct/tax_rebate_2026/ct_tax_rebate_2026.py @@ -54,7 +54,7 @@ def create_ct_tax_rebate_2026_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/dc/property_tax/dc_property_tax_reform.py b/policyengine_us/reforms/states/dc/property_tax/dc_property_tax_reform.py index 575409634c0..8c67bc0574c 100644 --- a/policyengine_us/reforms/states/dc/property_tax/dc_property_tax_reform.py +++ b/policyengine_us/reforms/states/dc/property_tax/dc_property_tax_reform.py @@ -107,7 +107,7 @@ def create_dc_property_tax_credit_reform(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/de/dependent_credit/de_dependent_credit_reform.py b/policyengine_us/reforms/states/de/dependent_credit/de_dependent_credit_reform.py index b58c6357db6..d06667642f6 100644 --- a/policyengine_us/reforms/states/de/dependent_credit/de_dependent_credit_reform.py +++ b/policyengine_us/reforms/states/de/dependent_credit/de_dependent_credit_reform.py @@ -175,7 +175,7 @@ def create_de_dependent_credit_reform_fn(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ga/ctc/ga_ctc_reform.py b/policyengine_us/reforms/states/ga/ctc/ga_ctc_reform.py index 8b8f54bc4c6..0724417f7d5 100644 --- a/policyengine_us/reforms/states/ga/ctc/ga_ctc_reform.py +++ b/policyengine_us/reforms/states/ga/ctc/ga_ctc_reform.py @@ -38,7 +38,7 @@ def formula(tax_unit, period, parameters): refundable_credit = min_(unused_credit, refund_limit) # Only pay the refund in periods where the reform is in effect. The # reform is installed for the whole simulation whenever it activates - # in any of the next five years (see create_ga_ctc_reform), so this + # in any year of the lookahead window (see create_ga_ctc_reform), so this # per-period gate prevents a refund leaking into pre-activation years. return where(p.refundable.in_effect, refundable_credit, 0) @@ -68,7 +68,7 @@ def create_ga_ctc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).refundable.in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ga/dependent_exemption/ga_dependent_exemption_reform.py b/policyengine_us/reforms/states/ga/dependent_exemption/ga_dependent_exemption_reform.py index 68fea999af8..98e7a2b5998 100644 --- a/policyengine_us/reforms/states/ga/dependent_exemption/ga_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/ga/dependent_exemption/ga_dependent_exemption_reform.py @@ -89,7 +89,7 @@ def create_ga_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ga/eitc/ga_eitc_reform.py b/policyengine_us/reforms/states/ga/eitc/ga_eitc_reform.py index 9c33869f291..50e326e01d8 100644 --- a/policyengine_us/reforms/states/ga/eitc/ga_eitc_reform.py +++ b/policyengine_us/reforms/states/ga/eitc/ga_eitc_reform.py @@ -48,7 +48,7 @@ def create_ga_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/ga/sb520/ga_sb520_reform.py b/policyengine_us/reforms/states/ga/sb520/ga_sb520_reform.py index cabfb410d6c..4bf98d1b0fd 100644 --- a/policyengine_us/reforms/states/ga/sb520/ga_sb520_reform.py +++ b/policyengine_us/reforms/states/ga/sb520/ga_sb520_reform.py @@ -244,7 +244,7 @@ def create_ga_sb520_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p_sb520(current_period) if p_at_period.in_effect or p_at_period.brackets.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/hi/dependent_exemption/hi_dependent_exemption_reform.py b/policyengine_us/reforms/states/hi/dependent_exemption/hi_dependent_exemption_reform.py index a547c8cc6a3..4ede97fbab4 100644 --- a/policyengine_us/reforms/states/hi/dependent_exemption/hi_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/hi/dependent_exemption/hi_dependent_exemption_reform.py @@ -119,7 +119,7 @@ def create_hi_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/hi/hb2306_cdcc/hi_hb2306_cdcc.py b/policyengine_us/reforms/states/hi/hb2306_cdcc/hi_hb2306_cdcc.py index bf638568a1a..869bc6b8838 100644 --- a/policyengine_us/reforms/states/hi/hb2306_cdcc/hi_hb2306_cdcc.py +++ b/policyengine_us/reforms/states/hi/hb2306_cdcc/hi_hb2306_cdcc.py @@ -72,8 +72,8 @@ def create_hi_hb2306_cdcc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - # Check if reform is active in current or next 5 years - for i in range(5): + # Check if reform is active in the lookahead window + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ia/dependent_credit/ia_dependent_credit_reform.py b/policyengine_us/reforms/states/ia/dependent_credit/ia_dependent_credit_reform.py index c3484976a33..fb1e8dc60bc 100644 --- a/policyengine_us/reforms/states/ia/dependent_credit/ia_dependent_credit_reform.py +++ b/policyengine_us/reforms/states/ia/dependent_credit/ia_dependent_credit_reform.py @@ -75,7 +75,7 @@ def create_ia_dependent_credit_reform_fn(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/id/ctc/id_ctc_reform.py b/policyengine_us/reforms/states/id/ctc/id_ctc_reform.py index 5baf9eccc30..016e4507a84 100644 --- a/policyengine_us/reforms/states/id/ctc/id_ctc_reform.py +++ b/policyengine_us/reforms/states/id/ctc/id_ctc_reform.py @@ -140,7 +140,7 @@ def create_id_ctc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): node = p(current_period) if node.in_effect or node.refundable.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/id/eitc/id_eitc_reform.py b/policyengine_us/reforms/states/id/eitc/id_eitc_reform.py index e3967bb3b8c..935f51b44fb 100644 --- a/policyengine_us/reforms/states/id/eitc/id_eitc_reform.py +++ b/policyengine_us/reforms/states/id/eitc/id_eitc_reform.py @@ -60,7 +60,7 @@ def create_id_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/id/s1450/s1450.py b/policyengine_us/reforms/states/id/s1450/s1450.py index 9d55950c7e4..ec485c0303e 100644 --- a/policyengine_us/reforms/states/id/s1450/s1450.py +++ b/policyengine_us/reforms/states/id/s1450/s1450.py @@ -33,11 +33,11 @@ def create_id_s1450_reform(parameters, period, bypass: bool = False): p = parameters.gov.contrib.states.id.s1450 - # 5-year lookahead + # Lookahead window reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/il/dependent_exemption/il_dependent_exemption_reform.py b/policyengine_us/reforms/states/il/dependent_exemption/il_dependent_exemption_reform.py index 9b2ee01bfe6..14eb27b83dd 100644 --- a/policyengine_us/reforms/states/il/dependent_exemption/il_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/il/dependent_exemption/il_dependent_exemption_reform.py @@ -42,7 +42,7 @@ def create_il_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/il/sb3567/il_sb3567_reform.py b/policyengine_us/reforms/states/il/sb3567/il_sb3567_reform.py index 182b8652a6d..aa3d340e626 100644 --- a/policyengine_us/reforms/states/il/sb3567/il_sb3567_reform.py +++ b/policyengine_us/reforms/states/il/sb3567/il_sb3567_reform.py @@ -98,7 +98,7 @@ def create_il_sb3567_reform(parameters, period, bypass: bool = False): if bypass: return create_il_sb3567() # Idiomatic single-period activation check, matching sibling contrib - # reforms (pa_ctc_match, ct_sb100, ny/wftc). No 5-year forward + # reforms (pa_ctc_match, ct_sb100, ny/wftc). No forward # lookahead: that pattern can retroactively activate the reform in # earlier years when the toggle later flips, which is not desired here. if parameters(period).gov.contrib.states.il.sb3567.in_effect: diff --git a/policyengine_us/reforms/states/in/dependent_exemption/in_dependent_exemption_reform.py b/policyengine_us/reforms/states/in/dependent_exemption/in_dependent_exemption_reform.py index d0443121227..617aafcb8ce 100644 --- a/policyengine_us/reforms/states/in/dependent_exemption/in_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/in/dependent_exemption/in_dependent_exemption_reform.py @@ -101,7 +101,7 @@ def create_in_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ks/dependent_exemption/ks_dependent_exemption_reform.py b/policyengine_us/reforms/states/ks/dependent_exemption/ks_dependent_exemption_reform.py index 18a04f4a64d..fbbc5838ea9 100644 --- a/policyengine_us/reforms/states/ks/dependent_exemption/ks_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/ks/dependent_exemption/ks_dependent_exemption_reform.py @@ -121,7 +121,7 @@ def create_ks_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ky/eitc/ky_eitc_reform.py b/policyengine_us/reforms/states/ky/eitc/ky_eitc_reform.py index 6949552af25..88b15d7021b 100644 --- a/policyengine_us/reforms/states/ky/eitc/ky_eitc_reform.py +++ b/policyengine_us/reforms/states/ky/eitc/ky_eitc_reform.py @@ -48,7 +48,7 @@ def create_ky_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/ky/graduated_income_tax/ky_graduated_income_tax_reform.py b/policyengine_us/reforms/states/ky/graduated_income_tax/ky_graduated_income_tax_reform.py index 619deb10de8..b100b7516a4 100644 --- a/policyengine_us/reforms/states/ky/graduated_income_tax/ky_graduated_income_tax_reform.py +++ b/policyengine_us/reforms/states/ky/graduated_income_tax/ky_graduated_income_tax_reform.py @@ -110,8 +110,8 @@ def create_ky_graduated_income_tax_reform(parameters, period, bypass: bool = Fal reform_active = False current_period = period_(period) - # Check if either reform will be active in the next 5 years - for i in range(5): + # Check if either reform will be active in the lookahead window + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p_hb13(current_period).in_effect or p_hb152(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ma/commonwealth_credit/ma_commonwealth_credit.py b/policyengine_us/reforms/states/ma/commonwealth_credit/ma_commonwealth_credit.py index d0ada9616ad..e625e8978f3 100644 --- a/policyengine_us/reforms/states/ma/commonwealth_credit/ma_commonwealth_credit.py +++ b/policyengine_us/reforms/states/ma/commonwealth_credit/ma_commonwealth_credit.py @@ -49,7 +49,7 @@ class ma_commonwealth_credit(Variable): def formula(tax_unit, period, parameters): p = parameters(period).gov.contrib.states.ma.commonwealth_credit - # The 5-year lookahead in the reform factory can apply this + # The lookahead in the reform factory can apply this # reform to years before it takes effect; gate on the scalar # in_effect parameter so pre-effective years return the # baseline behavior (no Commonwealth Credit). @@ -85,7 +85,7 @@ class ma_eitc(Variable): def formula(tax_unit, period, parameters): federal_eitc = tax_unit("eitc", period) rate = parameters(period).gov.states.ma.tax.income.credits.eitc.match - # The 5-year lookahead in the reform factory can apply this + # The lookahead in the reform factory can apply this # reform to years before it takes effect; gate on the scalar # in_effect parameter so pre-effective years return the baseline # full match to all filers. @@ -129,7 +129,7 @@ def create_ma_commonwealth_credit_reform(parameters, period, bypass: bool = Fals reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ma/dependent_exemption/ma_dependent_exemption_reform.py b/policyengine_us/reforms/states/ma/dependent_exemption/ma_dependent_exemption_reform.py index 4347e2c5376..70b61302732 100644 --- a/policyengine_us/reforms/states/ma/dependent_exemption/ma_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/ma/dependent_exemption/ma_dependent_exemption_reform.py @@ -35,7 +35,7 @@ def formula(tax_unit, period, parameters): # baseline per-dependent exemption. Only apply the reform # pricing in periods where the reform is in effect — the reform # is installed for the whole simulation whenever it activates in - # any of the next five years, so this per-period gate prevents + # any year of the lookahead window, so this per-period gate prevents # the reform amount leaking into pre-activation years. if pc.in_effect: if pc.age_limit.in_effect: @@ -84,7 +84,7 @@ def create_ma_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ma/tiered_child_and_family_credit/ma_tiered_child_and_family_credit.py b/policyengine_us/reforms/states/ma/tiered_child_and_family_credit/ma_tiered_child_and_family_credit.py index f77766c3ebc..24c32f6ba96 100644 --- a/policyengine_us/reforms/states/ma/tiered_child_and_family_credit/ma_tiered_child_and_family_credit.py +++ b/policyengine_us/reforms/states/ma/tiered_child_and_family_credit/ma_tiered_child_and_family_credit.py @@ -66,7 +66,7 @@ def formula(tax_unit, period, parameters): person = tax_unit.members dependent = person("is_tax_unit_dependent", period) age = person("age", period) - # The 5-year lookahead in the reform factory can apply this + # The lookahead in the reform factory can apply this # reform to years before it takes effect; gate on the scalar # in_effect parameter so pre-effective years return the baseline # flat-amount credit. @@ -131,7 +131,7 @@ def create_ma_tiered_child_and_family_credit_reform( reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/md/dependent_exemption/md_dependent_exemption_reform.py b/policyengine_us/reforms/states/md/dependent_exemption/md_dependent_exemption_reform.py index 323615d4b82..0e44412ba1d 100644 --- a/policyengine_us/reforms/states/md/dependent_exemption/md_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/md/dependent_exemption/md_dependent_exemption_reform.py @@ -154,7 +154,7 @@ def create_md_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/me/ld229/me_ld229_reform.py b/policyengine_us/reforms/states/me/ld229/me_ld229_reform.py index c6587188a55..a03ac394279 100644 --- a/policyengine_us/reforms/states/me/ld229/me_ld229_reform.py +++ b/policyengine_us/reforms/states/me/ld229/me_ld229_reform.py @@ -51,7 +51,7 @@ def create_me_ld229_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/mi/ctc/mi_ctc_reform.py b/policyengine_us/reforms/states/mi/ctc/mi_ctc_reform.py index db9afc8b196..13604f5f586 100644 --- a/policyengine_us/reforms/states/mi/ctc/mi_ctc_reform.py +++ b/policyengine_us/reforms/states/mi/ctc/mi_ctc_reform.py @@ -55,7 +55,7 @@ def create_mi_ctc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/mi/dependent_exemption/mi_dependent_exemption_reform.py b/policyengine_us/reforms/states/mi/dependent_exemption/mi_dependent_exemption_reform.py index dd3a6c87cf7..fae3d9d4a59 100644 --- a/policyengine_us/reforms/states/mi/dependent_exemption/mi_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/mi/dependent_exemption/mi_dependent_exemption_reform.py @@ -102,7 +102,7 @@ def create_mi_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/mn/dependent_exemption/mn_dependent_exemption_reform.py b/policyengine_us/reforms/states/mn/dependent_exemption/mn_dependent_exemption_reform.py index 20a51743508..d2395c04bed 100644 --- a/policyengine_us/reforms/states/mn/dependent_exemption/mn_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/mn/dependent_exemption/mn_dependent_exemption_reform.py @@ -67,7 +67,7 @@ def create_mn_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/mn/hf4890/mn_hf4890.py b/policyengine_us/reforms/states/mn/hf4890/mn_hf4890.py index 06810c91cc3..03cc330d8da 100644 --- a/policyengine_us/reforms/states/mn/hf4890/mn_hf4890.py +++ b/policyengine_us/reforms/states/mn/hf4890/mn_hf4890.py @@ -73,7 +73,7 @@ def create_mn_hf4890_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/mo/eitc/mo_refundable_eitc_reform.py b/policyengine_us/reforms/states/mo/eitc/mo_refundable_eitc_reform.py index b87586aba11..383afc6aff2 100644 --- a/policyengine_us/reforms/states/mo/eitc/mo_refundable_eitc_reform.py +++ b/policyengine_us/reforms/states/mo/eitc/mo_refundable_eitc_reform.py @@ -98,7 +98,7 @@ def create_mo_refundable_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ms/dependent_exemption/ms_dependent_exemption_reform.py b/policyengine_us/reforms/states/ms/dependent_exemption/ms_dependent_exemption_reform.py index 667dd02a8df..6d9a00d358a 100644 --- a/policyengine_us/reforms/states/ms/dependent_exemption/ms_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/ms/dependent_exemption/ms_dependent_exemption_reform.py @@ -42,7 +42,7 @@ def create_ms_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ms/eitc/ms_eitc_reform.py b/policyengine_us/reforms/states/ms/eitc/ms_eitc_reform.py index 8127bb65275..7110e843b3d 100644 --- a/policyengine_us/reforms/states/ms/eitc/ms_eitc_reform.py +++ b/policyengine_us/reforms/states/ms/eitc/ms_eitc_reform.py @@ -48,7 +48,7 @@ def create_ms_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/mt/ctc/mt_ctc.py b/policyengine_us/reforms/states/mt/ctc/mt_ctc.py index ce9f8593724..f4b5abd8cdd 100644 --- a/policyengine_us/reforms/states/mt/ctc/mt_ctc.py +++ b/policyengine_us/reforms/states/mt/ctc/mt_ctc.py @@ -133,7 +133,7 @@ def create_mt_ctc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/mt/hb268/mt_hb268.py b/policyengine_us/reforms/states/mt/hb268/mt_hb268.py index e05d2d88468..1f11890a240 100644 --- a/policyengine_us/reforms/states/mt/hb268/mt_hb268.py +++ b/policyengine_us/reforms/states/mt/hb268/mt_hb268.py @@ -98,7 +98,7 @@ def create_mt_hb268_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/mt/newborn_credit/mt_newborn_credit.py b/policyengine_us/reforms/states/mt/newborn_credit/mt_newborn_credit.py index 91fe5566d89..7f9175f9d45 100644 --- a/policyengine_us/reforms/states/mt/newborn_credit/mt_newborn_credit.py +++ b/policyengine_us/reforms/states/mt/newborn_credit/mt_newborn_credit.py @@ -112,7 +112,7 @@ def create_mt_newborn_credit_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/nc/cdcc/nc_cdcc_reform.py b/policyengine_us/reforms/states/nc/cdcc/nc_cdcc_reform.py index 5ef1728228b..366ef3e9734 100644 --- a/policyengine_us/reforms/states/nc/cdcc/nc_cdcc_reform.py +++ b/policyengine_us/reforms/states/nc/cdcc/nc_cdcc_reform.py @@ -65,7 +65,7 @@ def create_nc_cdcc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/nc/eitc/nc_eitc_reform.py b/policyengine_us/reforms/states/nc/eitc/nc_eitc_reform.py index 31eff7aba40..f96525635a6 100644 --- a/policyengine_us/reforms/states/nc/eitc/nc_eitc_reform.py +++ b/policyengine_us/reforms/states/nc/eitc/nc_eitc_reform.py @@ -58,7 +58,7 @@ def create_nc_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/nd/eitc/nd_eitc_reform.py b/policyengine_us/reforms/states/nd/eitc/nd_eitc_reform.py index c674726b633..7565924bbff 100644 --- a/policyengine_us/reforms/states/nd/eitc/nd_eitc_reform.py +++ b/policyengine_us/reforms/states/nd/eitc/nd_eitc_reform.py @@ -52,7 +52,7 @@ def create_nd_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/states/ne/dependent_exemption/ne_dependent_exemption_reform.py b/policyengine_us/reforms/states/ne/dependent_exemption/ne_dependent_exemption_reform.py index 84cd5b077cc..8b5e8fb255f 100644 --- a/policyengine_us/reforms/states/ne/dependent_exemption/ne_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/ne/dependent_exemption/ne_dependent_exemption_reform.py @@ -98,7 +98,7 @@ def create_ne_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/nj/dependent_exemption/nj_dependent_exemption_reform.py b/policyengine_us/reforms/states/nj/dependent_exemption/nj_dependent_exemption_reform.py index a0e437b6b54..066bad59d3c 100644 --- a/policyengine_us/reforms/states/nj/dependent_exemption/nj_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/nj/dependent_exemption/nj_dependent_exemption_reform.py @@ -55,7 +55,7 @@ def create_nj_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ny/dependent_exemption/ny_dependent_exemption_reform.py b/policyengine_us/reforms/states/ny/dependent_exemption/ny_dependent_exemption_reform.py index 007179a0a07..8e024f1d67f 100644 --- a/policyengine_us/reforms/states/ny/dependent_exemption/ny_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/ny/dependent_exemption/ny_dependent_exemption_reform.py @@ -49,7 +49,7 @@ def create_ny_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ny/s9110/ny_s9110_income_tax_reform.py b/policyengine_us/reforms/states/ny/s9110/ny_s9110_income_tax_reform.py index 94c521346c6..2fb27f56d92 100644 --- a/policyengine_us/reforms/states/ny/s9110/ny_s9110_income_tax_reform.py +++ b/policyengine_us/reforms/states/ny/s9110/ny_s9110_income_tax_reform.py @@ -64,7 +64,7 @@ def create_ny_s9110_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/oh/dependent_exemption/oh_dependent_exemption_reform.py b/policyengine_us/reforms/states/oh/dependent_exemption/oh_dependent_exemption_reform.py index 28154def134..35cffe80789 100644 --- a/policyengine_us/reforms/states/oh/dependent_exemption/oh_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/oh/dependent_exemption/oh_dependent_exemption_reform.py @@ -113,7 +113,7 @@ def create_oh_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/oh/eitc/oh_refundable_eitc_reform.py b/policyengine_us/reforms/states/oh/eitc/oh_refundable_eitc_reform.py index 8cc0b8e3fe9..a9733ead6c1 100644 --- a/policyengine_us/reforms/states/oh/eitc/oh_refundable_eitc_reform.py +++ b/policyengine_us/reforms/states/oh/eitc/oh_refundable_eitc_reform.py @@ -124,7 +124,7 @@ def create_oh_refundable_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ok/ctc/ok_refundable_ctc_reform.py b/policyengine_us/reforms/states/ok/ctc/ok_refundable_ctc_reform.py index a018bc597c6..4a9a64cb7b4 100644 --- a/policyengine_us/reforms/states/ok/ctc/ok_refundable_ctc_reform.py +++ b/policyengine_us/reforms/states/ok/ctc/ok_refundable_ctc_reform.py @@ -94,7 +94,7 @@ def create_ok_refundable_ctc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ok/dependent_exemption/ok_dependent_exemption_reform.py b/policyengine_us/reforms/states/ok/dependent_exemption/ok_dependent_exemption_reform.py index 762babe6a52..df0a04573ae 100644 --- a/policyengine_us/reforms/states/ok/dependent_exemption/ok_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/ok/dependent_exemption/ok_dependent_exemption_reform.py @@ -117,7 +117,7 @@ def create_ok_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/oregon/dependent_exemption_credit/or_dependent_exemption_credit_reform.py b/policyengine_us/reforms/states/oregon/dependent_exemption_credit/or_dependent_exemption_credit_reform.py index 1ff4effc4b0..0db6a52bc87 100644 --- a/policyengine_us/reforms/states/oregon/dependent_exemption_credit/or_dependent_exemption_credit_reform.py +++ b/policyengine_us/reforms/states/oregon/dependent_exemption_credit/or_dependent_exemption_credit_reform.py @@ -164,7 +164,7 @@ def create_or_dependent_exemption_credit_reform_fn( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/pa/ctc/pa_ctc_flat_amount.py b/policyengine_us/reforms/states/pa/ctc/pa_ctc_flat_amount.py index 77aedb87318..99fbd72e604 100644 --- a/policyengine_us/reforms/states/pa/ctc/pa_ctc_flat_amount.py +++ b/policyengine_us/reforms/states/pa/ctc/pa_ctc_flat_amount.py @@ -68,7 +68,7 @@ def create_pa_ctc_flat_amount_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/pa/ctc/pa_ctc_match.py b/policyengine_us/reforms/states/pa/ctc/pa_ctc_match.py index ed83a3b5ed9..de84583a023 100644 --- a/policyengine_us/reforms/states/pa/ctc/pa_ctc_match.py +++ b/policyengine_us/reforms/states/pa/ctc/pa_ctc_match.py @@ -88,7 +88,7 @@ def create_pa_ctc_match_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ri/ctc/ri_ctc_reform.py b/policyengine_us/reforms/states/ri/ctc/ri_ctc_reform.py index b0ab425740f..ba9bb31fcaa 100644 --- a/policyengine_us/reforms/states/ri/ctc/ri_ctc_reform.py +++ b/policyengine_us/reforms/states/ri/ctc/ri_ctc_reform.py @@ -206,7 +206,7 @@ def create_ri_ctc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ri/exemption/ri_exemption_reform.py b/policyengine_us/reforms/states/ri/exemption/ri_exemption_reform.py index ecf00256286..b45cced8465 100644 --- a/policyengine_us/reforms/states/ri/exemption/ri_exemption_reform.py +++ b/policyengine_us/reforms/states/ri/exemption/ri_exemption_reform.py @@ -149,7 +149,7 @@ def create_ri_exemption_reform_fn(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ri/high_earner_tax/ri_high_earner_tax_reform.py b/policyengine_us/reforms/states/ri/high_earner_tax/ri_high_earner_tax_reform.py index e7211a4c75f..3b44154aa11 100644 --- a/policyengine_us/reforms/states/ri/high_earner_tax/ri_high_earner_tax_reform.py +++ b/policyengine_us/reforms/states/ri/high_earner_tax/ri_high_earner_tax_reform.py @@ -48,7 +48,7 @@ def create_ri_high_earner_tax_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ri/social_security_exemption/ri_social_security_exemption_reform.py b/policyengine_us/reforms/states/ri/social_security_exemption/ri_social_security_exemption_reform.py index e4103445a86..7514c6b1b73 100644 --- a/policyengine_us/reforms/states/ri/social_security_exemption/ri_social_security_exemption_reform.py +++ b/policyengine_us/reforms/states/ri/social_security_exemption/ri_social_security_exemption_reform.py @@ -124,7 +124,7 @@ def create_ri_social_security_exemption_reform( reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/sc/child_poverty_eitc/sc_fully_refundable_eitc_reform.py b/policyengine_us/reforms/states/sc/child_poverty_eitc/sc_fully_refundable_eitc_reform.py index d4522581b00..5b6573e61be 100644 --- a/policyengine_us/reforms/states/sc/child_poverty_eitc/sc_fully_refundable_eitc_reform.py +++ b/policyengine_us/reforms/states/sc/child_poverty_eitc/sc_fully_refundable_eitc_reform.py @@ -110,7 +110,7 @@ def create_sc_fully_refundable_eitc_reform(parameters, period, bypass: bool = Fa reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/sc/dependent_exemption/sc_dependent_exemption_reform.py b/policyengine_us/reforms/states/sc/dependent_exemption/sc_dependent_exemption_reform.py index f227705ede8..49ea2348f2e 100644 --- a/policyengine_us/reforms/states/sc/dependent_exemption/sc_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/sc/dependent_exemption/sc_dependent_exemption_reform.py @@ -56,7 +56,7 @@ def create_sc_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/sc/h3492/sc_h3492_eitc_refundable.py b/policyengine_us/reforms/states/sc/h3492/sc_h3492_eitc_refundable.py index 2d9f1838e3d..a17e23119a7 100644 --- a/policyengine_us/reforms/states/sc/h3492/sc_h3492_eitc_refundable.py +++ b/policyengine_us/reforms/states/sc/h3492/sc_h3492_eitc_refundable.py @@ -140,7 +140,7 @@ def create_sc_h3492_eitc_refundable_reform(parameters, period, bypass: bool = Fa reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/tx/rebate/tx_rebate.py b/policyengine_us/reforms/states/tx/rebate/tx_rebate.py index 501511dd82d..4c2ccf257c4 100644 --- a/policyengine_us/reforms/states/tx/rebate/tx_rebate.py +++ b/policyengine_us/reforms/states/tx/rebate/tx_rebate.py @@ -152,7 +152,7 @@ def create_tx_rebate_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ut/child_poverty_eitc/ut_fully_refundable_eitc_reform.py b/policyengine_us/reforms/states/ut/child_poverty_eitc/ut_fully_refundable_eitc_reform.py index b2c23b3bdcf..38f23d97c19 100644 --- a/policyengine_us/reforms/states/ut/child_poverty_eitc/ut_fully_refundable_eitc_reform.py +++ b/policyengine_us/reforms/states/ut/child_poverty_eitc/ut_fully_refundable_eitc_reform.py @@ -107,7 +107,7 @@ def create_ut_fully_refundable_eitc_reform(parameters, period, bypass: bool = Fa reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ut/ctc/ut_ctc_reform.py b/policyengine_us/reforms/states/ut/ctc/ut_ctc_reform.py index f0cd16a01b2..1b70ac0a4b4 100644 --- a/policyengine_us/reforms/states/ut/ctc/ut_ctc_reform.py +++ b/policyengine_us/reforms/states/ut/ctc/ut_ctc_reform.py @@ -111,7 +111,7 @@ def create_ut_ctc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ut/dependent_exemption/ut_dependent_exemption_reform.py b/policyengine_us/reforms/states/ut/dependent_exemption/ut_dependent_exemption_reform.py index 84f0200ba99..85c45e51eca 100644 --- a/policyengine_us/reforms/states/ut/dependent_exemption/ut_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/ut/dependent_exemption/ut_dependent_exemption_reform.py @@ -21,7 +21,7 @@ def formula(tax_unit, period, parameters): pc = parameters(period).gov.contrib.states.ut.dependent_exemption # Only apply the reform pricing in periods where the reform is # in effect — the reform is installed for the whole simulation - # whenever it activates in any of the next five years, so this + # whenever it activates in any year of the lookahead window, so this # per-period gate prevents the reform amount leaking into # pre-activation years. if not pc.in_effect: @@ -78,7 +78,7 @@ def create_ut_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ut/ut_hb210.py b/policyengine_us/reforms/states/ut/ut_hb210.py index bf794dd5db3..b2bc6556d68 100644 --- a/policyengine_us/reforms/states/ut/ut_hb210.py +++ b/policyengine_us/reforms/states/ut/ut_hb210.py @@ -59,7 +59,7 @@ def create_ut_hb210_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ut/ut_hb210_s2.py b/policyengine_us/reforms/states/ut/ut_hb210_s2.py index ff1568e74a0..0e784c2b570 100644 --- a/policyengine_us/reforms/states/ut/ut_hb210_s2.py +++ b/policyengine_us/reforms/states/ut/ut_hb210_s2.py @@ -89,7 +89,7 @@ def modify_parameters(parameters): class reform(Reform): def apply(self): self.modify_parameters(modify_parameters) - self.add_variable(ut_hb210_s2_marriage_credit) + self.update_variable(ut_hb210_s2_marriage_credit) return reform @@ -103,7 +103,7 @@ def create_ut_hb210_s2_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/ut/ut_refundable_eitc.py b/policyengine_us/reforms/states/ut/ut_refundable_eitc.py index 1829a0cf8f7..34a1e228972 100644 --- a/policyengine_us/reforms/states/ut/ut_refundable_eitc.py +++ b/policyengine_us/reforms/states/ut/ut_refundable_eitc.py @@ -101,7 +101,7 @@ def create_ut_refundable_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/va/dependent_exemption/va_dependent_exemption_reform.py b/policyengine_us/reforms/states/va/dependent_exemption/va_dependent_exemption_reform.py index b4bb5367f2e..b5acb29a8e2 100644 --- a/policyengine_us/reforms/states/va/dependent_exemption/va_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/va/dependent_exemption/va_dependent_exemption_reform.py @@ -152,7 +152,7 @@ def create_va_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/va/hb979/va_hb979_reform.py b/policyengine_us/reforms/states/va/hb979/va_hb979_reform.py index 4f3119c2a8b..f1bf7db34da 100644 --- a/policyengine_us/reforms/states/va/hb979/va_hb979_reform.py +++ b/policyengine_us/reforms/states/va/hb979/va_hb979_reform.py @@ -41,7 +41,7 @@ def create_va_hb979_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/vt/dependent_exemption/vt_dependent_exemption_reform.py b/policyengine_us/reforms/states/vt/dependent_exemption/vt_dependent_exemption_reform.py index 69440c7d77b..b4ce1ab1a8b 100644 --- a/policyengine_us/reforms/states/vt/dependent_exemption/vt_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/vt/dependent_exemption/vt_dependent_exemption_reform.py @@ -108,7 +108,7 @@ def create_vt_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/vt/fair_share/vt_fair_share_reform.py b/policyengine_us/reforms/states/vt/fair_share/vt_fair_share_reform.py index e9e5022f485..640cdb4714c 100644 --- a/policyengine_us/reforms/states/vt/fair_share/vt_fair_share_reform.py +++ b/policyengine_us/reforms/states/vt/fair_share/vt_fair_share_reform.py @@ -72,7 +72,7 @@ def create_vt_fair_share_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/wi/dependent_exemption/wi_dependent_exemption_reform.py b/policyengine_us/reforms/states/wi/dependent_exemption/wi_dependent_exemption_reform.py index 0471bac9c9a..4320f52617c 100644 --- a/policyengine_us/reforms/states/wi/dependent_exemption/wi_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/wi/dependent_exemption/wi_dependent_exemption_reform.py @@ -111,7 +111,7 @@ def create_wi_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/wv/dependent_exemption/wv_dependent_exemption_reform.py b/policyengine_us/reforms/states/wv/dependent_exemption/wv_dependent_exemption_reform.py index 4af8b64ba2a..64f92b9742c 100644 --- a/policyengine_us/reforms/states/wv/dependent_exemption/wv_dependent_exemption_reform.py +++ b/policyengine_us/reforms/states/wv/dependent_exemption/wv_dependent_exemption_reform.py @@ -119,7 +119,7 @@ def create_wv_dependent_exemption_reform_fn(parameters, period, bypass: bool = F reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/reforms/states/wv/eitc/wv_eitc_reform.py b/policyengine_us/reforms/states/wv/eitc/wv_eitc_reform.py index 90baa6b39ab..c18e1dfdf8a 100644 --- a/policyengine_us/reforms/states/wv/eitc/wv_eitc_reform.py +++ b/policyengine_us/reforms/states/wv/eitc/wv_eitc_reform.py @@ -60,7 +60,7 @@ def create_wv_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): p_at_period = p(current_period) if p_at_period.in_effect: reform_active = True diff --git a/policyengine_us/reforms/treasury/repeal_dependent_exemptions.py b/policyengine_us/reforms/treasury/repeal_dependent_exemptions.py index fbfd6b94c1e..729dd9a3fa3 100644 --- a/policyengine_us/reforms/treasury/repeal_dependent_exemptions.py +++ b/policyengine_us/reforms/treasury/repeal_dependent_exemptions.py @@ -39,7 +39,7 @@ def create_repeal_dependent_exemptions_reform(parameters, period, bypass: bool = reform_active = False current_period = period_(period) - for i in range(5): + for i in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).repeal_dependent_exemptions: reform_active = True break diff --git a/policyengine_us/reforms/winship.py b/policyengine_us/reforms/winship.py index 8a85330e27a..00cfe917cd7 100644 --- a/policyengine_us/reforms/winship.py +++ b/policyengine_us/reforms/winship.py @@ -87,7 +87,7 @@ def create_individual_eitc_reform(parameters, period, bypass: bool = False): reform_active = False current_period = period_(period) - for _ in range(5): + for _ in range(STRUCTURAL_REFORM_CHECK_YEARS): if p(current_period).in_effect: reform_active = True break diff --git a/policyengine_us/system.py b/policyengine_us/system.py index eaef87ae6a4..4460cc277fd 100644 --- a/policyengine_us/system.py +++ b/policyengine_us/system.py @@ -18,6 +18,7 @@ StateCode, ) from policyengine_us.tools.parameters import ( + EARLIEST_STRUCTURAL_REFORM_YEAR, FIRST_MODELED_YEAR, backdate_parameters, ) @@ -51,6 +52,7 @@ add_per_capita_uprating, ) from policyengine_us.data.dataset_schema import ( + _DEFAULT_TIME_PERIOD, US_ENTITIES, USSingleYearDataset, USMultiYearDataset, @@ -68,8 +70,10 @@ COUNTRY_DIR = Path(__file__).parent -CURRENT_YEAR = 2024 -DEFAULT_START_DATE = str(CURRENT_YEAR) + "-01-01" +CURRENT_YEAR = 2026 +# Structural-reform checks start here rather than at CURRENT_YEAR, so moving the +# default calculation year does not stop reforms from earlier years applying. +DEFAULT_START_DATE = f"{EARLIEST_STRUCTURAL_REFORM_YEAR}-01-01" # Certified Microcosm build (primary-source US microdata), pinned by build id. # Microcosm ships from a Hugging Face *dataset* repo, hence the `hf://datasets/` @@ -98,11 +102,11 @@ class CountryTaxBenefitSystem(TaxBenefitSystem): If no reform is applied, the system will be initialized with the default tax/benefit parameters. - start_instant(str: ISO date format YYYY-MM-DD): Optional; The date - at which the simulation begins; defaults to 2024-01-01; this is a - temporary patch for structural reforms, and must be set to the start - date of a structural reform parameter if it begins on a date other - than the first day of the current year. + start_instant(str: ISO date format YYYY-MM-DD): Optional; The first + date checked when deciding which structural reforms apply; defaults + to 2024-01-01. Most structural reforms are checked on January 1 of + ten consecutive years from this date, and some only on this date, so + set it when a reform's parameter turns on outside those dates. """ variables_dir = COUNTRY_DIR / "variables" @@ -327,11 +331,11 @@ class Simulation(TobCalculationMixin, SPMSimulationMixin, CoreSimulation): does not include society-wide microdata. Args: - start_instant(str: ISO date format YYYY-MM-DD): Optional; The date - at which the simulation begins; defaults to 2024-01-01; this is a - temporary patch for structural reforms, and must be set to the start - date of a structural reform parameter if it begins on a date other - than the first day of the current year. + start_instant(str: ISO date format YYYY-MM-DD): Optional; The first + date checked when deciding which structural reforms apply; defaults + to 2024-01-01. Most structural reforms are checked on January 1 of + ten consecutive years from this date, and some only on this date, so + set it when a reform's parameter turns on outside those dates. """ default_tax_benefit_system = CountryTaxBenefitSystem @@ -494,11 +498,11 @@ class Microsimulation(TobCalculationMixin, SPMSimulationMixin, CoreMicrosimulati thus suitable for society-level impacts. Args: - start_instant(str: ISO date format YYYY-MM-DD): Optional; The date - at which the simulation begins; defaults to 2024-01-01; this is a - temporary patch for structural reforms, and must be set to the start - date of a structural reform parameter if it begins on a date other - than the first day of the current year. + start_instant(str: ISO date format YYYY-MM-DD): Optional; The first + date checked when deciding which structural reforms apply; defaults + to 2024-01-01. Most structural reforms are checked on January 1 of + ten consecutive years from this date, and some only on this date, so + set it when a reform's parameter turns on outside those dates. dataset_end_year(int | None): Optional; The final year to create when automatically extending an entity-level single-year dataset. Defaults to the latest supported economic-assumption year. This option applies @@ -509,10 +513,12 @@ class Microsimulation(TobCalculationMixin, SPMSimulationMixin, CoreMicrosimulati default_tax_benefit_system = CountryTaxBenefitSystem default_tax_benefit_system_instance = system default_dataset = DEFAULT_DATASET - default_dataset_year = CURRENT_YEAR + # Microdata stays in its base year: core labels a dataset without its own + # year with the default input period, and values are not uprated for it. + default_dataset_year = _DEFAULT_TIME_PERIOD default_role = "member" - default_calculation_period = CURRENT_YEAR - default_input_period = CURRENT_YEAR + default_calculation_period = _DEFAULT_TIME_PERIOD + default_input_period = _DEFAULT_TIME_PERIOD def __init__(self, *args, **kwargs): start_instant: Annotated[str, "ISO date format YYYY-MM-DD"] = kwargs.pop( diff --git a/policyengine_us/tests/code_health/test_no_add_variable_in_reforms.py b/policyengine_us/tests/code_health/test_no_add_variable_in_reforms.py new file mode 100644 index 00000000000..8de573611fb --- /dev/null +++ b/policyengine_us/tests/code_health/test_no_add_variable_in_reforms.py @@ -0,0 +1,38 @@ +"""Reforms must be safe to apply more than once. + +``CountryTaxBenefitSystem`` applies a structural reform and ``Simulation`` +applies it again, so ``add_variable`` raises ``VariableNameConflictError`` the +second time. YAML tests apply a reform once and cannot detect this. +``update_variable`` adds a new variable and replaces an existing one. +""" + +import ast + +from policyengine_us.model_api import REPO + +REFORMS_ROOT = REPO / "reforms" +NON_REPEATABLE_METHODS = {"add_variable", "add_variables"} + + +def calls_non_repeatable_method(node: ast.AST) -> bool: + return ( + isinstance(node, ast.Call) + and isinstance(node.func, ast.Attribute) + and node.func.attr in NON_REPEATABLE_METHODS + ) + + +def test_reforms_do_not_call_add_variable(): + violations = [] + + for file_name in sorted(REFORMS_ROOT.glob("**/*.py")): + tree = ast.parse(file_name.read_text(), filename=str(file_name)) + for node in ast.walk(tree): + if calls_non_repeatable_method(node): + violations.append(f"{file_name.relative_to(REPO)}:{node.lineno}") + + assert not violations, ( + "Use update_variable in reforms: a Simulation applies structural " + "reforms a second time, and add_variable raises when it does. " + "Violations:\n" + "\n".join(violations) + ) diff --git a/policyengine_us/tests/code_health/test_structural_reform_check_years.py b/policyengine_us/tests/code_health/test_structural_reform_check_years.py new file mode 100644 index 00000000000..10067cf45c4 --- /dev/null +++ b/policyengine_us/tests/code_health/test_structural_reform_check_years.py @@ -0,0 +1,62 @@ +"""Reform factories that look ahead must share one number of years. + +A factory written with its own ``range(5)`` would stop finding reforms that +every other factory finds, and nothing would report it: the reform would simply +not apply. +""" + +import ast + +from policyengine_us.model_api import REPO + +REFORMS_ROOT = REPO / "reforms" + + +def is_reform_factory(node: ast.AST) -> bool: + return ( + isinstance(node, ast.FunctionDef) + and node.name.startswith("create_") + and any(argument.arg == "bypass" for argument in node.args.args) + ) + + +def statements_outside_nested_definitions(function: ast.FunctionDef): + pending = list(function.body) + while pending: + node = pending.pop() + if isinstance(node, (ast.FunctionDef, ast.ClassDef)): + continue + yield node + pending.extend(ast.iter_child_nodes(node)) + + +def loops_over_another_range(node: ast.AST) -> bool: + if not ( + isinstance(node, ast.For) + and isinstance(node.iter, ast.Call) + and isinstance(node.iter.func, ast.Name) + and node.iter.func.id == "range" + ): + return False + arguments = node.iter.args + return not ( + len(arguments) == 1 + and isinstance(arguments[0], ast.Name) + and arguments[0].id == "STRUCTURAL_REFORM_CHECK_YEARS" + ) + + +def test_reform_factories_use_the_shared_number_of_years(): + violations = [] + + for file_name in sorted(REFORMS_ROOT.glob("**/*.py")): + tree = ast.parse(file_name.read_text(), filename=str(file_name)) + for factory in filter(is_reform_factory, ast.walk(tree)): + for node in statements_outside_nested_definitions(factory): + if loops_over_another_range(node): + violations.append(f"{file_name.relative_to(REPO)}:{node.lineno}") + + assert not violations, ( + "Loop over range(STRUCTURAL_REFORM_CHECK_YEARS) in reform factories. " + "Violations:\n" + "\n".join(violations) + ) diff --git a/policyengine_us/tests/core/test_business_income_regressions.py b/policyengine_us/tests/core/test_business_income_regressions.py index 0edd081739f..51b5eb54e02 100644 --- a/policyengine_us/tests/core/test_business_income_regressions.py +++ b/policyengine_us/tests/core/test_business_income_regressions.py @@ -12,6 +12,7 @@ def test_simulation_moves_self_employment_input_before_lsr(): }, }, }, + default_input_period=2024, ) assert simulation.calculate("self_employment_income_before_lsr", 2024)[0] == 10_000 @@ -27,6 +28,7 @@ def test_simulation_moves_sstb_self_employment_input_before_lsr(): }, }, }, + default_input_period=2024, ) assert ( @@ -45,6 +47,7 @@ def test_taxable_self_employment_income_uses_farm_operations_income(): }, }, }, + default_input_period=2024, ) assert simulation.calculate("taxable_self_employment_income", 2024)[ @@ -61,6 +64,7 @@ def test_taxable_self_employment_income_excludes_schedule_j_farm_income(): }, }, }, + default_input_period=2024, ) assert simulation.calculate("taxable_self_employment_income", 2024)[0] == 0 diff --git a/policyengine_us/tests/microsimulation/test_dataset_default_year.py b/policyengine_us/tests/microsimulation/test_dataset_default_year.py new file mode 100644 index 00000000000..c63586cace8 --- /dev/null +++ b/policyengine_us/tests/microsimulation/test_dataset_default_year.py @@ -0,0 +1,36 @@ +"""A dataset without its own year stays in the microdata base year. + +Core labels such a dataset with the default input period and does not uprate +its values, so following ``CURRENT_YEAR`` would present 2024 dollars as a later +year and leave the base year empty. +""" + +import numpy as np +import pandas as pd + +from policyengine_us import Microsimulation +from policyengine_us.data.dataset_schema import _DEFAULT_TIME_PERIOD + + +def test_dataframe_without_years_stays_in_the_base_year(): + wages = [10_000.0, 20_000.0] + identifiers = [1, 2] + dataset = pd.DataFrame( + { + "person_id": identifiers, + "household_id": identifiers, + "tax_unit_id": identifiers, + "spm_unit_id": identifiers, + "family_id": identifiers, + "marital_unit_id": identifiers, + "age": [40.0, 50.0], + "employment_income": wages, + "household_weight": [1.0, 1.0], + } + ) + + simulation = Microsimulation(dataset=dataset) + + assert int(simulation.dataset.time_period) == _DEFAULT_TIME_PERIOD + base_year_wages = simulation.calculate("employment_income", _DEFAULT_TIME_PERIOD) + np.testing.assert_array_equal(np.asarray(base_year_wages), wages) diff --git a/policyengine_us/tests/microsimulation/test_marital_unit_inputs.py b/policyengine_us/tests/microsimulation/test_marital_unit_inputs.py index 40b18e6c665..37b7365ab96 100644 --- a/policyengine_us/tests/microsimulation/test_marital_unit_inputs.py +++ b/policyengine_us/tests/microsimulation/test_marital_unit_inputs.py @@ -342,14 +342,17 @@ def test_fallback_stops_at_a_false_is_married_or_another_household(): ], ) def test_inputs_dated_after_the_default_input_year_keep_the_couple(order): - # Simulation's default input year is 2024; a payload dated 2026 must - # still pair its couple wherever they are listed. + # With a default input year of 2024, a payload dated 2026 must still pair + # its couple wherever they are listed. people = { "grandchild": {"age": {"2026": 10}}, "husband": {"age": {"2026": 70}}, "wife": {"age": {"2026": 68}}, } - sim = Simulation(situation={"people": {name: people[name] for name in order}}) + sim = Simulation( + situation={"people": {name: people[name] for name in order}}, + default_input_period=2024, + ) units = sim.marital_unit.members_entity_id.tolist() index = {name: position for position, name in enumerate(order)} assert units[index["husband"]] == units[index["wife"]] @@ -653,6 +656,6 @@ def test_undated_role_inputs_set_units_for_the_default_input_year(): "wife": {"age": 68}, "grandchild": {"age": 10, "is_tax_unit_spouse": False}, } - sim = Simulation(situation={"people": people}) + sim = Simulation(situation={"people": people}, default_input_period=2024) assert len(set(sim.marital_unit.members_entity_id.tolist())) == 3 assert sim.calculate("is_tax_unit_spouse", 2026).tolist() == [False, True, False] diff --git a/policyengine_us/tests/policy/contrib/local/ny/test_nyc_mamdani_income_tax_properties.py b/policyengine_us/tests/policy/contrib/local/ny/test_nyc_mamdani_income_tax_properties.py index e6bc707f68e..cce00cfb583 100644 --- a/policyengine_us/tests/policy/contrib/local/ny/test_nyc_mamdani_income_tax_properties.py +++ b/policyengine_us/tests/policy/contrib/local/ny/test_nyc_mamdani_income_tax_properties.py @@ -18,7 +18,7 @@ - it is zero outside NYC; and - it is zero in years before ``in_effect`` turns on, even though the factory installs the reform for the whole simulation when ``in_effect`` is true on - January 1 of any of the five years from the simulation's start instant. + January 1 of any year checked from the simulation's start instant. """ import functools diff --git a/policyengine_us/tests/policy/contrib/refundable_credit_conversion/test_refundable_credit_conversion_autoloader.py b/policyengine_us/tests/policy/contrib/refundable_credit_conversion/test_refundable_credit_conversion_autoloader.py index f1f6e488271..38fbe4cedc4 100644 --- a/policyengine_us/tests/policy/contrib/refundable_credit_conversion/test_refundable_credit_conversion_autoloader.py +++ b/policyengine_us/tests/policy/contrib/refundable_credit_conversion/test_refundable_credit_conversion_autoloader.py @@ -5,7 +5,7 @@ exercise the autoloader directly for its two cheapest properties: the bypass flag and the default-inactive return-None path. -The 5-year forward-lookahead window itself is not unit-tested here: +The forward-lookahead window itself is not unit-tested here: constructing parameter trees with `in_effect` true at specific future years requires a `copy.deepcopy(system.parameters)` per case, which pushes peak memory past the CI runner cap when this directory's batch diff --git a/policyengine_us/tests/policy/contrib/states/test_dependent_exemption_reform_activation.py b/policyengine_us/tests/policy/contrib/states/test_dependent_exemption_reform_activation.py index 32cc784f088..581121dae8d 100644 --- a/policyengine_us/tests/policy/contrib/states/test_dependent_exemption_reform_activation.py +++ b/policyengine_us/tests/policy/contrib/states/test_dependent_exemption_reform_activation.py @@ -5,7 +5,7 @@ module-level object (e.g. ``hi_dependent_exemption_reform``), so the non-bypass code path inside every ``create__..._reform_fn`` is never run by those tests. That path inspects the ``in_effect`` contrib parameter over a -five-year window and returns either a ``Reform`` subclass (when the reform is +lookahead window and returns either a ``Reform`` subclass (when the reform is in effect) or ``None`` (the default no-op). This module covers both outcomes for all eleven states in the PR, mirroring how diff --git a/policyengine_us/tests/policy/contrib/states/test_id_ga_ctc_reform_activation.py b/policyengine_us/tests/policy/contrib/states/test_id_ga_ctc_reform_activation.py index cdba3447c06..88c7cd91789 100644 --- a/policyengine_us/tests/policy/contrib/states/test_id_ga_ctc_reform_activation.py +++ b/policyengine_us/tests/policy/contrib/states/test_id_ga_ctc_reform_activation.py @@ -8,7 +8,7 @@ * ``ga_refundable_ctc`` had no per-period ``in_effect`` gate, so once the reform was installed (the factory installs it for the whole simulation whenever the - toggle is true in any of the next five years) it paid the refund in every + toggle is true in any year of its lookahead window) it paid the refund in every year, including pre-activation ones. * the Idaho reform's ``modify_parameters`` revived ``id_ctc`` in the ordered nonrefundable list from a hardcoded ``2026-01-01`` regardless of the actual diff --git a/policyengine_us/tests/policy/contrib/states/test_structural_reforms_in_simulation.py b/policyengine_us/tests/policy/contrib/states/test_structural_reforms_in_simulation.py new file mode 100644 index 00000000000..84973374538 --- /dev/null +++ b/policyengine_us/tests/policy/contrib/states/test_structural_reforms_in_simulation.py @@ -0,0 +1,215 @@ +"""State structural reforms must build and calculate in a real ``Simulation``. + +YAML tests apply a reform once, to a copy of the built default system. A +``Simulation`` instead builds ``CountryTaxBenefitSystem(reform=...)``, which +finds structural reforms from their ``in_effect`` parameters and refreshes the +per-capita uprating series, and then applies the reforms a second time. The +failures covered here only appear on that path, so YAML tests cannot detect +them. +""" + +from functools import lru_cache +from types import SimpleNamespace + +import numpy as np +import pytest +from policyengine_core.reforms import Reform + +from policyengine_us import Simulation +from policyengine_us.reforms.states.nd.eitc.nd_eitc_reform import ( + create_nd_eitc_reform, +) +from policyengine_us.reforms.states.ut.ut_hb210_s2 import ut_hb210_s2 +from policyengine_us.system import DEFAULT_START_DATE, system +from policyengine_us.tools.per_capita_uprating import ( + is_national_total_path, + per_capita_path, +) + +PERIOD = "2026" +REFORM_DATES = "2024-01-01.2100-12-31" +FEDERAL_EITC = 1_000 +EITC_MATCH_RATE = 0.5 +# gov.states.oh.tax.income.credits.eitc.rate +OHIO_EITC_RATE = 0.3 +EMPLOYMENT_INCOME_NATIONAL_TOTAL = "calibration.gov.irs.soi.employment_income" +EXPECTED_REFUNDABLE_CREDIT_BY_STATE = { + "AL": FEDERAL_EITC * EITC_MATCH_RATE, + "KY": FEDERAL_EITC * EITC_MATCH_RATE, + "MS": FEDERAL_EITC * EITC_MATCH_RATE, + "ND": FEDERAL_EITC * EITC_MATCH_RATE, + # Ohio's reform has no match rate: it refunds Ohio's existing credit. + "OH": FEDERAL_EITC * OHIO_EITC_RATE, +} +UTAH_MARRIAGE_CREDIT_SWITCH = "gov.contrib.states.ut.hb210.s2_marriage_credit.in_effect" +# JOINT entry of gov.contrib.states.ut.hb210.s2_marriage_credit.amount +UTAH_JOINT_MARRIAGE_CREDIT = 158 + + +def _eitc_reform_parameters(): + reform_parameters = {} + for state_code in EXPECTED_REFUNDABLE_CREDIT_BY_STATE: + eitc_parameters = ( + f"gov.contrib.states.{state_code.lower()}" + ".child_poverty_impact_dashboard.eitc" + ) + reform_parameters[f"{eitc_parameters}.in_effect"] = {REFORM_DATES: True} + if state_code != "OH": + reform_parameters[f"{eitc_parameters}.match"] = { + REFORM_DATES: EITC_MATCH_RATE + } + return reform_parameters + + +def _one_filer_per_state(state_codes, year=PERIOD): + def groups_of_one(group_name): + return { + f"{group_name}_{state_code}": {"members": [state_code]} + for state_code in state_codes + } + + tax_units = groups_of_one("tax_unit") + households = groups_of_one("household") + for state_code in state_codes: + tax_units[f"tax_unit_{state_code}"]["eitc"] = {year: FEDERAL_EITC} + households[f"household_{state_code}"]["state_code"] = {year: state_code} + return { + "people": {state_code: {"age": {year: 35}} for state_code in state_codes}, + "tax_units": tax_units, + "families": groups_of_one("family"), + "spm_units": groups_of_one("spm_unit"), + "marital_units": groups_of_one("marital_unit"), + "households": households, + } + + +def _utah_married_couple(): + spouses = ["spouse_with_earnings", "other_spouse"] + return { + "people": { + "spouse_with_earnings": { + "age": {PERIOD: 40}, + "employment_income": {PERIOD: 60_000}, + }, + "other_spouse": {"age": {PERIOD: 40}}, + }, + "tax_units": { + "tax_unit": {"members": spouses, "filing_status": {PERIOD: "JOINT"}} + }, + "families": {"family": {"members": spouses}}, + "spm_units": {"spm_unit": {"members": spouses}}, + "marital_units": {"marital_unit": {"members": spouses}}, + "households": {"household": {"members": spouses, "state_code": {PERIOD: "UT"}}}, + } + + +@lru_cache(maxsize=None) +def _baseline_utah_non_refundable_credits(): + baseline_simulation = Simulation(situation=_utah_married_couple()) + baseline_credits = baseline_simulation.calculate( + "ut_non_refundable_credits", PERIOD + ) + return float(np.asarray(baseline_credits)[0]) + + +def _parameters_with_north_dakota_eitc_on_only_in(year): + # Clone only the states subtree, so the test builds no full parameter tree. + states = system.parameters.gov.contrib.states.clone() + states.parent = None + states.nd.child_poverty_impact_dashboard.eitc.in_effect.update( + period=f"year:{year}:1", value=True + ) + return SimpleNamespace(gov=SimpleNamespace(contrib=SimpleNamespace(states=states))) + + +@pytest.mark.parametrize("switch_year", [2024, 2025, 2033]) +def test_reform_is_found_when_switch_is_on_in_a_checked_year(switch_year): + parameters = _parameters_with_north_dakota_eitc_on_only_in(switch_year) + + assert create_nd_eitc_reform(parameters, DEFAULT_START_DATE) is not None + + +@pytest.mark.parametrize("switch_year", [2023, 2034]) +def test_reform_is_not_found_when_switch_is_on_outside_checked_years(switch_year): + parameters = _parameters_with_north_dakota_eitc_on_only_in(switch_year) + + assert create_nd_eitc_reform(parameters, DEFAULT_START_DATE) is None + + +def test_reform_on_only_before_the_default_year_applies_in_a_simulation(): + year = "2025" + dates = "2025-01-01.2025-12-31" + eitc_parameters = "gov.contrib.states.nd.child_poverty_impact_dashboard.eitc" + simulation = Simulation( + situation=_one_filer_per_state(["ND"], year=year), + reform={ + f"{eitc_parameters}.in_effect": {dates: True}, + f"{eitc_parameters}.match": {dates: EITC_MATCH_RATE}, + }, + ) + + credit = simulation.calculate("nd_refundable_credits", year) + assert np.asarray(credit) == pytest.approx([FEDERAL_EITC * EITC_MATCH_RATE]) + + +def test_eitc_reforms_that_replace_input_credits_build_and_calculate(): + """Each reform turns an uprated dollar input into a computed variable. + + All five states share one simulation, so the test builds one system. + """ + state_codes = list(EXPECTED_REFUNDABLE_CREDIT_BY_STATE) + simulation = Simulation( + situation=_one_filer_per_state(state_codes), + reform=_eitc_reform_parameters(), + ) + + for filer_index, state_code in enumerate(state_codes): + expected_credits = np.zeros(len(state_codes)) + expected_credits[filer_index] = EXPECTED_REFUNDABLE_CREDIT_BY_STATE[state_code] + calculated_credits = simulation.calculate( + f"{state_code.lower()}_refundable_credits", PERIOD + ) + assert np.asarray(calculated_credits) == pytest.approx(expected_credits) + + # The build only fails for a computed variable left on a national total, so + # check that this test still exercises that case. + variables = simulation.tax_benefit_system.variables + for state_code in state_codes: + credit_variable = variables[f"{state_code.lower()}_refundable_credits"] + assert not credit_variable.is_input_variable() + assert is_national_total_path(credit_variable.uprating) + assert variables["employment_income_before_lsr"].uprating == per_capita_path( + EMPLOYMENT_INCOME_NATIONAL_TOTAL + ) + + +@pytest.mark.parametrize( + "includes_reform_object", + [False, True], + ids=["parameter_switch", "reform_object_and_parameter_switch"], +) +def test_utah_marriage_credit_reform_can_be_applied_repeatedly( + includes_reform_object, +): + switch_parameters = {UTAH_MARRIAGE_CREDIT_SWITCH: {REFORM_DATES: True}} + reform = switch_parameters + if includes_reform_object: + reform = ( + ut_hb210_s2, + Reform.from_dict(switch_parameters, country_id="us"), + ) + + simulation = Simulation(situation=_utah_married_couple(), reform=reform) + + marriage_credit = simulation.calculate("ut_hb210_s2_marriage_credit", PERIOD) + assert np.asarray(marriage_credit) == pytest.approx([UTAH_JOINT_MARRIAGE_CREDIT]) + non_refundable_credits = ( + simulation.tax_benefit_system.parameters.gov.states.ut.tax.income.credits + ).non_refundable(f"{PERIOD}-01-01") + assert list(non_refundable_credits).count("ut_hb210_s2_marriage_credit") == 1 + + reformed_credits = np.asarray( + simulation.calculate("ut_non_refundable_credits", PERIOD) + ) + credit_increase = reformed_credits - _baseline_utah_non_refundable_credits() + assert credit_increase == pytest.approx([UTAH_JOINT_MARRIAGE_CREDIT]) diff --git a/policyengine_us/tests/policy/contrib/states/vt/fair_share/test_vt_fair_share_reform_activation.py b/policyengine_us/tests/policy/contrib/states/vt/fair_share/test_vt_fair_share_reform_activation.py index e59c6f2d51f..f541628b798 100644 --- a/policyengine_us/tests/policy/contrib/states/vt/fair_share/test_vt_fair_share_reform_activation.py +++ b/policyengine_us/tests/policy/contrib/states/vt/fair_share/test_vt_fair_share_reform_activation.py @@ -5,7 +5,7 @@ ``create_vt_fair_share_reform`` or its registration in ``create_structural_reforms_from_parameters``. That is the path the app and API take when a user sets ``gov.contrib.states.vt.fair_share.in_effect``. The -factory looks at the period and the next four years and returns a ``Reform`` +factory looks at each year of its lookahead window and returns a ``Reform`` subclass if the toggle is true in any of them, or ``None`` otherwise. As in ``test_dependent_exemption_reform_activation.py``, only the @@ -26,11 +26,11 @@ create_vt_fair_share_reform, ) from policyengine_us.system import system +from policyengine_us.tools.parameters import STRUCTURAL_REFORM_CHECK_YEARS YEAR = 2026 PERIOD = f"{YEAR}-01-01" -# The factory checks the period and the next four years. -LOOKAHEAD_YEARS = 5 +LOOKAHEAD_YEARS = STRUCTURAL_REFORM_CHECK_YEARS REFORM_VARIABLES = { "vt_fair_share_surcharge", "vt_income_tax_before_refundable_credits", @@ -115,8 +115,8 @@ def test__given_default_parameters__then_factory_returns_none(): def test__given_in_effect_true_within_lookahead__then_factory_returns_reform( years_ahead, ): - # in_effect is true only in one year: the period itself (0) or up to four - # years later. + # in_effect is true only in one year: the period itself (0) or a later year + # of the lookahead window. states = _states_with_in_effect(period=f"year:{YEAR + years_ahead}:1") result = create_vt_fair_share_reform(_contrib_states_only(states), PERIOD) @@ -129,7 +129,7 @@ def test__given_in_effect_true_within_lookahead__then_factory_returns_reform( def test__given_in_effect_true_only_beyond_lookahead__then_factory_returns_none( years_ahead, ): - # in_effect is false through the fifth year and true from then on. + # in_effect is false through the lookahead window and true after it. states = _states_with_in_effect(start=f"{YEAR + years_ahead}-01-01") result = create_vt_fair_share_reform(_contrib_states_only(states), PERIOD) diff --git a/policyengine_us/tests/test_ctc_itemizing_branch_cycle.py b/policyengine_us/tests/test_ctc_itemizing_branch_cycle.py index 2198de58e74..437c71c768e 100644 --- a/policyengine_us/tests/test_ctc_itemizing_branch_cycle.py +++ b/policyengine_us/tests/test_ctc_itemizing_branch_cycle.py @@ -45,7 +45,7 @@ def test_refundable_ctc_on_itemizing_branch_does_not_recurse(): }, "households": {"hh": {"members": ["adult", "child"], "state_code": "CA"}}, } - sim = Simulation(situation=situation) + sim = Simulation(situation=situation, default_input_period=2024) itemizing_branch = sim.get_branch("itemizing") itemizing_branch.set_input("tax_unit_itemizes", 2024, np.array([True])) @@ -78,7 +78,7 @@ def test_income_tax_on_itemizing_branch_with_no_dependents(): "tax_units": {"tu": {"members": ["adult"], "filing_status": "SINGLE"}}, "households": {"hh": {"members": ["adult"], "state_code": "CA"}}, } - sim = Simulation(situation=situation) + sim = Simulation(situation=situation, default_input_period=2024) itemizing_branch = sim.get_branch("itemizing") itemizing_branch.set_input("tax_unit_itemizes", 2024, np.array([True])) diff --git a/policyengine_us/tools/parameters.py b/policyengine_us/tools/parameters.py index d95547f8dc5..247116af52d 100644 --- a/policyengine_us/tools/parameters.py +++ b/policyengine_us/tools/parameters.py @@ -8,6 +8,14 @@ # this year. FIRST_MODELED_YEAR = 2015 +# The first year checked by default when deciding whether a structural reform +# applies: the base year of the default dataset. It stays fixed when +# CURRENT_YEAR moves, so a reform that is on only in an earlier year still +# applies. +EARLIEST_STRUCTURAL_REFORM_YEAR = 2024 +# How many years a reform factory checks, counting the first. +STRUCTURAL_REFORM_CHECK_YEARS = 10 + def str_to_instant(s): return periods.Instant(tuple(map(lambda s: int(s), s.split("-")))) diff --git a/policyengine_us/tools/per_capita_uprating.py b/policyengine_us/tools/per_capita_uprating.py index acf5f04a1e4..21fb104d1ff 100644 --- a/policyengine_us/tools/per_capita_uprating.py +++ b/policyengine_us/tools/per_capita_uprating.py @@ -182,7 +182,7 @@ def add_per_capita_parameters_for_parameter_uprating(parameters) -> None: def add_per_capita_uprating(system) -> None: - """Point every variable that uprates by a national total at its + """Point every input variable that uprates by a national total at its per-capita sibling, building or refreshing the sibling parameters. Runs at the end of system init and again after every parameter reform, so @@ -215,7 +215,11 @@ def add_per_capita_uprating(system) -> None: for path in sorted(totals): _add_per_capita_parameter(system.parameters, path) for variable in system.variables.values(): - if is_national_total_path(variable.uprating): + # A reform can replace an input with a computed variable, which inherits + # the input's uprating. Assigning it would count as declaring uprating + # on a computed variable, which core rejects. The inherited path is read + # only in a period the variable has no formula for. + if variable.is_input_variable() and is_national_total_path(variable.uprating): variable.uprating = per_capita_path(variable.uprating)