Skip to content

Commit

Permalink
Merge pull request #2381 from hdoupe/cpi-offset-fix
Browse files Browse the repository at this point in the history
Fix for CPI_offset logic
  • Loading branch information
MattHJensen authored Nov 12, 2019
2 parents 05702c0 + c48a4b0 commit 7d1b24f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
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)
)

0 comments on commit 7d1b24f

Please sign in to comment.