Skip to content

Commit

Permalink
Merge in recent changes on master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Dec 16, 2024
2 parents 0b14676 + 57e0f62 commit 9d344c0
Show file tree
Hide file tree
Showing 34 changed files with 414 additions and 428 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Build
shell: bash -l {0}
run: |
pip install -e .
pip install -e . --user
pip install pytest-cov --user
pip install pytest-pycodestyle --user
Expand Down
25 changes: 25 additions & 0 deletions docs/about/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ Go [here](https://github.com/PSLmodels/Tax-Calculator/pulls?q=is%3Apr+is%3Aclose
for a complete commit history.


2024-12-16 Release 4.3.5
------------------------
(last merged pull request is
[#2854](https://github.com/PSLmodels/Tax-Calculator/pull/2854))

**This is a minor enhancement and bug-fix release.**

**API Changes**

**New Features**
- Update PUF and CPS input data using CBO June 2024 baseline projection
[[#2831](https://github.com/PSLmodels/Tax-Calculator/pull/2831) by Bodi Yang]
- Generalize tmd_constructor in both Records and Policy classes
[[#2850](https://github.com/PSLmodels/Tax-Calculator/pull/2850) by Martin Holmer]
- Add changes that should have been included in PR #2831
[[#2854](https://github.com/PSLmodels/Tax-Calculator/pull/2854) by Martin Holmer]

**Bug Fixes**
- Fix several broken documentation links
[[#2847](https://github.com/PSLmodels/Tax-Calculator/pull/2847) by Martin Holmer] and
[[#2849](https://github.com/PSLmodels/Tax-Calculator/pull/2849) by Martin Holmer]
- Remove incorrect use of GrowFactors() in Policy and Parameters classes
[[#2852](https://github.com/PSLmodels/Tax-Calculator/pull/2852) by Martin Holmer]


2024-11-30 Release 4.3.4
------------------------
(last merged pull request is
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The cross-model validation work with NBER's TAXSIM-27 model is described

## Latest release

{doc}`4.3.4 (2024-11-30) <about/releases>`
{doc}`4.3.5 (2024-12-16) <about/releases>`

If you are already using Tax-Calculator, upgrade using the following command:

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
with open("README.md") as f:
longdesc = f.read()

version = "4.3.4"
version = "4.3.5"

config = {
"description": "Tax Calculator",
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
from taxcalc.utils import *
from taxcalc.cli import *

__version__ = '4.3.4'
__version__ = '4.3.5'
__min_python3_version__ = 10
__max_python3_version__ = 12
2 changes: 1 addition & 1 deletion taxcalc/assumptions/economic_assumptions_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// about how individuals and the overall economy respond to a tax reform.
//
// Detailed documentation on these parameters can be found at
// <http://PSLmodels.github.io/Tax-Calculator/#params>.
// <https://taxcalc.pslmodels.org/guide/assumption_params.html>.
{
"consumption": {
"MPC_e17500": {"2017": 0.0},
Expand Down
10 changes: 7 additions & 3 deletions taxcalc/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ def read_json_param_objects(reform, assump):
return param_dict

@staticmethod
def reform_documentation(params, policy_dicts=None):
def reform_documentation(params, growfactors, policy_dicts=None):
"""
Generate reform documentation versus current-law policy.
Expand All @@ -1120,6 +1120,9 @@ def reform_documentation(params, policy_dicts=None):
dictionary is structured like dict returned from
the static Calculator.read_json_param_objects() method
growfactors: GrowFactors
GrowFactors object used to construct Calculator Policy object
policy_dicts : list of dict or None
each dictionary in list is a params['policy'] dictionary
representing second and subsequent elements of a compound
Expand Down Expand Up @@ -1255,13 +1258,14 @@ def lines(text, num_indent_spaces, max_line_length=77):
# create Policy object with current-law-policy values
gdiff_base = GrowDiff()
gdiff_base.update_growdiff(params['growdiff_baseline'])
gfactors_clp = GrowFactors()
assert isinstance(growfactors, GrowFactors)
gfactors_clp = copy.deepcopy(growfactors)
gdiff_base.apply_to(gfactors_clp)
clp = Policy(gfactors=gfactors_clp)
# create Policy object with post-reform values
gdiff_resp = GrowDiff()
gdiff_resp.update_growdiff(params['growdiff_response'])
gfactors_ref = GrowFactors()
gfactors_ref = copy.deepcopy(growfactors)
gdiff_base.apply_to(gfactors_ref)
gdiff_resp.apply_to(gfactors_ref)
ref = Policy(gfactors=gfactors_ref)
Expand Down
Binary file modified taxcalc/cps_weights.csv.gz
Binary file not shown.
90 changes: 25 additions & 65 deletions taxcalc/growfactors.csv

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions taxcalc/parameters.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import copy
import os
import re
import copy
from collections import defaultdict
from typing import Union, Mapping, Any, List

import marshmallow as ma
import paramtools as pt
import numpy as np
import requests

import taxcalc
from taxcalc.growfactors import GrowFactors


Expand Down Expand Up @@ -249,7 +246,6 @@ def adjust_with_indexing(self, params_or_path, **kwargs):
label_to_extend = self.label_to_extend
array_first = self.array_first
self.array_first = False
self._gfactors = GrowFactors()

params = self.read_params(params_or_path)

Expand Down Expand Up @@ -508,12 +504,14 @@ def set_rates(self):

def wage_growth_rates(self, year=None):
if year is not None:
return self._wage_growth_rates[year - self.start_year]
syr = max(self.start_year, self._gfactors.first_year)
return self._wage_growth_rates[year - syr]
return self._wage_growth_rates or []

def inflation_rates(self, year=None):
if year is not None:
return self._inflation_rates[year - self.start_year]
syr = max(self.start_year, self._gfactors.first_year)
return self._inflation_rates[year - syr]
return self._inflation_rates or []

# alias methods below
Expand Down
48 changes: 18 additions & 30 deletions taxcalc/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
import json
from pathlib import Path
import numpy as np
from taxcalc.parameters import Parameters
from taxcalc.growfactors import GrowFactors

Expand Down Expand Up @@ -53,7 +52,7 @@ class instance: Policy
'DependentCredit_before_CTC': 'is a removed parameter name',
'FilerCredit_c': 'is a removed parameter name',
'ALD_InvInc_ec_base_RyanBrady': 'is a removed parameter name',
# TODO: following parameter renamed in PR 2292 merged on 2019-04-15
# following parameter renamed in PR 2292 merged on 2019-04-15
"cpi_offset": (
"was renamed parameter_indexing_CPI_offset. "
"See documentation for change in usage."
Expand All @@ -62,7 +61,7 @@ class instance: Policy
"was renamed parameter_indexing_CPI_offset. "
"See documentation for change in usage."
),
# TODO: following parameters renamed in PR 2345 merged on 2019-06-24
# following parameters renamed in PR 2345 merged on 2019-06-24
'PT_excl_rt':
'was renamed PT_qbid_rt in release 2.4.0',
'PT_excl_wagelim_thd':
Expand Down Expand Up @@ -102,17 +101,18 @@ def __init__(self, gfactors=None, **kwargs):
Policy.WAGE_INDEXED_PARAMS, **kwargs)

@staticmethod
def tmd_constructor(growfactors_path): # pragma: no cover
def tmd_constructor(growfactors: Path | GrowFactors): # pragma: no cover
"""
Static method returns a Policy object instantiated with TMD
input data. This convenience method works in a analogous way
to Policy(), which returns a Policy object instantiated with
non-TMD input data.
"""
assert isinstance(growfactors_path, Path)
gf_filename = str(growfactors_path)
tmd_growfactors = GrowFactors(growfactors_filename=gf_filename)
return Policy(gfactors=tmd_growfactors)
if isinstance(growfactors, Path):
growfactors = GrowFactors(growfactors_filename=str(growfactors))
else:
assert isinstance(growfactors, GrowFactors)
return Policy(gfactors=growfactors)

@staticmethod
def read_json_reform(obj):
Expand Down Expand Up @@ -147,32 +147,20 @@ def parameter_list():
return [k for k in defaults if k != "schema"]

def set_rates(self):
"""Initialize taxcalc indexing data."""
"""
Initialize policy parameter indexing rates.
"""
cpi_vals = [
vo["value"] for
vo in self._data["parameter_indexing_CPI_offset"]["value"]
]
# extend parameter_indexing_CPI_offset values through budget window
# if they have not been extended already.
cpi_vals = cpi_vals + cpi_vals[-1:] * (
self.end_year - self.start_year + 1 - len(cpi_vals)
# policy_current_law.json should not specify any non-zero values
# for the parameter_indexing_CPI_offset parameter, so check this
assert any(cpi_vals) is False
syr = max(self.start_year, self._gfactors.first_year)
self._inflation_rates = self._gfactors.price_inflation_rates(
syr, self.end_year
)
cpi_offset = {
(self.start_year + ix): val
for ix, val in enumerate(cpi_vals)
}

self._gfactors = GrowFactors()

self._inflation_rates = [
np.round(rate + cpi_offset[self.start_year + ix], 4)
for ix, rate in enumerate(
self._gfactors.price_inflation_rates(
self.start_year, self.end_year
)
)
]

self._wage_growth_rates = self._gfactors.wage_growth_rates(
self.start_year, self.end_year
syr, self.end_year
)
Loading

0 comments on commit 9d344c0

Please sign in to comment.