Skip to content

Commit

Permalink
Merge pull request #2613 from hdoupe/rm-init-vals
Browse files Browse the repository at this point in the history
Remove parameters code that resets to initial values on update
  • Loading branch information
jdebacker authored Nov 5, 2021
2 parents e3567d1 + 38ebfa5 commit 9054288
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 18 deletions.
17 changes: 0 additions & 17 deletions taxcalc/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ def __init__(self, start_year=None, num_years=None, last_known_year=None,
"year": start_year or self.JSON_START_YEAR
}
super().__init__(**kwargs)
self._init_values = {
param: copy.deepcopy(data["value"])
for param, data in self.read_params(self.defaults).items()
if param != "schema"
}

def adjust(
self, params_or_path, print_warnings=True, raise_errors=True, **kwargs
Expand Down Expand Up @@ -301,7 +296,6 @@ def adjust_with_indexing(self, params_or_path, **kwargs):
] += cpi_vo["value"]
# 1. Delete all unknown values.
# 1.a For revision, these are years specified after cpi_min_year.
init_vals = {}
to_delete = {}
for param in params:
if (
Expand All @@ -312,16 +306,11 @@ def adjust_with_indexing(self, params_or_path, **kwargs):
if param.endswith("-indexed"):
param = param.split("-indexed")[0]
if self._data[param].get("indexed", False):
init_vals[param] = (
self.sel[self._init_values[param]]["year"]
<= cpi_min_year["year"]
)
to_delete[param] = (
self.sel[param]["year"] > cpi_min_year["year"]
)
needs_reset.append(param)
self.delete(to_delete, **kwargs)
super().adjust(init_vals, **kwargs)

# 1.b For all others, these are years after last_known_year.
last_known_year = max(cpi_min_year["year"], self._last_known_year)
Expand Down Expand Up @@ -367,7 +356,6 @@ def adjust_with_indexing(self, params_or_path, **kwargs):
needs_reset.append(param)
super().adjust(long_param_vals, **kwargs)

init_vals = {}
to_delete = {}
for param in self._data:
if (
Expand All @@ -377,15 +365,10 @@ def adjust_with_indexing(self, params_or_path, **kwargs):
):
continue
if self._data[param].get("indexed", False):
init_vals[param] = (
self.sel[self._init_values[param]]['year']
<= last_known_year
)
to_delete[param] = self.sel[param]["_auto"] == True # noqa
needs_reset.append(param)

self.delete(to_delete, **kwargs)
super().adjust(init_vals, **kwargs)

self.extend(label="year")

Expand Down
37 changes: 36 additions & 1 deletion taxcalc/reforms/TCJA.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,40 @@
"2026": 0},
"ID_Medical_frt": {"2017": 0.075,
"2019": 0.075},
"parameter_indexing_CPI_offset": {"2017": -0.0025}
"parameter_indexing_CPI_offset": {"2017": -0.0025},

// Apply parameters that are affected by the change in index rates
// even though they are not directly modified by TCJA.
"II_em_ps": {"2018": [9e99, 9e99, 9e99, 9e99, 9e99]},
"STD_Dep": {"2018": 1050, "2019": 1100},
"STD_Aged": {"2018": [1600, 1300, 1300, 1600, 1300],
"2019": [1650, 1300, 1300, 1650, 1300]},
"CG_brk1": {"2018": [38600, 77200, 38600, 51700, 77200],
"2019": [39375, 78750, 39375, 52750, 78750]},
"CG_brk2": {"2018": [425800, 479000, 239500, 452400, 479000],
"2019": [434550, 488850, 244425, 461700, 488850]},
"AMT_CG_brk1": {"2018": [38600, 77200, 38600, 51700, 77200],
"2019": [39375, 78750, 39375, 52750, 78750]},
"AMT_CG_brk2": {"2018": [425800, 479000, 239500, 452400, 479000],
"2019": [434550, 488850, 244425, 461700, 488850]},
"AMT_child_em": {"2018": 7600,
"2019": 0},
"AMT_brk1": {"2018": 191100,
"2019": 194800},
"EITC_c": {"2018": [519, 3461, 5716, 6431],
"2019": [529, 3526, 5828, 6557]},
"EITC_ps": {"2018": [8490, 18660, 18660, 18660],
"2019": [8650, 19030, 19030, 19030]},
"EITC_ps_MarriedJ": {"2018": [5680, 5690, 5690, 5690],
"2019": [5800, 5790, 5790, 5790]},
"EITC_InvestIncome_c": {"2018": 3500,
"2019": 3600},
"ETC_pe_Single": {"2018": 67,
"2019": 68},
"ETC_pe_Married": {"2018": 134,
"2019": 136},
"FST_AGI_thd_lo": {"2018": [1000000, 1000000, 500000, 1000000, 1000000],
"2019": [1000000, 1000000, 500000, 1000000, 1000000]},
"FST_AGI_thd_hi": {"2018": [2000000, 2000000, 1000000, 2000000, 2000000],
"2019": [2000000, 2000000, 1000000, 2000000, 2000000]}
}
4 changes: 4 additions & 0 deletions taxcalc/tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def update_params(self, revision,

# test Params class
prms = Params()

with pytest.raises(NotImplementedError):
prms.set_rates()

if revision == {}:
assert isinstance(prms, Params)
assert prms.start_year == 2001
Expand Down
26 changes: 26 additions & 0 deletions taxcalc/tests/test_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,3 +1517,29 @@ def test_indexed_status_parsing(self):

with pytest.raises(pt.ValidationError):
pol2.adjust({"EITC_c-indexed": 123})

def test_cpi_offset_does_not_affect_wage_indexed_params(self):
"""
Test adjusting parameter_indexing_CPI_offset does not affect unknown
values of wage indexed parameters like SS_Earnings_c.
"""
base_reform = {
"parameter_indexing_CPI_offset": {2021: -0.001},
"SS_Earnings_c": {2024: 300000},
}

pol0 = Policy()
pol0.implement_reform(base_reform)

pol1 = Policy()
pol1.implement_reform(base_reform)
pol1.implement_reform(dict(base_reform, SS_Earnings_c={2025: 500000}))

exp_before_2025 = pol0.to_array(
"SS_Earnings_c", year=list(range(2021, 2024 + 1))
)
act_before_2025 = pol1.to_array(
"SS_Earnings_c", year=list(range(2021, 2024 + 1))
)

np.testing.assert_equal(act_before_2025, exp_before_2025)

0 comments on commit 9054288

Please sign in to comment.