Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply five year forward checks with utility function #5175

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
fb07a46
Apply five-year-forward check
leehengpan Sep 25, 2024
7f0708f
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
leehengpan Sep 30, 2024
710d2ce
changelog_entry.yaml added
leehengpan Sep 30, 2024
b00f925
Fixed formatting
leehengpan Sep 30, 2024
23b777a
Update capital_gains_tax_increase.py
leehengpan Oct 7, 2024
9a77097
Update remove_head_of_household.py
leehengpan Oct 7, 2024
1e69cdf
Update family_security_act_2024_ctc.py
leehengpan Oct 7, 2024
e224ce3
Update family_security_act_2024_eitc.py
leehengpan Oct 7, 2024
8fba501
Update boost_middle_class_tax_credit.py
leehengpan Oct 7, 2024
ba672a5
Update end_child_poverty_act.py
leehengpan Oct 7, 2024
5e312f9
Update ctc_expansion.py
leehengpan Oct 7, 2024
b74d514
Update dc_kccatc.py
leehengpan Oct 7, 2024
ce8394d
Update halve_joint_eitc_phase_out_rate.py
leehengpan Oct 7, 2024
7eeca54
Update abolish_federal_income_tax.py
leehengpan Oct 7, 2024
b7dd7e2
Update abolish_payroll_tax.py
leehengpan Oct 7, 2024
c9270fb
Update reported_state_income_tax.py
leehengpan Oct 7, 2024
2cd624a
Update rent_relief_tax_credit.py
leehengpan Oct 7, 2024
ad846e4
Update middle_class_tax_credit.py
leehengpan Oct 7, 2024
ba064ba
Update adjust_income_limit_by_filing_status_and_eligibility_by_childr…
leehengpan Oct 7, 2024
5e415f1
Update dc_ctc.py
leehengpan Oct 7, 2024
db47292
Update mn_walz_hf1938.py
leehengpan Oct 7, 2024
b33a826
Update ny_working_families_tax_credit.py
leehengpan Oct 7, 2024
fe0b951
Update or_rebate_state_tax_exempt.py
leehengpan Oct 7, 2024
b5f0c5d
Update repeal_dependent_exemptions.py
leehengpan Oct 7, 2024
81c65c9
Apply five year checks with the new utility function
leehengpan Oct 7, 2024
cd45dd1
Rename utility function and fix dc_kccatc
leehengpan Oct 22, 2024
8a00947
Format and fix utility import issue
leehengpan Oct 22, 2024
a58678b
Handle Nonetype in utility function
leehengpan Oct 22, 2024
888a194
Fix formatting
leehengpan Oct 22, 2024
a31cbf1
Handle Nonetype in reforms
leehengpan Oct 22, 2024
fb2ec47
Add missing arguments to utility function calls
leehengpan Oct 22, 2024
dfea777
Add missing arguments to utility function calls
leehengpan Oct 22, 2024
ddaea59
Fix utility function and apply to dc_kccatc
leehengpan Oct 22, 2024
2f2ae75
Add arguments to reform function in utility function
leehengpan Oct 22, 2024
3556249
Rewrite utility function
leehengpan Oct 22, 2024
c0589f8
Handle reform functions with and without arguments
leehengpan Oct 22, 2024
a15c912
Update __init__ files
leehengpan Oct 22, 2024
8ebe6d9
Formatting
leehengpan Oct 22, 2024
c5a289f
fix init files
leehengpan Oct 22, 2024
55b3186
update function names in reforms.py
leehengpan Oct 22, 2024
1926499
Fix reform creation and utility function implementation
leehengpan Oct 23, 2024
8981b91
Fix formatting
leehengpan Oct 23, 2024
f4633c6
Handle argument inconsistency in utility function
leehengpan Oct 23, 2024
e1de578
Fix incorrect function import in reforms.py
leehengpan Oct 23, 2024
8bb4c40
Fix parameter routes
leehengpan Oct 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
added:
- Add five-year-forward check on all reforms
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *

from reforms.utilities import is_reform_active

def create_capital_gains_tax_increase() -> Reform:
class capital_gains_tax(Variable):
Expand Down Expand Up @@ -145,8 +145,9 @@ def create_capital_gains_tax_increase_reform(
return create_capital_gains_tax_increase()

p = parameters(period).gov.contrib.biden.budget_2025.capital_gains
reform_active = is_reform_active(p, period, "active")

if p.active:
if reform_active:
return create_capital_gains_tax_increase()
else:
return None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from policyengine_us.model_api import *
from policyengine_core.periods import period as period_


def create_medicare_and_investment_tax_increase() -> Reform:
Expand Down Expand Up @@ -75,8 +76,19 @@ def create_medicare_and_investment_tax_increase_reform(
return create_medicare_and_investment_tax_increase()

p = parameters(period).gov.contrib.biden.budget_2025
current_period = period_(period)
reform_active = False

if (p.medicare.rate > 0) | (p.net_investment_income.rate > 0):
for i in range(5):
if (
p(current_period).medicare.rate > 0
or p(current_period).net_investment_income.rate > 0
):
reform_active = True
break
current_period = current_period.offset(1, "year")

if reform_active:
return create_medicare_and_investment_tax_increase()
else:
return None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from policyengine_us.model_api import *
from policyengine_core.periods import period as period_


def create_increase_taxable_earnings_for_social_security() -> Reform:
Expand Down Expand Up @@ -33,8 +34,16 @@ def create_increase_taxable_earnings_for_social_security_reform(
return create_increase_taxable_earnings_for_social_security()

p = parameters(period).gov.contrib.cbo.payroll
current_period = period_(period)
reform_active = False

if p.secondary_earnings_threshold < np.inf:
for i in range(5):
if p(current_period).secondary_earnings_threshold < np.inf:
reform_active = True
break
current_period = current_period.offset(1, "year")

if reform_active:
return create_increase_taxable_earnings_for_social_security()
else:
return None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *
from policyengine_core.periods import period as period_
from reforms.utilities import is_reform_active


def create_remove_head_of_household() -> Reform:
Expand All @@ -18,14 +18,7 @@ def create_remove_head_of_household_reform(

# Look ahead for the next five years
p = parameters.gov.contrib.congress.romney.family_security_act
reform_active = False
current_period = period_(period)

for i in range(5):
if p(current_period).remove_head_of_household:
reform_active = True
break
current_period = current_period.offset(1, "year")
reform_active = is_reform_active(p, period, "remove_head_of_household")

if reform_active:
return create_remove_head_of_household()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from policyengine_us.model_api import *
from policyengine_core.periods import period as period_

from reforms.utilities import is_reform_active

def create_family_security_act_2024_ctc() -> Reform:
class ctc_phase_in_rate(Variable):
Expand Down Expand Up @@ -147,14 +146,7 @@ def create_family_security_act_2024_ctc_reform(

# Look ahead for the next five years
p = parameters.gov.contrib.congress.romney.family_security_act_2_0.ctc
reform_active = False
current_period = period_(period)

for i in range(5):
if p(current_period).apply_ctc_structure:
reform_active = True
break
current_period = current_period.offset(1, "year")
reform_active = is_reform_active(p, period, "apply_ctc_structure")

if reform_active:
return create_family_security_act_2024_ctc()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *
from policyengine_core.periods import period as period_
from reforms.utilities import is_reform_active


def create_family_security_act_2024_eitc() -> Reform:
Expand Down Expand Up @@ -38,14 +38,7 @@ def create_family_security_act_2024_eitc_reform(

# Look ahead for the next five years
p = parameters.gov.contrib.congress.romney.family_security_act_2_0.eitc
reform_active = False
current_period = period_(period)

for i in range(5):
if p(current_period).apply_eitc_structure:
reform_active = True
break
current_period = current_period.offset(1, "year")
reform_active = is_reform_active(p, period, "apply_eitc_structure")

if reform_active:
return create_family_security_act_2024_eitc()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *

from reforms.utilities import is_reform_active

def create_boost_middle_class_tax_credit() -> Reform:
class boost_middle_class_tax_credit(Variable):
Expand Down Expand Up @@ -147,8 +147,9 @@ def create_boost_middle_class_tax_credit_reform(
return create_boost_middle_class_tax_credit()

p = parameters(period).gov.contrib.harris.lift.middle_class_tax_credit
reform_active = is_reform_active(p, period)

if p.in_effect:
if reform_active:
return create_boost_middle_class_tax_credit()
else:
return None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from policyengine_us.model_api import *
from reforms.utilities import is_reform_active


def create_end_child_poverty_act() -> Reform:
Expand Down Expand Up @@ -180,8 +181,9 @@ def create_end_child_poverty_act_reform(
return create_end_child_poverty_act()

p = parameters(period).gov.contrib.congress.tlaib.end_child_poverty_act
reform_active = is_reform_active(p, period)

if p.in_effect:
if reform_active:
return create_end_child_poverty_act()
else:
return None
Expand Down
15 changes: 2 additions & 13 deletions policyengine_us/reforms/congress/wyden_smith/ctc_expansion.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *
from policyengine_core.periods import period as period_
from reforms.utilities import is_reform_active


def create_ctc_expansion() -> Reform:
Expand Down Expand Up @@ -111,18 +111,7 @@ def create_ctc_expansion_reform(parameters, period, bypass: bool = False):
# Look ahead for the next five years

p = parameters.gov.contrib.congress.wyden_smith

reform_active = False
current_period = period_(period)

for i in range(5):
if (
p(current_period).actc_lookback
or p(current_period).per_child_actc_phase_in
):
reform_active = True
break
current_period = current_period.offset(1, "year")
reform_active = is_reform_active(p, period, "actc_lookback") or is_reform_active(p, period, "per_child_actc_phase_in")

if reform_active:
return create_ctc_expansion()
Expand Down
18 changes: 14 additions & 4 deletions policyengine_us/reforms/dc_kccatc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from policyengine_us.model_api import *
from reforms.utilities import is_reform_active


def create_dc_kccatc_reform(parameters, period, bypass=False):
def create_dc_kccatc():
class dc_kccatc(Variable):
value_type = float
entity = TaxUnit
Expand Down Expand Up @@ -87,8 +87,18 @@ class reform(Reform):
def apply(self):
self.update_variable(dc_kccatc)

if bypass or parameters(period).gov.contrib.dc_kccatc.active:
return reform
return reform
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes in this variable seemed to break - could you check the unit tests



def create_dc_kccatc_reform(parameters, period, bypass=False):
if bypass:
return create_dc_kccatc()

p = parameters(period).gov.contrib.dc_kccatc
reform_active = is_reform_active(p, period, "active")

if reform_active:
return create_dc_kccatc()
else:
return None

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from policyengine_us.model_api import *
from reforms.utilities import is_reform_active


def create_halve_joint_eitc_phase_out_rate() -> Reform:
Expand Down Expand Up @@ -32,8 +33,9 @@ def create_halve_joint_eitc_phase_out_rate_reform(
return create_halve_joint_eitc_phase_out_rate()

p = parameters(period).gov.contrib.joint_eitc
reform_active = is_reform_active(p, period)

if p.in_effect:
if reform_active:
return create_halve_joint_eitc_phase_out_rate()
else:
return None
Expand Down
5 changes: 3 additions & 2 deletions policyengine_us/reforms/federal/abolish_federal_income_tax.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *

from reforms.utilities import is_reform_active

def create_abolish_federal_income_tax() -> Reform:
class household_tax_before_refundable_credits(Variable):
Expand Down Expand Up @@ -54,8 +54,9 @@ def create_abolish_federal_income_tax_reform(
return create_abolish_federal_income_tax()

p = parameters(period).gov.contrib.ubi_center.flat_tax
reform_active = is_reform_active(p, period, "abolish_federal_income_tax")

if p.abolish_federal_income_tax:
if reform_active:
return create_abolish_federal_income_tax()
else:
return None
Expand Down
5 changes: 3 additions & 2 deletions policyengine_us/reforms/federal/abolish_payroll_tax.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *

from reforms.utilities import is_reform_active

def create_abolish_payroll_tax() -> Reform:
class household_tax_before_refundable_credits(Variable):
Expand Down Expand Up @@ -34,8 +34,9 @@ def create_abolish_payroll_tax_reform(
return create_abolish_payroll_tax()

p = parameters(period).gov.contrib.ubi_center.flat_tax
reform_active = is_reform_active(p, period, "abolish_payroll_tax")

if p.abolish_payroll_tax:
if reform_active:
return create_abolish_payroll_tax()
else:
return None
Expand Down
5 changes: 3 additions & 2 deletions policyengine_us/reforms/federal/reported_state_income_tax.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *

from reforms.utilities import is_reform_active

def create_reported_state_income_tax() -> Reform:
class household_tax_before_refundable_credits(Variable):
Expand Down Expand Up @@ -61,8 +61,9 @@ def create_reported_state_income_tax_reform(
return create_reported_state_income_tax()

p = parameters(period).simulation
reform_active = is_reform_active(p, period, "reported_state_income_tax")

if p.reported_state_income_tax:
if reform_active:
return create_reported_state_income_tax()
else:
return None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *

from reforms.utilities import is_reform_active

def create_middle_class_tax_credit() -> Reform:
class middle_class_tax_credit(Variable):
Expand Down Expand Up @@ -61,8 +61,9 @@ def create_middle_class_tax_credit_reform(
return create_middle_class_tax_credit()

p = parameters(period).gov.contrib.harris.lift.middle_class_tax_credit
reform_active = is_reform_active(p, period)

if p.in_effect:
if reform_active:
return create_middle_class_tax_credit()
else:
return None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *

from reforms.utilities import is_reform_active

def create_rent_relief_tax_credit() -> Reform:
class rent_relief_tax_credit(Variable):
Expand Down Expand Up @@ -83,8 +83,9 @@ def create_rent_relief_tax_credit_reform(
p = parameters(
period
).gov.contrib.harris.rent_relief_act.rent_relief_credit
reform_active = is_reform_active(p, period)

if p.in_effect:
if reform_active:
return create_rent_relief_tax_credit()
else:
return None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from policyengine_us.model_api import *

from reforms.utilities import is_reform_active

def create_adjust_income_limit_and_min_children_by_filing_status() -> Reform:
class nyc_school_tax_credit_eligible(Variable):
Expand Down Expand Up @@ -55,8 +55,9 @@ def create_adjust_income_limit_by_filing_status_and_eligibility_by_children_refo
return create_adjust_income_limit_and_min_children_by_filing_status()

p = parameters(period).gov.contrib.local.nyc.stc
reform_active = is_reform_active(p, period, "adjust_income_limit_by_filing_status_and_eligibility_by_children")

if p.adjust_income_limit_by_filing_status_and_eligibility_by_children:
if reform_active:
return create_adjust_income_limit_and_min_children_by_filing_status()
else:
return None
Expand Down
15 changes: 6 additions & 9 deletions policyengine_us/reforms/states/dc/dc_ctc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from policyengine_us.model_api import *
from policyengine_core.periods import period as period_

from reforms.utilities import is_reform_active

def create_dc_ctc() -> Reform:
class dc_ctc(Variable):
Expand Down Expand Up @@ -61,14 +60,12 @@ def create_dc_ctc_reform(parameters, period, bypass: bool = False):
return create_dc_ctc()

p = parameters.gov.contrib.states.dc.ctc
reform_active = is_reform_active(p, period)

current_period = period_(period)

for i in range(5):
if p(current_period).in_effect:
return create_dc_ctc()
current_period = current_period.offset(1, "year")
return None
if reform_active:
return create_dc_ctc()
else:
return None


dc_ctc = create_dc_ctc_reform(None, None, bypass=True)
Loading
Loading