Skip to content

Commit

Permalink
Merge pull request #54 from PSLmodels/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
bodiyang authored Oct 7, 2024
2 parents 747956c + af96206 commit ca8eabb
Show file tree
Hide file tree
Showing 32 changed files with 4,151 additions and 1,041 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 @@ -34,7 +34,7 @@ jobs:
shell: bash -l {0}
working-directory: ./
run: |
pytest -m 'not requires_pufcsv and not requires_tmdcsv and not pre_release and not local' --cov=./ --cov-report=xml
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 Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ include taxcalc/policy_current_law.json
include taxcalc/puf_weights.csv.gz
include taxcalc/puf_ratios.csv
include taxcalc/records_variables.json
include taxcalc/tmd_weights.csv.gz
include taxcalc/tmd_growfactors.csv
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ help:
@echo "clean : remove .pyc files and local taxcalc package"
@echo "package : build and install local package"
@echo "pytest-cps : generate report for and cleanup after"
@echo " pytest -m 'not requires_pufcsv and not requires_tmdcsv and not pre_release'"
@echo " pytest -m 'not requires_pufcsv and not pre_release'"
@echo "pytest : generate report for and cleanup after"
@echo " pytest -m 'not pre_release'"
@echo "pytest-all : generate report for and cleanup after"
Expand Down Expand Up @@ -51,7 +51,7 @@ endef
.PHONY=pytest-cps
pytest-cps:
@$(pytest-setup)
@cd taxcalc ; pytest -n4 --disable-warnings --durations=0 --durations-min=2 -m "not requires_pufcsv and not requires_tmdcsv and not pre_release"
@cd taxcalc ; pytest -n4 --disable-warnings --durations=0 --durations-min=2 -m "not requires_pufcsv and not pre_release"
@$(pytest-cleanup)

.PHONY=pytest
Expand Down Expand Up @@ -103,7 +103,7 @@ define coverage-cleanup
rm -f .coverage htmlcov/*
endef

COVMARK = "not requires_pufcsv and not requires_tmdcsv and not pre_release"
COVMARK = "not requires_pufcsv and not pre_release"

OS := $(shell uname -s)

Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ comment:

ignore:
- "setup.py"
- "update_pcl.py"
- "ppp.py"
- "extend_tcja.py"
23 changes: 23 additions & 0 deletions docs/about/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ Release history
Go [here](https://github.com/PSLmodels/Tax-Calculator/pulls?q=is%3Apr+is%3Aclosed)
for a complete commit history.


2024-10-02 Release 4.3.0
------------------------
(last merged pull request is
[#2819](https://github.com/PSLmodels/Tax-Calculator/pull/2819))

**This is an enhancement and bug-fix release.**

**API Changes**

**New Features**
- Add known values of inflation-indexed policy parameters for 2023 [[#2806](https://github.com/PSLmodels/Tax-Calculator/pull/2806) by Martin Holmer]
- Enhance `Records.tmd_constructor` static method [[#2809](https://github.com/PSLmodels/Tax-Calculator/pull/2809) by Martin Holmer]
- Remove TMD data files from Tax-Calculator repository [[#2810](https://github.com/PSLmodels/Tax-Calculator/pull/2810) by Martin Holmer]
- Add known values of inflation-indexed policy parameters for 2024 [[#2816](https://github.com/PSLmodels/Tax-Calculator/pull/2816) by Martin Holmer]
- Enhance `extend_tcja.py` and update `reforms/ext.json` [[#2817](https://github.com/PSLmodels/Tax-Calculator/pull/2817) by Martin Holmer]
- Enhance `ppp.py` script [[#2819](https://github.com/PSLmodels/Tax-Calculator/pull/2819) by Martin Holmer]

**Bug Fixes**
- Fix specification of domestic production deduction under TCJA [[#2807](https://github.com/PSLmodels/Tax-Calculator/pull/2807) by Martin Holmer]
- Fix `ALD_BusinessLosses_c` parameter values after 2025 [[#2818](https://github.com/PSLmodels/Tax-Calculator/pull/2818) by Martin Holmer]


2024-09-14 Release 4.2.2
------------------------
(last merged pull request is
Expand Down
12 changes: 10 additions & 2 deletions docs/contributing/RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Releasing Tax-Caclculator Packages
==================================

The following outlines the process to release Tax-Calculator Packages on Conda-Forge and creating a new branch to fix a bug in a previous release.
The following outlines the process to release Tax-Calculator Packages
on Conda-Forge and creating a new branch to fix a bug in a previous
release.

Create new `taxcalc` packages
===========================
=============================
```
--> on branch X-Y-Z, edit docs/about/releases.md to finalize X.Y.Z info
Expand All @@ -13,6 +15,12 @@ Create new `taxcalc` packages
--> merge master branch into X-Y-Z branch
--> run `python update_pcl.py` [to update policy_current_law.json if needed]
--> run `python ppp.py` [to update policy_current_law.json if needed]
--> run `python extend_tcja.py > ext.json` [to update reforms/ext.json]
--> run `make tctest-jit` [to make sure JIT decorators are not hiding bugs]
--> run `make pytest-all` [or `pytest -m pre_release -n4` in taxcalc subdir]
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.2.2 (2024-09-14) <about/releases>`
{doc}`4.3.0 (2024-10-02) <about/releases>`

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

Expand Down
13 changes: 8 additions & 5 deletions docs/usage/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ file.

The [tax-microdata
repository](https://github.com/PSLmodels/tax-microdata-benchmarking)
produces an input variables file (`tmd.csv`) and a
`tmd_weights.csv.gz` file that is included in the Tax-Calculator
produces an input variables file (`tmd.csv`), a national weights file
(`tmd_weights.csv.gz`), and a variable growth factors file
(`tmd_growfactors.csv`) that can be used with the Tax-Calculator
package beginning with the 3.6.0 release. The `tmd.csv` file is
available only to Tax-Calculator users who have purchased their own
version of the 2015 IRS-SOI PUF. For those users, the
`Records.tmd_constructor()` method creates a `Records` class object
containing the `tmd` variables and weights.
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`.

## Using other data with Tax-Calculator

Expand Down
53 changes: 38 additions & 15 deletions extend_tcja.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
extend_tcja.json, that can serve as an alternative baseline to
current-law policy (which ends TCJA temporary provisions after 2025).
USAGE: (taxcalc-dev) ~% python extend_tcja.py
USAGE: (taxcalc-dev) Tax-Calculator% python extend_tcja.py > ext.json
THEN CHECK: % diff ext.json taxcalc/reforms/ext.json
IF DIFFS: % mv ext.json taxcalc/reforms/ext.json
IMPORTANT NOTE: be sure to remove the trailing comma after the last item
in the reform JSON object generated by this script.
WHEN TO USE: use this script to update reforms/ext.json in these situations:
(a) whenever inflation rates in the growfactors.csv files are changed
OR
(b) whenever inflation-indexed parameters are updated (usually as part
of changes that increase the value of Policy.LAST_KNOWN_YEAR).
"""

import sys
Expand Down Expand Up @@ -76,64 +81,82 @@
"PT_qbid_alt_property_rt": {"indexed": False, "category": 7},
# category 8 ...
"ALD_BusinessLosses_c": {"indexed": True, "category": 8},
"ALD_DomesticProduction_hc": {"indexed": False, "category": 8},
}


def main():
"""
High-level script logic.
"""
# identify last parameter name in TCJA_PARAMETERS
last_pname = list(TCJA_PARAMETERS.keys())[-1]
# calculate 2025-to-2026 parameters indexing factor
pol = taxcalc.Policy()
pirates = pol.inflation_rates()
ifactor = 1.0 + pirates[2025-taxcalc.Policy.JSON_START_YEAR]
ifactor25 = 1.0 + pirates[2025-taxcalc.Policy.JSON_START_YEAR]
ifactor28 = 1.0 + pirates[2028-taxcalc.Policy.JSON_START_YEAR]
# specify extend-TCJA-beyond-2025 reform
# ... get 2025 parameter values
pol.set_year(2025)
pdata = dict(pol.items())
# ... write reform header comments
print( '// REFORM TO EXTEND TEMPORARY TCJA PROVISIONS BEYOND 2025')
print(f'// USING TAX-CALCULATOR {taxcalc.__version__}')
print(f'// WITH 2025-to-2026 INDEXING FACTOR = {ifactor:.6f}')
print(f'// WITH 2025-to-2026 INDEXING FACTOR = {ifactor25:.6f}')
print(f'// AND 2028-to-2029 INDEXING FACTOR = {ifactor28:.6f}')
if TCJA_CATEGORY:
print(f'// ONLY TCJA PROVISIONS IN CATEGORY {TCJA_CATEGORY}')
print('{')
# ... set 2026 nonreverted values for the parameters set to revert
# ... set 2026/29 nonreverted values for the parameters set to revert
left_brace = '{'
right_brace = '}'
year = 2026
for pname, pinfo in TCJA_PARAMETERS.items():
if TCJA_CATEGORY and pinfo['category'] != TCJA_CATEGORY:
continue # skip this parameter
if pname == 'ALD_BusinessLosses_c':
ifactor = ifactor28
year = 2029
pol.set_year(2028)
pdata = dict(pol.items())
else:
if year != 2026:
pol.set_year(2025)
pdata = dict(pol.items())
ifactor = ifactor25
year = 2026
trailing_comma = '' if pname == last_pname else ','
if pinfo['indexed']:
pval = pdata[pname][0] * ifactor
if isinstance(pval, numpy.ndarray):
# handle vector parameter
pval = numpy.minimum(9e99, pval.round(2))
sys.stdout.write(f' "{pname}": ')
sys.stdout.write('{"2026": ')
sys.stdout.write(f'{left_brace}"{year}": ')
sys.stdout.write(f'{pval.tolist()}')
sys.stdout.write('},\n')
sys.stdout.write(f'{right_brace}{trailing_comma}\n')
else:
# handle scalar parameter
pval = min(9e99, pval)
sys.stdout.write(f' "{pname}": ')
sys.stdout.write('{"2026": ')
sys.stdout.write(f'{left_brace}"{year}": ')
sys.stdout.write(f'{pval*ifactor:.2f}')
sys.stdout.write('},\n')
sys.stdout.write(f'{right_brace}{trailing_comma}\n')
else: # if parameter is not indexed
pval = pdata[pname][0]
if isinstance(pval, numpy.ndarray):
# handle vector parameter
pval = numpy.minimum(9e99, pval.round(2))
sys.stdout.write(f' "{pname}": ')
sys.stdout.write('{"2026": ')
sys.stdout.write(f'{left_brace}"{year}": ')
sys.stdout.write(f'{pval.tolist()}')
sys.stdout.write('},\n')
sys.stdout.write(f'{right_brace}{trailing_comma}\n')
else:
# handle scalar parameter
sys.stdout.write(f' "{pname}": ')
sys.stdout.write('{"2026": ')
sys.stdout.write(f'{left_brace}"{year}": ')
sys.stdout.write(f'{pval:.2f}')
sys.stdout.write('},\n')
sys.stdout.write(f'{right_brace}{trailing_comma}\n')
print('}')
return 0
# end main function code
Expand Down
Loading

0 comments on commit ca8eabb

Please sign in to comment.