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

Fix for CPI_offset logic #2381

Merged
merged 3 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion taxcalc/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@ def _apply_cpi_offset_in_revision(self, revision):
assert first_cpi_offset_year > 0
# adjust inflation rates
cpi_offset = getattr(self, '_CPI_offset')
for idx in range(0, self.num_years):
first_cpi_offset_ix = first_cpi_offset_year - self.start_year
for idx in range(first_cpi_offset_ix, self.num_years):
infrate = round(self._inflation_rates[idx] + cpi_offset[idx], 6)
self._inflation_rates[idx] = infrate
# revert indexed parameter values to policy_current_law.json values
Expand Down
27 changes: 27 additions & 0 deletions taxcalc/tests/test_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,3 +1003,30 @@ def test_index_offset_reform():
expvalue = round(pvalue2[2020] * (1. + expindexrate), 2)
# ... compare expected value with actual value of pvalue2 for 2021
assert np.allclose([expvalue], [pvalue2[2021]])


def test_cpi_offset_affect_on_prior_years():
"""
Test that CPI_offset does not have affect on inflation
rates in earlier years.
"""
reform = {'CPI_offset': {2022: -0.005}}
p1 = Policy()
p2 = Policy()
p2.implement_reform(reform)

start_year = p1.start_year
p1_rates = np.array(p1.inflation_rates())
p2_rates = np.array(p2.inflation_rates())

# Inflation rates prior to 2022 are the same.
np.testing.assert_allclose(
p1_rates[:2022 - start_year],
p2_rates[:2022 - start_year]
)

# Inflation rate in 2022 was updated.
np.testing.assert_allclose(
p1_rates[2022 - start_year],
p2_rates[2022 - start_year] - (-0.005)
)