From 4692e220ef83ec8a59f25b041b79745edf8ae833 Mon Sep 17 00:00:00 2001 From: hdoupe Date: Mon, 11 Nov 2019 15:53:53 -0500 Subject: [PATCH 1/3] Check that CPI_Offset updates do not affect prior years --- taxcalc/tests/test_policy.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/taxcalc/tests/test_policy.py b/taxcalc/tests/test_policy.py index 29ddd35d8..9e3fe1975 100644 --- a/taxcalc/tests/test_policy.py +++ b/taxcalc/tests/test_policy.py @@ -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 + 1], + p2_rates[2022 - start_year + 1] - (-0.005) + ) From 1c64f4a3de8328a549d07787fbaf970d5d288d29 Mon Sep 17 00:00:00 2001 From: hdoupe Date: Mon, 11 Nov 2019 15:58:38 -0500 Subject: [PATCH 2/3] Only apply CPI_Offset in the year it was specified and years following --- taxcalc/parameters.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/taxcalc/parameters.py b/taxcalc/parameters.py index a5b67b3e5..6b5913ee2 100644 --- a/taxcalc/parameters.py +++ b/taxcalc/parameters.py @@ -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 From c48a4b07e8efc4500e0857280e1dc6a7887068b3 Mon Sep 17 00:00:00 2001 From: hdoupe Date: Mon, 11 Nov 2019 16:02:15 -0500 Subject: [PATCH 3/3] Fix one-off error in test --- taxcalc/tests/test_policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/taxcalc/tests/test_policy.py b/taxcalc/tests/test_policy.py index 9e3fe1975..2d0388f29 100644 --- a/taxcalc/tests/test_policy.py +++ b/taxcalc/tests/test_policy.py @@ -1027,6 +1027,6 @@ def test_cpi_offset_affect_on_prior_years(): # Inflation rate in 2022 was updated. np.testing.assert_allclose( - p1_rates[2022 - start_year + 1], - p2_rates[2022 - start_year + 1] - (-0.005) + p1_rates[2022 - start_year], + p2_rates[2022 - start_year] - (-0.005) )