Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodi Yang committed Nov 18, 2024
2 parents ddb5eda + b3bca61 commit 260fe6c
Show file tree
Hide file tree
Showing 23 changed files with 1,604 additions and 105 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ jobs:
- name: Build
shell: bash -l {0}
run: |
pip install -e . --user
pip install -e . --user --config-settings editable_mode=compat
pip install pytest-cov --user
pip install pytest-pycodestyle --user
- name: Test
shell: bash -l {0}
working-directory: ./
run: |
pytest -m 'not requires_pufcsv and not pre_release and not local' --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'PSLmodels/Tax-Calculator')
uses: codecov/codecov-action@v4
Expand All @@ -43,5 +45,6 @@ jobs:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
#fail_ci_if_error: true
fail_ci_if_error: false
verbose: true
2 changes: 1 addition & 1 deletion .github/workflows/check_jupyterbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: |
pip install jupyter-book
conda install -c pslmodels behresp
pip install -e .
pip install -e . --config-settings editable_mode=compat
python docs/guide/make/make_uguide.py
cd docs
jb build .
2 changes: 1 addition & 1 deletion .github/workflows/deploy_jupyterbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
pip install jupyter-book
conda install -c pslmodels behresp
pip install -e .
pip install -e . --config-settings editable_mode=compat
cd docs
jb build .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_parameters_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
pip install jupyter-book
conda install -c pslmodels behresp
pip install -e .
pip install -e . --config-settings editable_mode=compat
python docs/guide/make/make_uguide.py
cd docs
jb build .
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ clean:

.PHONY=package
package:
@pip install -e .
@pip install -e . --config-settings editable_mode=compat

define pytest-setup
rm -f taxcalc/tests/reforms_actual_init
Expand Down
36 changes: 36 additions & 0 deletions docs/about/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,42 @@ Go [here](https://github.com/PSLmodels/Tax-Calculator/pulls?q=is%3Apr+is%3Aclose
for a complete commit history.


2024-11-14 Release 4.3.3
------------------------
(last merged pull request is
[#2837](https://github.com/PSLmodels/Tax-Calculator/pull/2837))

**This is a minor enhancement release.**

**API Changes**

**New Features**
- Clarify TCJA-after-2025 documentation
[[#2836](https://github.com/PSLmodels/Tax-Calculator/pull/2836) by Martin Holmer]
- Add known values of 2025 policy parameters
[[#2837](https://github.com/PSLmodels/Tax-Calculator/pull/2837) by Martin Holmer]


2024-11-08 Release 4.3.2
------------------------
(last merged pull request is
[#2834](https://github.com/PSLmodels/Tax-Calculator/pull/2834))

**This is a bug-fix release.**

**API Changes**

**New Features**
- Add Policy.tmd_constructor() static method for convenience when using Python API
[[#2834](https://github.com/PSLmodels/Tax-Calculator/pull/2834) by Martin Holmer]

**Bug Fixes**
- Fix handling of tmd_growfactors.csv file
[[#2832](https://github.com/PSLmodels/Tax-Calculator/pull/2832) by Martin Holmer]
- Fix `tc` reform documentation output
[[#2833](https://github.com/PSLmodels/Tax-Calculator/pull/2833) by Martin Holmer]


2024-10-28 Release 4.3.1
------------------------
(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.1 (2024-10-28) <about/releases>`
{doc}`4.3.3 (2024-11-14) <about/releases>`

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

Expand Down
4 changes: 2 additions & 2 deletions docs/usage/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ available only to Tax-Calculator users who have purchased their own
version of the 2015 IRS-SOI PUF. For those users, those three files
are avaiable from the tax-microdata repository. These three tmd files
can be used with the Tax-Calculator Python API (using the
`Records.tmd_constructor()` static method) or with the Tax-Calculator
CLI tool, `tc`.
`Records.tmd_constructor()` and `Policy.tmd_constructor()`static methods)
or with the Tax-Calculator CLI tool, `tc`.

## Using other data with Tax-Calculator

Expand Down
15 changes: 2 additions & 13 deletions docs/usage/tcja_after_2025.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,12 @@ To analyze your reform relative to a reform that extends all TCJA
temporary provisions beyond 2025, you would execute this command:

```
tc z.csv 2026 --exact --tables --baseline ext.json --reform x.json
tc z.csv 2026 --exact --tables --baseline ext.json --reform ext.json+x.json
```

The tables would be in the `z-26-ext-x-#-tab.text` output file
The tables would be in the `z-26-ext-ext+x-#-tab.text` output file
generated by this `tc` run.

Also, remember that you can simulate a _compound reform_ using the
following syntax:

```
tc z.csv 2026 --exact --tables --baseline ext.json --reform x.json+y.json
```

where `y.json` contains a reform with additional provisions not
included in your `x.json` reform file. The resulting table output
would be in a file named `z-26-ext-x+y-#-tab.text`.

And finally, you might consider creating a reform file called
`end.json` that contains just the two characters `{}`. This is a null
reform, which is equivalent to current-law policy, that could be used
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.1"
version = "4.3.3"

config = {
"description": "Tax Calculator",
Expand Down
2 changes: 1 addition & 1 deletion taxcalc.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: taxcalc
Version: 4.3.0
Version: 4.3.3
Summary: taxcalc
Home-page: https://github.com/PSLmodels/Tax-Calculator
Download-URL: https://github.com/PSLmodels/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.1'
__version__ = '4.3.3'
__min_python3_version__ = 10
__max_python3_version__ = 12
12 changes: 6 additions & 6 deletions taxcalc/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ def mtr(self, variable_str='e00200p',
self.policy_param('FICA_ss_trt_employee') +
self.policy_param('FICA_mc_trt_employer') +
self.policy_param('FICA_mc_trt_employee')),
0.5 * (self.policy_param('FICA_mc_trt_employer') + self.policy_param('FICA_mc_trt_employee')))
0.5 * (self.policy_param('FICA_mc_trt_employer') +
self.policy_param('FICA_mc_trt_employee')))
else:
adj = 0.0
# compute marginal tax rates
Expand Down Expand Up @@ -1189,11 +1190,10 @@ def lines(text, num_indent_spaces, max_line_length=77):
for pname in baseline.keys():
upda_value = getattr(updated, pname)
base_value = getattr(baseline, pname)
is_array = isinstance(upda_value, np.ndarray)
if (
(isinstance(upda_value, np.ndarray) and
np.allclose(upda_value, base_value)) or
(not isinstance(upda_value, np.ndarray) and
upda_value != base_value)
(is_array and not np.allclose(upda_value, base_value))
or (is_array == False and upda_value != base_value)
):
params_with_diff.append(pname)
if params_with_diff:
Expand Down Expand Up @@ -1248,7 +1248,7 @@ def lines(text, num_indent_spaces, max_line_length=77):
else: # if baseline is GrowDiff object
# each GrowDiff parameter has zero as default value
doc += ' baseline_value: 0.0\n'
del mdata_base
del mdata_base
return doc

# begin main logic of reform_documentation
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/growfactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class instance: GrowFactors
which is for use with puf and cps data from the taxdata repository.
"""

PACKAGE_FILE_NAMES = ['growfactors.csv', 'tmd_growfactors.csv']
PACKAGE_FILE_NAMES = ['growfactors.csv']
FILE_PATH = os.path.abspath(os.path.dirname(__file__))

VALID_NAMES = set(['ABOOK', 'ACGNS', 'ACPIM', 'ACPIU',
Expand Down
21 changes: 17 additions & 4 deletions taxcalc/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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 @@ -37,7 +38,7 @@ class instance: Policy
DEFAULTS_FILE_NAME = 'policy_current_law.json'
DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__))
JSON_START_YEAR = 2013 # remains the same unless earlier data added
LAST_KNOWN_YEAR = 2024 # last year for which indexed param vals are known
LAST_KNOWN_YEAR = 2025 # last year for which indexed param vals are known
# should increase LAST_KNOWN_YEAR by one every calendar year
LAST_BUDGET_YEAR = 2034 # last extrapolation year
# should increase LAST_BUDGET_YEAR by one every calendar year
Expand Down Expand Up @@ -80,7 +81,7 @@ class instance: Policy
# (3) specify which Policy parameters are wage (rather than price) indexed
WAGE_INDEXED_PARAMS = ['SS_Earnings_c', 'SS_Earnings_thd']

def __init__(self, gfactors=None, only_reading_defaults=False, **kwargs):
def __init__(self, gfactors=None, **kwargs):
# put JSON contents of DEFAULTS_FILE_NAME into self._vals dictionary
super().__init__()
# handle gfactors argument
Expand All @@ -92,7 +93,6 @@ def __init__(self, gfactors=None, only_reading_defaults=False, **kwargs):
raise ValueError('gfactors is not None or a GrowFactors instance')
# read default parameters and initialize
syr = Policy.JSON_START_YEAR
lyr = Policy.LAST_BUDGET_YEAR
nyrs = Policy.DEFAULT_NUM_YEARS
self._inflation_rates = None
self._wage_growth_rates = None
Expand All @@ -101,6 +101,19 @@ def __init__(self, gfactors=None, only_reading_defaults=False, **kwargs):
Policy.REDEFINED_PARAMS,
Policy.WAGE_INDEXED_PARAMS, **kwargs)

@staticmethod
def tmd_constructor(growfactors_path): # 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)

@staticmethod
def read_json_reform(obj):
"""
Expand Down Expand Up @@ -129,7 +142,7 @@ def parameter_list():
Policy.DEFAULTS_FILE_PATH,
Policy.DEFAULTS_FILE_NAME
)
with open(path) as f:
with open(path, 'r', encoding='utf-8') as f:
defaults = json.loads(f.read()) # pylint: disable=protected-access
return [k for k in defaults if k != "schema"]

Expand Down
Loading

0 comments on commit 260fe6c

Please sign in to comment.