diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index f833617e3..1068c8e99 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -1,4 +1,4 @@ -name: Build Package and Test Source Code [Python 3.9, 3.10, 2.11] +name: Build Package and Test Source Code [Python 3.9, 3.10, 3.11] on: [push, pull_request] @@ -34,7 +34,7 @@ jobs: shell: bash -l {0} working-directory: ./ run: | - pytest -m 'not requires_pufcsv and not pre_release and not local' --cov=./ --cov-report=xml + pytest -m 'not requires_pufcsv and not requires_tmdcsv and not pre_release and not local' --cov=./ --cov-report=xml - name: Upload coverage to Codecov if: matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@v4 diff --git a/.github/workflows/build_new_test_benchmark.yml b/.github/workflows/build_new_test_benchmark.yml deleted file mode 100644 index 4d2b5032f..000000000 --- a/.github/workflows/build_new_test_benchmark.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Build and commit new test statistics benchmark file - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@master - - - name: Setup Miniconda using Python - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: taxcalc-dev - environment-file: environment.yml - python-version: 3.11 - auto-activate-base: false - - - name: Build - shell: bash -l {0} - run: | - pip install -e . - pip install pytest-cov - pip install pytest-pycodestyle - - - name: Test - shell: bash -l {0} - working-directory: ./ - run: | - pytest -m 'not requires_pufcsv and not pre_release and not local' - - - name: Commit new test stats benchmark - shell: bash -l {0} - working-directory: ./taxcalc/tests - run: | - rm test_stats_benchmark.csv - mv test_stats_current.csv test_stats_benchmark.csv - - git config user.name github-actions - git config user.email github-actions@github.com - - git add test_stats_benchmark.csv - git commit -m "Update test benchmark $(date +'%Y-%m-%d')" - git push diff --git a/.gitignore b/.gitignore index 45f57b368..bb66a294b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ read-the-docs/_build/ # IRS-SOI PUF data file puf.csv +tmd.csv # Jupyter notebook checkpoints *.ipynb_checkpoints* diff --git a/MANIFEST.in b/MANIFEST.in index 7f3a045b8..881f00830 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,4 +7,4 @@ 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 diff --git a/Makefile b/Makefile index 76ab75647..2d9abe0bd 100644 --- a/Makefile +++ b/Makefile @@ -51,19 +51,19 @@ endef .PHONY=pytest-cps pytest-cps: @$(pytest-setup) - @cd taxcalc ; pytest -n4 --disable-warnings -m "not requires_pufcsv and not pre_release" + @cd taxcalc ; pytest -n4 --disable-warnings --durations=0 --durations-min=2 -m "not requires_pufcsv and not requires_tmdcsv and not pre_release" @$(pytest-cleanup) .PHONY=pytest pytest: @$(pytest-setup) - @cd taxcalc ; pytest -n4 -m "not pre_release" + @cd taxcalc ; pytest -n4 --disable-warnings --durations=0 --durations-min=2 -m "not pre_release" @$(pytest-cleanup) .PHONY=pytest-all pytest-all: @$(pytest-setup) - @cd taxcalc ; pytest -n4 -m "" + @cd taxcalc ; pytest -n4 --disable-warnings --durations=0 --durations-min=2 -m "" @$(pytest-cleanup) define tctest-cleanup @@ -103,7 +103,7 @@ define coverage-cleanup rm -f .coverage htmlcov/* endef -COVMARK = "not requires_pufcsv and not pre_release" +COVMARK = "not requires_pufcsv and not requires_tmdcsv and not pre_release" OS := $(shell uname -s) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index 9f6d8f8cc..0add1689d 100755 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -8,10 +8,10 @@ build: requirements: build: - - "python<3.12" - - "numpy>=1.14" - - "pandas>=1.2.0" - - "bokeh>=1.4.0, <3.0.0" + - "python>=3.9, <3.12" + - "numpy>=1.20, <2.0" + - "pandas>=2.0, <3.0" + - "bokeh>=1.4, <3.0" - requests - numba - "paramtools>=0.18.0" @@ -21,10 +21,10 @@ requirements: - openpyxl run: - - "python<3.12" - - "numpy>=1.14" - - "pandas>=1.2.0" - - "bokeh>=1.4.0, <3.0.0" + - "python>=3.9, <3.12" + - "numpy>=1.20, <2.0" + - "pandas>=2.0, <3.0" + - "bokeh>=1.4, <3.0" - requests - numba - "paramtools>=0.18.0" diff --git a/docs/usage/tcja_after_2025.md b/docs/usage/tcja_after_2025.md index 153530b9a..0c29e4ce9 100644 --- a/docs/usage/tcja_after_2025.md +++ b/docs/usage/tcja_after_2025.md @@ -26,7 +26,7 @@ expire). Compatible input datasets include: [taxdata](https://github.com/PSLmodels/taxdata) repository and available only to those with access to the 2011 IRS/SOI PUF -* several newer CSV-formatted input files created in the PSLmodels +* the newer `tmd.csv` file generated in the PSLmodels [tax-microdata](https://github.com/PSLmodels/tax-microdata-benchmarking) repository that are based on the 2015 IRS/SOI PUF and on more recent CPS data, and are available only to those with access to the 2015 diff --git a/environment.yml b/environment.yml index 19dc1a14d..daff46ba7 100644 --- a/environment.yml +++ b/environment.yml @@ -2,25 +2,23 @@ name: taxcalc-dev channels: - conda-forge dependencies: -- "python<3.12" -- curl -- "numpy>=1.14" -- "pandas>=1.2.0" -- "bokeh>=1.4.0, <3.0.0" +- "python>=3.9, <3.12" +- "numpy>=1.20, <2.0" +- "pandas>=2.0, <3.0" +- "bokeh>=1.4, <3.0" - requests -- aiohttp - numba +- "paramtools>=0.18.0" - "fsspec<=0.8.7" +- aiohttp +- curl - pytest -- pytest-pep8 - pytest-xdist - pycodestyle - pylint - coverage -- "paramtools>=0.18.0" - behresp - openpyxl - pip - pip: - jupyter-book - - pytest_harvest diff --git a/pytest.ini b/pytest.ini index ee526e3b5..f40bfdba7 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,9 +3,14 @@ testpaths = taxcalc markers = requires_pufcsv + requires_tmdcsv pre_release - local compatible_data + local benefits itmded_vars - pep8 + cpscsv_agg + pufcsv_agg + reforms + rtr + extend_tcja diff --git a/taxcalc.egg-info/SOURCES.txt b/taxcalc.egg-info/SOURCES.txt index 7c9f694e2..b2bac2eb9 100644 --- a/taxcalc.egg-info/SOURCES.txt +++ b/taxcalc.egg-info/SOURCES.txt @@ -24,6 +24,7 @@ taxcalc/puf_weights.csv.gz taxcalc/records.py taxcalc/records_variables.json taxcalc/taxcalcio.py +taxcalc/tmd_weights.csv.gz taxcalc/utils.py taxcalc/utilsprvt.py taxcalc.egg-info/PKG-INFO diff --git a/taxcalc/cli/tc.py b/taxcalc/cli/tc.py index 3c123d4aa..66873f3e6 100644 --- a/taxcalc/cli/tc.py +++ b/taxcalc/cli/tc.py @@ -153,7 +153,11 @@ def cli_tc_main(): sys.stderr.write(tcio.errmsg) sys.stderr.write('USAGE: tc --help\n') return 1 - aging = inputfn.endswith('puf.csv') or inputfn.endswith('cps.csv') + aging = ( + inputfn.endswith('puf.csv') or + inputfn.endswith('cps.csv') or + inputfn.endswith('tmd.csv') + ) tcio.init(input_data=inputfn, tax_year=taxyear, baseline=args.baseline, reform=args.reform, assump=args.assump, diff --git a/taxcalc/consumption.json b/taxcalc/consumption.json index 2c2214e02..1b0e4d8e9 100644 --- a/taxcalc/consumption.json +++ b/taxcalc/consumption.json @@ -282,4 +282,4 @@ } } } -} \ No newline at end of file +} diff --git a/taxcalc/data.py b/taxcalc/data.py index 556ce2643..d2d70c382 100644 --- a/taxcalc/data.py +++ b/taxcalc/data.py @@ -276,6 +276,6 @@ def _read_weights(self, weights): def _extrapolate(self, year): """ - Apply to dats variables the growth factor values for specified year. + Apply to data variables the growth factor values for specified year. """ # Override this empty method in subclass diff --git a/taxcalc/growdiff.json b/taxcalc/growdiff.json index 453a38cb5..c8b09ef2a 100644 --- a/taxcalc/growdiff.json +++ b/taxcalc/growdiff.json @@ -500,4 +500,4 @@ } } } -} \ No newline at end of file +} diff --git a/taxcalc/growdiff.py b/taxcalc/growdiff.py index 959bdb8a7..e4cc4ac9e 100644 --- a/taxcalc/growdiff.py +++ b/taxcalc/growdiff.py @@ -7,6 +7,7 @@ import os import numpy as np from taxcalc.parameters import Parameters +from taxcalc.policy import Policy from taxcalc.growfactors import GrowFactors @@ -26,8 +27,8 @@ class GrowDiff(Parameters): class instance: GrowDiff """ - JSON_START_YEAR = 2013 # must be same as Policy.JSON_START_YEAR - DEFAULT_NUM_YEARS = 22 # must be same as Policy.DEFAULT_NUM_YEARS + JSON_START_YEAR = Policy.JSON_START_YEAR + DEFAULT_NUM_YEARS = Policy.DEFAULT_NUM_YEARS DEFAULTS_FILE_NAME = 'growdiff.json' DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__)) @@ -75,8 +76,13 @@ def apply_to(self, growfactors): """ assert isinstance(growfactors, GrowFactors) for gfvn in GrowFactors.VALID_NAMES: - _gfvn = '_{}'.format(gfvn) + _gfvn = f'_{gfvn}' for i in range(0, self.num_years): cyr = i + self.start_year diff_array = getattr(self, _gfvn) growfactors.update(gfvn, cyr, diff_array[i]) + + def set_rates(self): + """ + Unimplemented base class method that is not used here. + """ diff --git a/taxcalc/growfactors.csv b/taxcalc/growfactors.csv index 5a64b31e5..4f3c025e5 100644 --- a/taxcalc/growfactors.csv +++ b/taxcalc/growfactors.csv @@ -1,25 +1,65 @@ -YEAR,ATXPY,ASCHF,ABOOK,ACPIU,ACPIM,AWAGE,ASCHCI,ASCHCL,ASCHEI,ASCHEL,AINTS,ADIVS,ACGNS,ASOCSEC,AUCOMP,AIPD,ABENOTHER,ABENMCARE,ABENMCAID,ABENSSI,ABENSNAP,ABENWIC,ABENHOUSING,ABENTANF,ABENVET -2011,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 -2012,1.043862,0.950283,1.104992,1.0209,1.0365,1.032649,1.049023,0.956138,1.165922,0.926962,0.923588,1.327776,1.58966,1.02827,0.7711,0.9231,0.992359,1,1,1,1,1,1,1,1 -2013,1.012518,1.142179,1.033784,1.014791,1.024602,1.019984,0.99505,1.050098,0.997245,1.013128,0.893658,0.819381,0.776217,1.014786,0.728829,0.896219,0.992515,1,1,1,1,1,1,1,1 -2014,1.029476,0.931683,0.976566,1.015927,1.023917,1.039999,1.040616,1.030349,1.075978,0.991321,0.925886,1.17606,1.387522,1.004801,0.641103,0.970506,0.99257,1,1,1,1,1,1,1,1 -2015,1.043858,0.508206,0.999544,1.001235,1.026485,1.024119,1.038052,1.040061,1.04481,1.057257,1.013311,1.013846,1.004308,1.017188,0.81793,0.988666,1.053858,1.023325,1.041528,1.019361,1.102667,1.007792,1.026748,1.132657,1.04693 -2016,1.021978,1.071198,0.984833,1.012621,1.037807,1.006659,0.984484,1.005593,0.982695,0.983807,0.999649,0.968237,0.881651,0.991403,0.933831,1.001764,1.097065,1.011695,1.010367,0.993375,0.989722,1.002577,1.01625,0.828168,1.105413 -2017,1.049373,0.907035,1.018491,1.01677,1.025035,1.040577,1.060677,1.132498,1.093477,1.160123,1.088642,1.102389,1.344721,1.00723,0.94186,1.029301,1.011911,1.030968,1.014601,0.981621,1,0.998715,1.063959,1,1 -2018,1.042394,0.976786,1.074059,1.02,1.019707,1.041821,1.042769,1.042713,1.074048,1.074033,1.031272,1.076804,1.074755,1.018778,0.92284,1.050825,1.103035,1.045097,1.045897,1.005738,1,1.002574,1.034828,1,1 -2019,1.032351,0.979401,1.019085,1.01341,1.028328,1.039292,1.004274,1.004387,1.019131,1.019122,1.014806,1.041751,0.925878,1.031182,0.940635,1.040577,1.054052,1.052158,1.045866,1.000751,1,1.002567,1.034809,1,1 -2020,1.067957,1.167938,0.947032,1.00799,1.041121,1.006381,1.016054,1.015991,0.947016,0.94708,0.989319,1.091767,1.292516,1.023383,1.034222,1.076313,0.996727,1.050763,1.046106,1.00255,1,1.003841,1.034974,1,1 -2021,1.065517,1.126248,1.216697,1.04269,1.012343,1.079707,1.057058,1.05708,1.216716,1.216644,0.999214,1.057982,1.792117,1.011965,8.619252,1.073809,1.03007,1.047248,1.047927,1.001796,1,1.002551,1.034869,1,1 -2022,1.014347,1.742914,1.047552,1.07229,1.040311,1.076282,1.022527,1.022546,1.047553,1.047566,1.049118,1.042358,0.631565,1.04749,0.152665,1.022138,1.030159,1.048769,1.047573,0.999851,1,1.002545,1.034942,1,1 -2023,1.050108,0.653145,1.091056,1.05402,1.004761,1.050035,1.013156,1.013121,1.091037,1.091047,1.026196,1.126711,1.0525,1.085497,0.748857,1.058072,1.030193,1.050822,1.048715,1.000448,1,1.003807,1.034968,1,1 -2024,1.046242,0.895528,1.007166,1.0255,1.01407,1.040377,1.0397,1.03963,1.007187,1.007157,1.156028,1.023049,0.932271,1.052921,1.337549,1.054081,1.030334,1.048426,1.051767,0.99776,1,1.002528,1.034951,1,1 -2025,1.040442,0.963117,1.020457,1.02198,0.958663,1.038977,1.037682,1.037745,1.020415,1.020444,1.091746,1.02538,0.97747,1.031721,1.154874,1.047914,1.030635,1.046248,1.052213,1.002245,1,1.003783,1.034897,1,1 -2026,1.039294,0.987094,1.014705,1.02074,1.014023,1.035978,1.037783,1.037762,1.014711,1.014716,1.098184,1.019802,0.970235,1.030992,1.035291,1.046856,1.030633,1.072236,1,0.999552,1,1.002513,1.034808,1,1 -2027,1.037119,0.998822,1.017535,1.01946,1.013312,1.033569,1.03414,1.034138,1.017568,1.017583,1.066606,1.013266,0.993714,1.031791,1.045541,1.044372,1.030788,1,1,1,1,1.002506,1.034863,1,1 -2028,1.036799,1.006582,1.023966,1.01942,1.013356,1.033042,1.031594,1.03158,1.023985,1.02393,1.050716,1.021542,1.009158,1.03344,1.043558,1.043967,1.030942,1,1,1,1,1,1,1,1 -2029,1.035913,1.010333,1.028149,1.01966,1.013612,1.033365,1.030869,1.030888,1.028085,1.028143,1.03013,1.032091,1.018962,1.033664,1.045739,1.042825,1.031131,1,1,1,1,1,1,1,1 -2030,1.036423,1.01018,1.024121,1.01977,1.013855,1.03321,1.030563,1.030595,1.02417,1.024128,1.036979,1.032934,1.024538,1.034401,1.043738,1.043174,1.03133,1,1,1,1,1,1,1,1 -2031,1.036362,1.010259,1.024733,1.01991,1.014016,1.032812,1.031233,1.03124,1.024699,1.024734,1.039197,1.032793,1.027842,1.036645,1.038241,1.042951,1.03151,1,1,1,1,1,1,1,1 -2032,1.036409,1.009979,1.028,1.01999,1.014306,1.032126,1.032334,1.032295,1.028004,1.027983,1.04014,1.03261,1.029719,1.036435,1.031319,1.042807,1.031644,1,1,1,1,1,1,1,1 -2033,1.035793,1.008195,1.02813,1.02002,1.014309,1.031481,1.033961,1.033991,1.028128,1.02811,1.031669,1.03246,1.030798,1.037554,1.028443,1.042009,1.031857,1,1,1,1,1,1,1,1 -2034,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1,1,1,1,1,1,1,1 +YEAR,ATXPY,ASCHF,ABOOK,ACPIU,ACPIM,AWAGE,ASCHCI,ASCHCL,ASCHEI,ASCHEL,AINTS,ADIVS,ACGNS,ASOCSEC,AUCOMP,AIPD,ABENOTHER,ABENMCARE,ABENMCAID,ABENSSI,ABENSNAP,ABENWIC,ABENHOUSING,ABENTANF,ABENVET +2011,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2012,1.043862,0.950283,1.104992,1.0209,1.0365,1.032649,1.049023,0.956138,1.165922,0.926962,0.923588,1.327776,1.58966,1.02827,0.7711,0.9231,0.992359,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2013,1.012518,1.142179,1.033784,1.014791,1.024602,1.019984,0.99505,1.050098,0.997245,1.013128,0.893658,0.819381,0.776217,1.014786,0.728829,0.896219,0.992515,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2014,1.029476,0.931683,0.976566,1.015927,1.023917,1.039999,1.040616,1.030349,1.075978,0.991321,0.925886,1.17606,1.387522,1.004801,0.641103,0.970506,0.99257,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2015,1.043858,0.508206,0.999544,1.001235,1.026485,1.024119,1.038052,1.040061,1.04481,1.057257,1.013311,1.013846,1.004308,1.017188,0.81793,0.988666,1.053858,1.023325,1.041528,1.019361,1.102667,1.007792,1.026748,1.132657,1.04693 +2016,1.021978,1.071198,0.984833,1.012621,1.037807,1.006659,0.984484,1.005593,0.982695,0.983807,0.999649,0.968237,0.881651,0.991403,0.933831,1.001764,1.097065,1.011695,1.010367,0.993375,0.989722,1.002577,1.01625,0.828168,1.105413 +2017,1.049373,0.907035,1.018491,1.01677,1.025035,1.040577,1.060677,1.132498,1.093477,1.160123,1.088642,1.102389,1.344721,1.00723,0.94186,1.029301,1.011911,1.030968,1.014601,0.981621,1.0,0.998715,1.063959,1.0,1.0 +2018,1.042394,0.976786,1.074059,1.02,1.019707,1.041821,1.042769,1.042713,1.074048,1.074033,1.031272,1.076804,1.074755,1.018778,0.92284,1.050825,1.103035,1.045097,1.045897,1.005738,1.0,1.002574,1.034828,1.0,1.0 +2019,1.032351,0.979401,1.019085,1.01341,1.028328,1.039292,1.004274,1.004387,1.019131,1.019122,1.014806,1.041751,0.925878,1.031182,0.940635,1.040577,1.054052,1.052158,1.045866,1.000751,1.0,1.002567,1.034809,1.0,1.0 +2020,1.067957,1.167938,0.947032,1.00799,1.041121,1.006381,1.016054,1.015991,0.947016,0.94708,0.989319,1.091767,1.292516,1.023383,1.034222,1.076313,0.996727,1.050763,1.046106,1.00255,1.0,1.003841,1.034974,1.0,1.0 +2021,1.065517,1.126248,1.216697,1.04269,1.012343,1.079707,1.057058,1.05708,1.216716,1.216644,0.999214,1.057982,1.792117,1.011965,8.619252,1.073809,1.03007,1.047248,1.047927,1.001796,1.0,1.002551,1.034869,1.0,1.0 +2022,1.014347,1.742914,1.047552,1.07229,1.040311,1.076282,1.022527,1.022546,1.047553,1.047566,1.049118,1.042358,0.631565,1.04749,0.152665,1.022138,1.030159,1.048769,1.047573,0.999851,1.0,1.002545,1.034942,1.0,1.0 +2023,1.050108,0.653145,1.091056,1.05402,1.004761,1.050035,1.013156,1.013121,1.091037,1.091047,1.026196,1.126711,1.0525,1.085497,0.748857,1.058072,1.030193,1.050822,1.048715,1.000448,1.0,1.003807,1.034968,1.0,1.0 +2024,1.046242,0.895528,1.007166,1.0255,1.01407,1.040377,1.0397,1.03963,1.007187,1.007157,1.156028,1.023049,0.932271,1.052921,1.337549,1.054081,1.030334,1.048426,1.051767,0.99776,1.0,1.002528,1.034951,1.0,1.0 +2025,1.040442,0.963117,1.020457,1.02198,0.958663,1.038977,1.037682,1.037745,1.020415,1.020444,1.091746,1.02538,0.97747,1.031721,1.154874,1.047914,1.030635,1.046248,1.052213,1.002245,1.0,1.003783,1.034897,1.0,1.0 +2026,1.039294,0.987094,1.014705,1.02074,1.014023,1.035978,1.037783,1.037762,1.014711,1.014716,1.098184,1.019802,0.970235,1.030992,1.035291,1.046856,1.030633,1.072236,1.0,0.999552,1.0,1.002513,1.034808,1.0,1.0 +2027,1.037119,0.998822,1.017535,1.01946,1.013312,1.033569,1.03414,1.034138,1.017568,1.017583,1.066606,1.013266,0.993714,1.031791,1.045541,1.044372,1.030788,1.0,1.0,1.0,1.0,1.002506,1.034863,1.0,1.0 +2028,1.036799,1.006582,1.023966,1.01942,1.013356,1.033042,1.031594,1.03158,1.023985,1.02393,1.050716,1.021542,1.009158,1.03344,1.043558,1.043967,1.030942,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2029,1.035913,1.010333,1.028149,1.01966,1.013612,1.033365,1.030869,1.030888,1.028085,1.028143,1.03013,1.032091,1.018962,1.033664,1.045739,1.042825,1.031131,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2030,1.036423,1.01018,1.024121,1.01977,1.013855,1.03321,1.030563,1.030595,1.02417,1.024128,1.036979,1.032934,1.024538,1.034401,1.043738,1.043174,1.03133,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2031,1.036362,1.010259,1.024733,1.01991,1.014016,1.032812,1.031233,1.03124,1.024699,1.024734,1.039197,1.032793,1.027842,1.036645,1.038241,1.042951,1.03151,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2032,1.036409,1.009979,1.028,1.01999,1.014306,1.032126,1.032334,1.032295,1.028004,1.027983,1.04014,1.03261,1.029719,1.036435,1.031319,1.042807,1.031644,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2033,1.035793,1.008195,1.02813,1.02002,1.014309,1.031481,1.033961,1.033991,1.028128,1.02811,1.031669,1.03246,1.030798,1.037554,1.028443,1.042009,1.031857,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2034,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2035,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2036,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2037,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2038,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2039,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2040,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2041,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2042,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2043,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2044,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2045,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2046,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2047,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2048,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2049,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2050,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2051,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2052,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2053,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2054,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2055,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2056,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2057,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2058,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2059,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2060,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2061,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2062,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2063,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2064,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2065,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2066,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2067,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2068,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2069,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2070,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2071,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2072,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2073,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +2074,1.035385,1.008203,1.02971,1.02,1.014443,1.030912,1.033294,1.033253,1.029705,1.029722,1.027096,1.032231,1.031308,1.03748,1.029528,1.041408,1.032059,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 diff --git a/taxcalc/growfactors.py b/taxcalc/growfactors.py index b259fe11d..b4dcefe13 100644 --- a/taxcalc/growfactors.py +++ b/taxcalc/growfactors.py @@ -33,7 +33,7 @@ class instance: GrowFactors Notes ----- Typical usage is "gfactor = GrowFactors()", which produces an object - containing the default growth factors in the GrowFactors.FILE_NAME file. + containing growth factors in the GrowFactors.FILE_NAME file. """ FILE_NAME = 'growfactors.csv' @@ -56,7 +56,7 @@ def __init__(self, growfactors_filename=FILE_NAME): growfactors_filename) if os.path.isfile(full_filename): gfdf = pd.read_csv(full_filename, index_col='YEAR') - else: # find file in conda package + else: # find file in package gfdf = read_egg_csv(os.path.basename(growfactors_filename), index_col='YEAR') # pragma: no cover else: @@ -65,7 +65,7 @@ def __init__(self, growfactors_filename=FILE_NAME): # check validity of gfdf column names gfdf_names = set(list(gfdf)) if gfdf_names != GrowFactors.VALID_NAMES: - msg = ('missing names are: {} and invalid names are: {}') + msg = 'missing names are: {} and invalid names are: {}' missing = GrowFactors.VALID_NAMES - gfdf_names invalid = gfdf_names - GrowFactors.VALID_NAMES raise ValueError(msg.format(missing, invalid)) diff --git a/taxcalc/policy_current_law.json b/taxcalc/policy_current_law.json index 69f16131f..c99a152e3 100644 --- a/taxcalc/policy_current_law.json +++ b/taxcalc/policy_current_law.json @@ -20692,4 +20692,4 @@ "cps": true } } -} \ No newline at end of file +} diff --git a/taxcalc/records.py b/taxcalc/records.py index 40d43672a..fedec143f 100644 --- a/taxcalc/records.py +++ b/taxcalc/records.py @@ -96,7 +96,10 @@ class instance: Records doing when attempting this. Use Records.cps_constructor() to get a Records object instantiated - with CPS input data. + with CPS input data developed in the taxdata repository. + + Use Records.tmd_constructor() to get a Records object instantiated + with TMD input data developed in the tax-microdata repository. """ # suppress pylint warning about constructor having too many arguments: # pylint: disable=too-many-arguments @@ -107,11 +110,14 @@ class instance: Records PUFCSV_YEAR = 2011 CPSCSV_YEAR = 2014 + TMDCSV_YEAR = 2021 PUF_WEIGHTS_FILENAME = 'puf_weights.csv.gz' PUF_RATIOS_FILENAME = 'puf_ratios.csv' CPS_WEIGHTS_FILENAME = 'cps_weights.csv.gz' CPS_RATIOS_FILENAME = None + TMD_WEIGHTS_FILENAME = 'tmd_weights.csv.gz' + TMD_RATIOS_FILENAME = None CODE_PATH = os.path.abspath(os.path.dirname(__file__)) VARINFO_FILE_NAME = 'records_variables.json' VARINFO_FILE_PATH = CODE_PATH @@ -218,6 +224,28 @@ def cps_constructor(data=None, adjust_ratios=Records.CPS_RATIOS_FILENAME, exact_calculations=exact_calculations) + @staticmethod + def tmd_constructor(data, # path to tmd.csv file or dataframe + gfactors=GrowFactors(), + exact_calculations=False): # pragma: no cover + """ + Static method returns a Records object instantiated with TMD + input data. This works in a analogous way to Records(), which + returns a Records object instantiated with PUF input data. + This is a convenience method that eliminates the need to + specify all the details of the TMD input data just as the + default values of the arguments of the Records class constructor + eliminate the need to specify all the details of the PUF input + data. + """ + weights = os.path.join(Records.CODE_PATH, Records.TMD_WEIGHTS_FILENAME) + return Records(data=data, + start_year=Records.TMDCSV_YEAR, + gfactors=gfactors, + weights=weights, + adjust_ratios=Records.TMD_RATIOS_FILENAME, + exact_calculations=exact_calculations) + def increment_year(self): """ Add one to current year, and also does diff --git a/taxcalc/taxcalcio.py b/taxcalc/taxcalcio.py index ac85af4bb..dfb311fa9 100644 --- a/taxcalc/taxcalcio.py +++ b/taxcalc/taxcalcio.py @@ -73,6 +73,7 @@ def __init__(self, input_data, tax_year, baseline, reform, assump, inp = 'x' self.puf_input_data = False self.cps_input_data = False + self.tmd_input_data = False if isinstance(input_data, str): # remove any leading directory path from INPUT filename fname = os.path.basename(input_data) @@ -85,6 +86,7 @@ def __init__(self, input_data, tax_year, baseline, reform, assump, # check existence of INPUT file self.puf_input_data = input_data.endswith('puf.csv') self.cps_input_data = input_data.endswith('cps.csv') + self.tmd_input_data = input_data.endswith('tmd.csv') if not self.cps_input_data and not os.path.isfile(input_data): msg = 'INPUT file could not be found' self.errmsg += 'ERROR: {}\n'.format(msg) @@ -320,7 +322,18 @@ def init(self, input_data, tax_year, baseline, reform, assump, gfactors=gfactors_base, exact_calculations=exact_calculations ) - else: # if not cps_input_data but aging_input_data + elif self.tmd_input_data: + recs = Records.tmd_constructor( + data=input_data, + gfactors=gfactors_ref, + exact_calculations=exact_calculations + ) # pragma: no cover + recs_base = Records.tmd_constructor( + data=input_data, + gfactors=gfactors_base, + exact_calculations=exact_calculations + ) # pragma: no cover + else: # if not {cps|tmd}_input_data but aging_input_data recs = Records( data=input_data, gfactors=gfactors_ref, diff --git a/taxcalc/tests/conftest.py b/taxcalc/tests/conftest.py index 4d0419843..06c334874 100644 --- a/taxcalc/tests/conftest.py +++ b/taxcalc/tests/conftest.py @@ -4,7 +4,6 @@ import numpy import pandas import pytest -from pytest_harvest import get_session_results_df # convert all numpy warnings into errors so they can be detected in tests @@ -132,44 +131,3 @@ def fixture_test_reforms(tests_path): raise ValueError(msg) else: os.remove(actfile_path) - - -def pytest_sessionfinish(session): - """ Gather all test profiling test results and print to user.""" - - tests_path = os.path.abspath(os.path.dirname(__file__)) - - new_stats_df = get_session_results_df(session) - # move test_id from index into unique column - new_stats_df.reset_index(inplace=True) - old_stats_df = pandas.read_csv(os.path.join( - tests_path, 'test_stats_benchmark.csv') - ) - - merge_df = new_stats_df.merge(old_stats_df, on=['test_id'], how='left') - # time diff for new tests is set to 0 - merge_df['time_diff'] = ( - merge_df['duration_ms_x'] - merge_df['duration_ms_y'] - ) - merge_df['time_diff'] = merge_df['time_diff'].fillna(0) - - tol = 1.0 # choose tolerance in seconds - tol *= 1000 - - print('\n') - for ind, row in merge_df.iterrows(): - if row['time_diff'] > tol: - diff = round(abs(row['time_diff']), 3) - print((f"{row['test_id']} is slower than the " - f"current benchmark by {diff} ms")) - - print('\n') - for ind, row in merge_df.iterrows(): - if row['time_diff'] < (-1 * tol): - diff = round(abs(row['time_diff']), 3) - print((f"{row['test_id']} is faster than the " - f"current benchmark by {diff} ms")) - - # Save new test stats to disk including time diff - new_stats_df['time_diff'] = merge_df['time_diff'].values - new_stats_df.to_csv(os.path.join(tests_path, 'test_stats_current.csv')) diff --git a/taxcalc/tests/test_4package.py b/taxcalc/tests/test_4package.py index 431e36acc..4b30fc121 100644 --- a/taxcalc/tests/test_4package.py +++ b/taxcalc/tests/test_4package.py @@ -33,10 +33,8 @@ def test_for_consistency(tests_path): dev_pkgs = set([ 'fsspec<=0.8.7', 'pytest', - 'pytest-pep8', 'pytest-xdist', 'pycodestyle', - 'pytest_harvest', 'pylint', 'coverage', "pip", diff --git a/taxcalc/tests/test_benefits.py b/taxcalc/tests/test_benefits.py index b89cdef5a..e53d07424 100644 --- a/taxcalc/tests/test_benefits.py +++ b/taxcalc/tests/test_benefits.py @@ -23,7 +23,7 @@ @pytest.mark.benefits def test_benefits(tests_path, cps_fullsample): """ - Test CPS benefits. + Test CPS benefits from 2015 thru 2034. """ # pylint: disable=too-many-locals benefit_names = ['ssi', 'mcare', 'mcaid', 'snap', 'wic', @@ -38,7 +38,7 @@ def test_benefits(tests_path, cps_fullsample): benamt_list = list() bencnt_list = list() benavg_list = list() - for year in range(start_year, Policy.LAST_BUDGET_YEAR + 1): + for year in range(start_year, 2034 + 1): calc.advance_to_year(year) size = calc.array('XTOT') wght = calc.array('s006') diff --git a/taxcalc/tests/test_consumption.py b/taxcalc/tests/test_consumption.py index 1c16ed0a0..eaaa24831 100644 --- a/taxcalc/tests/test_consumption.py +++ b/taxcalc/tests/test_consumption.py @@ -65,7 +65,7 @@ def test_incorrect_update_consumption(): with pytest.raises(paramtools.ValidationError): Consumption().update_consumption({'MPC_e17500': {2012: 0.2}}) with pytest.raises(paramtools.ValidationError): - Consumption().update_consumption({'MPC_e17500': {2052: 0.2}}) + Consumption().update_consumption({'MPC_e17500': {2099: 0.2}}) with pytest.raises(paramtools.ValidationError): Consumption().update_consumption({'MPC_exxxxx': {2014: 0.2}}) with pytest.raises(paramtools.ValidationError): diff --git a/taxcalc/tests/test_policy.py b/taxcalc/tests/test_policy.py index 85b3c1aac..110c27407 100644 --- a/taxcalc/tests/test_policy.py +++ b/taxcalc/tests/test_policy.py @@ -183,7 +183,7 @@ def test_constant_inflation_rate_with_reform(): """ pol = Policy() # implement reform in year before final year - fyr = Policy.LAST_BUDGET_YEAR + fyr = 2034 ryr = fyr - 1 reform = { 'II_em': {(ryr - 3): 1000, # to avoid divide-by-zero under TCJA diff --git a/taxcalc/tests/test_puf_var_stats.py b/taxcalc/tests/test_puf_var_stats.py index 75f519638..15ca4498e 100644 --- a/taxcalc/tests/test_puf_var_stats.py +++ b/taxcalc/tests/test_puf_var_stats.py @@ -170,14 +170,14 @@ def test_puf_var_stats(tests_path, puf_fullsample): del table_corr['description'] # add statistics to tables year_headers = ['description'] - for year in range(Policy.JSON_START_YEAR, Policy.LAST_BUDGET_YEAR + 1): + for year in range(Policy.JSON_START_YEAR, 2034 + 1): assert year == calc.current_year year_headers.append(str(year)) calc.calc_all() calculate_mean_stats(calc, table_mean, year) if year == 2016: calculate_corr_stats(calc, table_corr) - if year < Policy.LAST_BUDGET_YEAR: + if year < 2034: calc.increment_year() # write tables to new CSV files mean_path = os.path.join(tests_path, MEAN_FILENAME + '-new') diff --git a/taxcalc/tests/test_stats_current.csv b/taxcalc/tests/test_stats_current.csv deleted file mode 100644 index 999ad51e2..000000000 --- a/taxcalc/tests/test_stats_current.csv +++ /dev/null @@ -1,2 +0,0 @@ -,test_id,pytest_obj,status,duration_ms,time_diff -0,taxcalc/tests/test_reforms.py::test_ext_reform,<function test_ext_reform at 0x1433411c0>,passed,27372.827967978083,0.0 diff --git a/taxcalc/tmd_weights.csv.gz b/taxcalc/tmd_weights.csv.gz new file mode 100644 index 000000000..c76d19655 Binary files /dev/null and b/taxcalc/tmd_weights.csv.gz differ