taxcalc 3.5.3__tar.gz → 4.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {taxcalc-3.5.3 → taxcalc-4.1.0}/MANIFEST.in +2 -1
  2. {taxcalc-3.5.3/taxcalc.egg-info → taxcalc-4.1.0}/PKG-INFO +3 -2
  3. {taxcalc-3.5.3 → taxcalc-4.1.0}/README.md +1 -1
  4. {taxcalc-3.5.3 → taxcalc-4.1.0}/setup.py +2 -1
  5. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/__init__.py +1 -1
  6. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/calcfunctions.py +70 -33
  7. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/calculator.py +5 -3
  8. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/cli/tc.py +23 -3
  9. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/consumption.json +1 -1
  10. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/data.py +1 -1
  11. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/growdiff.json +1 -1
  12. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/growdiff.py +9 -3
  13. taxcalc-4.1.0/taxcalc/growfactors.csv +65 -0
  14. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/growfactors.py +32 -21
  15. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/parameters.py +1 -1
  16. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/policy_current_law.json +86 -34
  17. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/records.py +30 -1
  18. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/records_variables.json +10 -0
  19. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/taxcalcio.py +53 -18
  20. taxcalc-4.1.0/taxcalc/tmd_growfactors.csv +55 -0
  21. taxcalc-4.1.0/taxcalc/tmd_weights.csv.gz +0 -0
  22. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/utils.py +72 -48
  23. {taxcalc-3.5.3 → taxcalc-4.1.0/taxcalc.egg-info}/PKG-INFO +3 -2
  24. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc.egg-info/SOURCES.txt +2 -0
  25. taxcalc-3.5.3/taxcalc/growfactors.csv +0 -25
  26. {taxcalc-3.5.3 → taxcalc-4.1.0}/LICENSE +0 -0
  27. {taxcalc-3.5.3 → taxcalc-4.1.0}/setup.cfg +0 -0
  28. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/cli/__init__.py +0 -0
  29. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/conftest.py +0 -0
  30. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/consumption.py +0 -0
  31. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/cps.csv.gz +0 -0
  32. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/cps_weights.csv.gz +0 -0
  33. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/decorators.py +0 -0
  34. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/policy.py +0 -0
  35. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/puf_ratios.csv +0 -0
  36. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/puf_weights.csv.gz +0 -0
  37. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc/utilsprvt.py +0 -0
  38. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc.egg-info/dependency_links.txt +0 -0
  39. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc.egg-info/entry_points.txt +0 -0
  40. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc.egg-info/requires.txt +0 -0
  41. {taxcalc-3.5.3 → taxcalc-4.1.0}/taxcalc.egg-info/top_level.txt +0 -0
@@ -7,4 +7,5 @@ include taxcalc/policy_current_law.json
7
7
  include taxcalc/puf_weights.csv.gz
8
8
  include taxcalc/puf_ratios.csv
9
9
  include taxcalc/records_variables.json
10
-
10
+ include taxcalc/tmd_weights.csv.gz
11
+ include taxcalc/tmd_growfactors.csv
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: taxcalc
3
- Version: 3.5.3
3
+ Version: 4.1.0
4
4
  Summary: taxcalc
5
5
  Home-page: https://github.com/PSLmodels/Tax-Calculator
6
6
  Download-URL: https://github.com/PSLmodels/Tax-Calculator
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Programming Language :: Python :: 3.9
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
18
19
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
20
  Description-Content-Type: text/markdown
20
21
  License-File: LICENSE
@@ -29,7 +30,7 @@ Requires-Dist: paramtools
29
30
  | | |
30
31
  | --- | --- |
31
32
  | Org | [![PSL cataloged](https://img.shields.io/badge/PSL-cataloged-a0a0a0.svg)](https://www.PSLmodels.org) [![OS License: CCO-1.0](https://img.shields.io/badge/OS%20License-CCO%201.0-yellow)](https://github.com/PSLmodels/Tax-Calculator/blob/master/LICENSE) [![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://pslmodels.github.io/Tax-Calculator/) |
32
- | Package | [![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-3916/) [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3108/) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3118/) [![PyPI Latest Release](https://img.shields.io/pypi/v/taxcalc.svg)](https://pypi.org/project/taxcalc/) [![PyPI Downloads](https://img.shields.io/pypi/dm/taxcalc.svg?label=PyPI%20downloads)](https://pypi.org/project/taxcalc/) [![Anaconda](https://img.shields.io/conda/dn/conda-forge/taxcalc?color=brightgreen&label=downloads&logo=conda-forge)](https://anaconda.org/conda-forge/taxcalc)|
33
+ | Package | [![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-3916/) [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3108/) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3118/) [![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/release/python-3121/) [![PyPI Latest Release](https://img.shields.io/pypi/v/taxcalc.svg)](https://pypi.org/project/taxcalc/) [![PyPI Downloads](https://img.shields.io/pypi/dm/taxcalc.svg?label=PyPI%20downloads)](https://pypi.org/project/taxcalc/) [![Anaconda](https://img.shields.io/conda/dn/conda-forge/taxcalc?color=brightgreen&label=downloads&logo=conda-forge)](https://anaconda.org/conda-forge/taxcalc)|
33
34
  | Testing | ![example event parameter](https://github.com/PSLmodels/Tax-Calculator/actions/workflows/build_and_test.yml/badge.svg?branch=master) ![example event parameter](https://github.com/PSLmodels/Tax-Calculator/actions/workflows/deploy_jupyterbook.yml/badge.svg?branch=master) [![Codecov](https://codecov.io/gh/PSLmodels/Tax-Calculator/branch/master/graph/badge.svg)](https://codecov.io/gh/PSLmodels/Tax-Calculator) |
34
35
 
35
36
 
@@ -1,7 +1,7 @@
1
1
  | | |
2
2
  | --- | --- |
3
3
  | Org | [![PSL cataloged](https://img.shields.io/badge/PSL-cataloged-a0a0a0.svg)](https://www.PSLmodels.org) [![OS License: CCO-1.0](https://img.shields.io/badge/OS%20License-CCO%201.0-yellow)](https://github.com/PSLmodels/Tax-Calculator/blob/master/LICENSE) [![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://pslmodels.github.io/Tax-Calculator/) |
4
- | Package | [![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-3916/) [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3108/) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3118/) [![PyPI Latest Release](https://img.shields.io/pypi/v/taxcalc.svg)](https://pypi.org/project/taxcalc/) [![PyPI Downloads](https://img.shields.io/pypi/dm/taxcalc.svg?label=PyPI%20downloads)](https://pypi.org/project/taxcalc/) [![Anaconda](https://img.shields.io/conda/dn/conda-forge/taxcalc?color=brightgreen&label=downloads&logo=conda-forge)](https://anaconda.org/conda-forge/taxcalc)|
4
+ | Package | [![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-3916/) [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3108/) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3118/) [![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/release/python-3121/) [![PyPI Latest Release](https://img.shields.io/pypi/v/taxcalc.svg)](https://pypi.org/project/taxcalc/) [![PyPI Downloads](https://img.shields.io/pypi/dm/taxcalc.svg?label=PyPI%20downloads)](https://pypi.org/project/taxcalc/) [![Anaconda](https://img.shields.io/conda/dn/conda-forge/taxcalc?color=brightgreen&label=downloads&logo=conda-forge)](https://anaconda.org/conda-forge/taxcalc)|
5
5
  | Testing | ![example event parameter](https://github.com/PSLmodels/Tax-Calculator/actions/workflows/build_and_test.yml/badge.svg?branch=master) ![example event parameter](https://github.com/PSLmodels/Tax-Calculator/actions/workflows/deploy_jupyterbook.yml/badge.svg?branch=master) [![Codecov](https://codecov.io/gh/PSLmodels/Tax-Calculator/branch/master/graph/badge.svg)](https://codecov.io/gh/PSLmodels/Tax-Calculator) |
6
6
 
7
7
 
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
  with open("README.md") as f:
4
4
  longdesc = f.read()
5
5
 
6
- version = "3.5.3"
6
+ version = "4.1.0"
7
7
 
8
8
  config = {
9
9
  "description": "Tax Calculator",
@@ -37,6 +37,7 @@ config = {
37
37
  "Programming Language :: Python :: 3.9",
38
38
  "Programming Language :: Python :: 3.10",
39
39
  "Programming Language :: Python :: 3.11",
40
+ "Programming Language :: Python :: 3.12",
40
41
  "Topic :: Software Development :: Libraries :: Python Modules",
41
42
  ],
42
43
  "tests_require": ["pytest"],
@@ -14,4 +14,4 @@ from taxcalc.taxcalcio import *
14
14
  from taxcalc.utils import *
15
15
  from taxcalc.cli import *
16
16
 
17
- __version__ = '3.5.3'
17
+ __version__ = '4.1.0'
@@ -100,8 +100,9 @@ def BenefitPrograms(calc):
100
100
 
101
101
  @iterate_jit(nopython=True)
102
102
  def EI_PayrollTax(SS_Earnings_c, e00200p, e00200s, pencon_p, pencon_s,
103
- FICA_ss_trt, FICA_mc_trt, ALD_SelfEmploymentTax_hc,
104
- SS_Earnings_thd, SECA_Earnings_thd,
103
+ FICA_ss_trt_employer, FICA_ss_trt_employee,
104
+ FICA_mc_trt_employer, FICA_mc_trt_employee,
105
+ ALD_SelfEmploymentTax_hc, SS_Earnings_thd, SECA_Earnings_thd,
105
106
  e00900p, e00900s, e02100p, e02100s, k1bx14p,
106
107
  k1bx14s, payrolltax, ptax_was, setax, c03260, ptax_oasdi,
107
108
  sey, earned, earned_p, earned_s,
@@ -123,10 +124,14 @@ def EI_PayrollTax(SS_Earnings_c, e00200p, e00200s, pencon_p, pencon_s,
123
124
  Contributions to defined-contribution pension plans for taxpayer
124
125
  pencon_s: float
125
126
  Contributions to defined-contribution pension plans for spouse
126
- FICA_ss_trt: float
127
- Social security payroll tax rate, including both employer and employee
128
- FICA_mc_trt: float
129
- Medicare payroll tax rate, including both employer and employee
127
+ FICA_ss_trt_employer: float
128
+ Employer side social security payroll tax rate
129
+ FICA_ss_trt_employee: float
130
+ Employee side social security payroll tax rate
131
+ FICA_mc_trt_employer: float
132
+ Employer side medicare payroll tax rate
133
+ FICA_mc_trt_employee: float
134
+ Employee side medicare payroll tax rate
130
135
  ALD_SelfEmploymentTax_hc: float
131
136
  Adjustment for self-employment tax haircut
132
137
  If greater than zero, reduces the employer equivalent portion of self-employment adjustment
@@ -218,22 +223,22 @@ def EI_PayrollTax(SS_Earnings_c, e00200p, e00200s, pencon_p, pencon_s,
218
223
  txearn_was_s = min(SS_Earnings_c, gross_was_s)
219
224
 
220
225
  # compute OASDI and HI payroll taxes on wage-and-salary income, FICA
221
- ptax_ss_was_p = FICA_ss_trt * txearn_was_p
222
- ptax_ss_was_s = FICA_ss_trt * txearn_was_s
223
- ptax_mc_was_p = FICA_mc_trt * gross_was_p
224
- ptax_mc_was_s = FICA_mc_trt * gross_was_s
226
+ ptax_ss_was_p = (FICA_ss_trt_employer + FICA_ss_trt_employee) * txearn_was_p
227
+ ptax_ss_was_s = (FICA_ss_trt_employer + FICA_ss_trt_employee) * txearn_was_s
228
+ ptax_mc_was_p = (FICA_mc_trt_employer + FICA_mc_trt_employee) * gross_was_p
229
+ ptax_mc_was_s = (FICA_mc_trt_employer + FICA_mc_trt_employee) * gross_was_s
225
230
  ptax_was = ptax_ss_was_p + ptax_ss_was_s + ptax_mc_was_p + ptax_mc_was_s
226
231
 
227
232
  # compute taxable self-employment income for OASDI SECA
228
- sey_frac = 1.0 - 0.5 * (FICA_ss_trt + FICA_mc_trt)
233
+ sey_frac = 1.0 - 0.5 * (FICA_ss_trt_employer + FICA_ss_trt_employee + FICA_mc_trt_employer + FICA_mc_trt_employee)
229
234
  txearn_sey_p = min(max(0., sey_p * sey_frac), SS_Earnings_c - txearn_was_p)
230
235
  txearn_sey_s = min(max(0., sey_s * sey_frac), SS_Earnings_c - txearn_was_s)
231
236
 
232
237
  # compute self-employment tax on taxable self-employment income, SECA
233
- setax_ss_p = FICA_ss_trt * txearn_sey_p
234
- setax_ss_s = FICA_ss_trt * txearn_sey_s
235
- setax_mc_p = FICA_mc_trt * max(0., sey_p * sey_frac)
236
- setax_mc_s = FICA_mc_trt * max(0., sey_s * sey_frac)
238
+ setax_ss_p = (FICA_ss_trt_employer + FICA_ss_trt_employee) * txearn_sey_p
239
+ setax_ss_s = (FICA_ss_trt_employer + FICA_ss_trt_employee) * txearn_sey_s
240
+ setax_mc_p = (FICA_mc_trt_employer + FICA_mc_trt_employee) * max(0., sey_p * sey_frac)
241
+ setax_mc_s = (FICA_mc_trt_employer + FICA_mc_trt_employee) * max(0., sey_s * sey_frac)
237
242
  setax_p = setax_ss_p + setax_mc_p
238
243
  setax_s = setax_ss_s + setax_mc_s
239
244
  setax = setax_p + setax_s
@@ -246,13 +251,13 @@ def EI_PayrollTax(SS_Earnings_c, e00200p, e00200s, pencon_p, pencon_s,
246
251
  # compute extra OASDI payroll taxes on the portion of the sum
247
252
  # of wage-and-salary income and taxable self employment income
248
253
  # that exceeds SS_Earnings_thd
249
- sey_frac = 1.0 - 0.5 * FICA_ss_trt
254
+ sey_frac = 1.0 - 0.5 * (FICA_ss_trt_employer + FICA_ss_trt_employee)
250
255
  was_plus_sey_p = gross_was_p + max(0., sey_p * sey_frac)
251
256
  was_plus_sey_s = gross_was_s + max(0., sey_s * sey_frac)
252
257
  extra_ss_income_p = max(0., was_plus_sey_p - SS_Earnings_thd)
253
258
  extra_ss_income_s = max(0., was_plus_sey_s - SS_Earnings_thd)
254
- extra_payrolltax = (extra_ss_income_p * FICA_ss_trt +
255
- extra_ss_income_s * FICA_ss_trt)
259
+ extra_payrolltax = (extra_ss_income_p * (FICA_ss_trt_employer + FICA_ss_trt_employee) +
260
+ extra_ss_income_s * (FICA_ss_trt_employer + FICA_ss_trt_employee))
256
261
 
257
262
  # compute part of total payroll taxes for filing unit
258
263
  # (the ptax_amc part of total payroll taxes for the filing unit is
@@ -1080,7 +1085,8 @@ def ItemDed(e17500_capped, e18400_capped, e18500_capped, e19200_capped,
1080
1085
  @iterate_jit(nopython=True)
1081
1086
  def AdditionalMedicareTax(e00200, MARS,
1082
1087
  AMEDT_ec, sey, AMEDT_rt,
1083
- FICA_mc_trt, FICA_ss_trt,
1088
+ FICA_mc_trt_employer, FICA_mc_trt_employee,
1089
+ FICA_ss_trt_employer, FICA_ss_trt_employee,
1084
1090
  ptax_amc, payrolltax):
1085
1091
  """
1086
1092
  Computes Additional Medicare Tax (Form 8959) included in payroll taxes.
@@ -1093,10 +1099,14 @@ def AdditionalMedicareTax(e00200, MARS,
1093
1099
  Additional Medicare Tax earnings exclusion
1094
1100
  AMEDT_rt: float
1095
1101
  Additional Medicare Tax rate
1096
- FICA_ss_trt: float
1097
- FICA Social Security tax rate
1098
- FICA_mc_trt: float
1099
- FICA Medicare tax rate
1102
+ FICA_ss_trt_employer: float
1103
+ Employer side FICA Social Security tax rate
1104
+ FICA_ss_trt_employee: float
1105
+ Employee side FICA Social Security tax rate
1106
+ FICA_mc_trt_employer: float
1107
+ Employer side FICA Medicare tax rate
1108
+ FICA_mc_trt_employee: float
1109
+ Employee side FICA Medicare tax rate
1100
1110
  e00200: float
1101
1111
  Wages and salaries
1102
1112
  sey: float
@@ -1113,7 +1123,7 @@ def AdditionalMedicareTax(e00200, MARS,
1113
1123
  payrolltax: float
1114
1124
  payroll tax augmented by Additional Medicare Tax
1115
1125
  """
1116
- line8 = max(0., sey) * (1. - 0.5 * (FICA_mc_trt + FICA_ss_trt))
1126
+ line8 = max(0., sey) * (1. - 0.5 * (FICA_mc_trt_employer + FICA_mc_trt_employee + FICA_ss_trt_employer + FICA_ss_trt_employee))
1117
1127
  line11 = max(0., AMEDT_ec[MARS - 1] - e00200)
1118
1128
  ptax_amc = AMEDT_rt * (max(0., e00200 - AMEDT_ec[MARS - 1]) +
1119
1129
  max(0., line8 - line11))
@@ -2149,15 +2159,23 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
2149
2159
  c00100: float
2150
2160
  Adjusted Gross Income (AGI)
2151
2161
  CDCC_ps: float
2152
- Child/dependent care credit phaseout start
2162
+ Child/dependent care credit first phaseout start
2163
+ CDCC_ps2: float
2164
+ Child/dependent care credit second phaseout start
2153
2165
  CDCC_crt: float
2154
- Child/dependent care credit phaseout percentage rate ceiling
2166
+ Child/dependent care credit phaseout rate ceiling
2167
+ CDCC_frt: float
2168
+ Child/dependent care credit phaseout rate floor
2169
+ CDCC_prt: float
2170
+ Child/dependent care credit phaseout rate
2155
2171
  c05800: float
2156
2172
  Total (regular + AMT) income tax liability before credits
2157
2173
  e07300: float
2158
2174
  Foreign tax credit from Form 1116
2159
2175
  c07180: float
2160
2176
  Credit for child and dependent care expenses from Form 2441
2177
+ CDCC_refund: bool
2178
+ Indicator for whether CDCC is refundable
2161
2179
 
2162
2180
  Returns
2163
2181
  -------
@@ -2189,7 +2207,8 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
2189
2207
  if c00100 > CDCC_ps2:
2190
2208
  crate = max(0., CDCC_frt -
2191
2209
  max(((c00100 - CDCC_ps2) * CDCC_prt), 0.))
2192
- c33200 = c33000 * 0.01 * crate
2210
+
2211
+ c33200 = c33000 * crate
2193
2212
  # credit is limited by tax liability if not refundable
2194
2213
  if CDCC_refundable:
2195
2214
  c07180 = 0.
@@ -3199,7 +3218,7 @@ def C1040(c05800, c07180, c07200, c07220, c07230, c07240, c07260, c07300,
3199
3218
  def CTC_new(CTC_new_c, CTC_new_rt, CTC_new_c_under6_bonus,
3200
3219
  CTC_new_ps, CTC_new_prt, CTC_new_for_all, CTC_include17,
3201
3220
  CTC_new_refund_limited, CTC_new_refund_limit_payroll_rt,
3202
- CTC_new_refund_limited_all_payroll, payrolltax,
3221
+ CTC_new_refund_limited_all_payroll, payrolltax, exact,
3203
3222
  n24, nu06, age_head, age_spouse, nu18, c00100, MARS, ptax_oasdi,
3204
3223
  c09200, ctc_new):
3205
3224
  """
@@ -3227,6 +3246,8 @@ def CTC_new(CTC_new_c, CTC_new_rt, CTC_new_c_under6_bonus,
3227
3246
  New child tax credit refund limit applies to all FICA taxes, not just OASDI
3228
3247
  payrolltax: float
3229
3248
  Total (employee + employer) payroll tax liability
3249
+ exact: int
3250
+ Whether or not exact phase-out calculation is being done
3230
3251
  n24: int
3231
3252
  Number of children who are Child-Tax-Credit eligible, one condition for which is being under age 17
3232
3253
  nu06: int
@@ -3261,8 +3282,12 @@ def CTC_new(CTC_new_c, CTC_new_rt, CTC_new_c_under6_bonus,
3261
3282
  ctc_new = min(CTC_new_rt * posagi, ctc_new)
3262
3283
  ymax = CTC_new_ps[MARS - 1]
3263
3284
  if posagi > ymax:
3264
- ctc_new_reduced = max(0.,
3265
- ctc_new - CTC_new_prt * (posagi - ymax))
3285
+ over = posagi - ymax
3286
+ if exact == 1: # exact calculation as on tax form
3287
+ excess = math.ceil(over / 1000.) * 1000.
3288
+ else: # smoothed calculation
3289
+ excess = over
3290
+ ctc_new_reduced = max(0., ctc_new - CTC_new_prt * excess)
3266
3291
  ctc_new = min(ctc_new, ctc_new_reduced)
3267
3292
  if ctc_new > 0. and CTC_new_refund_limited:
3268
3293
  refund_new = max(0., ctc_new - c09200)
@@ -3280,7 +3305,8 @@ def CTC_new(CTC_new_c, CTC_new_rt, CTC_new_c_under6_bonus,
3280
3305
  @iterate_jit(nopython=True)
3281
3306
  def IITAX(c59660, c11070, c10960, personal_refundable_credit, ctc_new, rptc,
3282
3307
  c09200, payrolltax, CDCC_refund, recovery_rebate_credit,
3283
- eitc, c07220, odc, CTC_refundable, ODC_refundable, refund, iitax, combined):
3308
+ eitc, c07220, odc, CTC_refundable, ODC_refundable, refund,
3309
+ ctc_total, ctc_refundable, iitax, combined):
3284
3310
  """
3285
3311
  Computes final taxes.
3286
3312
 
@@ -3307,6 +3333,10 @@ def IITAX(c59660, c11070, c10960, personal_refundable_credit, ctc_new, rptc,
3307
3333
  Earned Income Credit
3308
3334
  refund: float
3309
3335
  Total refundable income tax credits
3336
+ ctc_total: float
3337
+ Total CTC amount (c07220 + c11070 + odc + ctc_new)
3338
+ ctc_refundable: float
3339
+ Portion of total CTC amount that is refundable
3310
3340
  iitax: float
3311
3341
  Total federal individual income tax liability
3312
3342
  combined: float
@@ -3318,6 +3348,10 @@ def IITAX(c59660, c11070, c10960, personal_refundable_credit, ctc_new, rptc,
3318
3348
  Earned Income Credit
3319
3349
  refund: float
3320
3350
  Total refundable income tax credits
3351
+ ctc_total: float
3352
+ Total CTC amount (c07220 + c11070 + odc + ctc_new)
3353
+ ctc_refundable: float
3354
+ Portion of total CTC amount that is refundable
3321
3355
  iitax: float
3322
3356
  Total federal individual income tax liability
3323
3357
  combined: float
@@ -3333,10 +3367,13 @@ def IITAX(c59660, c11070, c10960, personal_refundable_credit, ctc_new, rptc,
3333
3367
  else:
3334
3368
  odc_refund = 0.
3335
3369
  refund = (eitc + c11070 + c10960 + CDCC_refund + recovery_rebate_credit +
3336
- personal_refundable_credit + ctc_new + rptc + ctc_refund + odc_refund)
3370
+ personal_refundable_credit + ctc_new + rptc + ctc_refund +
3371
+ odc_refund)
3372
+ ctc_total = c07220 + c11070 + odc + ctc_new
3373
+ ctc_refundable = ctc_refund + c11070 + odc_refund + ctc_new
3337
3374
  iitax = c09200 - refund
3338
3375
  combined = iitax + payrolltax
3339
- return (eitc, refund, iitax, combined)
3376
+ return (eitc, refund, ctc_total, ctc_refundable, iitax, combined)
3340
3377
 
3341
3378
 
3342
3379
  @JIT(nopython=True)
@@ -694,9 +694,11 @@ class Calculator():
694
694
  variable >= self.policy_param('SS_Earnings_thd')
695
695
  )
696
696
  adj = np.where(oasdi_taxed,
697
- 0.5 * (self.policy_param('FICA_ss_trt') +
698
- self.policy_param('FICA_mc_trt')),
699
- 0.5 * self.policy_param('FICA_mc_trt'))
697
+ 0.5 * (self.policy_param('FICA_ss_trt_employer') +
698
+ self.policy_param('FICA_ss_trt_employee') +
699
+ self.policy_param('FICA_mc_trt_employer') +
700
+ self.policy_param('FICA_mc_trt_employee')),
701
+ 0.5 * (self.policy_param('FICA_mc_trt_employer') + self.policy_param('FICA_mc_trt_employee')))
700
702
  else:
701
703
  adj = 0.0
702
704
  # compute marginal tax rates
@@ -8,6 +8,7 @@ which can be accessed as 'tc' from an installed taxcalc conda package.
8
8
 
9
9
  import os
10
10
  import sys
11
+ import time
11
12
  import argparse
12
13
  import difflib
13
14
  import taxcalc as tc
@@ -29,7 +30,7 @@ def cli_tc_main():
29
30
  (' '
30
31
  '[--baseline BASELINE] [--reform REFORM] [--assump ASSUMP]\n'),
31
32
  (' '
32
- '[--exact] [--tables] [--graphs]\n'),
33
+ '[--exact] [--tables] [--graphs] [--timings]\n'),
33
34
  (' '
34
35
  '[--dump] [--dvars DVARS] [--sqldb] [--outdir OUTDIR]\n'),
35
36
  (' '
@@ -88,6 +89,11 @@ def cli_tc_main():
88
89
  'to HTML files for viewing in browser.'),
89
90
  default=False,
90
91
  action="store_true")
92
+ parser.add_argument('--timings',
93
+ help=('optional flag that causes execution times to '
94
+ 'be written to stdout.'),
95
+ default=False,
96
+ action="store_true")
91
97
  parser.add_argument('--dump',
92
98
  help=('optional flag that causes OUTPUT to contain '
93
99
  'all INPUT variables (extrapolated to TAXYEAR) '
@@ -153,12 +159,21 @@ def cli_tc_main():
153
159
  sys.stderr.write(tcio.errmsg)
154
160
  sys.stderr.write('USAGE: tc --help\n')
155
161
  return 1
156
- aging = inputfn.endswith('puf.csv') or inputfn.endswith('cps.csv')
162
+ aging = (
163
+ inputfn.endswith('puf.csv') or
164
+ inputfn.endswith('cps.csv') or
165
+ inputfn.endswith('tmd.csv')
166
+ )
167
+ if args.timings:
168
+ stime = time.time()
157
169
  tcio.init(input_data=inputfn, tax_year=taxyear,
158
170
  baseline=args.baseline,
159
171
  reform=args.reform, assump=args.assump,
160
172
  aging_input_data=aging,
161
173
  exact_calculations=args.exact)
174
+ if args.timings:
175
+ xtime = time.time() - stime
176
+ sys.stdout.write(f'TIMINGS: init time = {xtime:.2f} secs\n')
162
177
  if tcio.errmsg:
163
178
  sys.stderr.write(tcio.errmsg)
164
179
  sys.stderr.write('USAGE: tc --help\n')
@@ -179,12 +194,17 @@ def cli_tc_main():
179
194
  sys.stderr.write('USAGE: tc --help\n')
180
195
  return 1
181
196
  # conduct tax analysis
197
+ if args.timings:
198
+ stime = time.time()
182
199
  tcio.analyze(writing_output_file=True,
183
200
  output_tables=args.tables,
184
201
  output_graphs=args.graphs,
185
202
  dump_varset=dumpvar_set,
186
203
  output_dump=args.dump,
187
204
  output_sqldb=args.sqldb)
205
+ if args.timings:
206
+ xtime = time.time() - stime
207
+ sys.stdout.write(f'TIMINGS: calc time = {xtime:.2f} secs\n')
188
208
  # compare test output with expected test output if --test option specified
189
209
  if args.test:
190
210
  retcode = _compare_test_output_files()
@@ -210,7 +230,7 @@ def _write_expected_test_output():
210
230
  ifile.write(input_data)
211
231
  expected_output_data = (
212
232
  'RECID,YEAR,WEIGHT,INCTAX,LSTAX,PAYTAX\n'
213
- '1,2018,0.00,139.87,0.00,6120.00\n'
233
+ '1,2018,0.00,131.88,0.00,6120.00\n'
214
234
  '2,2018,0.00,28879.00,0.00,21721.60\n'
215
235
  )
216
236
  with open(EXPECTED_TEST_OUTPUT_FILENAME, 'w') as ofile:
@@ -282,4 +282,4 @@
282
282
  }
283
283
  }
284
284
  }
285
- }
285
+ }
@@ -276,6 +276,6 @@ class Data():
276
276
 
277
277
  def _extrapolate(self, year):
278
278
  """
279
- Apply to dats variables the growth factor values for specified year.
279
+ Apply to data variables the growth factor values for specified year.
280
280
  """
281
281
  # Override this empty method in subclass
@@ -500,4 +500,4 @@
500
500
  }
501
501
  }
502
502
  }
503
- }
503
+ }
@@ -7,6 +7,7 @@ Tax-Calculator GrowDiff class that is used to modify GrowFactors.
7
7
  import os
8
8
  import numpy as np
9
9
  from taxcalc.parameters import Parameters
10
+ from taxcalc.policy import Policy
10
11
  from taxcalc.growfactors import GrowFactors
11
12
 
12
13
 
@@ -26,8 +27,8 @@ class GrowDiff(Parameters):
26
27
  class instance: GrowDiff
27
28
  """
28
29
 
29
- JSON_START_YEAR = 2013 # must be same as Policy.JSON_START_YEAR
30
- DEFAULT_NUM_YEARS = 22 # must be same as Policy.DEFAULT_NUM_YEARS
30
+ JSON_START_YEAR = Policy.JSON_START_YEAR
31
+ DEFAULT_NUM_YEARS = Policy.DEFAULT_NUM_YEARS
31
32
  DEFAULTS_FILE_NAME = 'growdiff.json'
32
33
  DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__))
33
34
 
@@ -75,8 +76,13 @@ class GrowDiff(Parameters):
75
76
  """
76
77
  assert isinstance(growfactors, GrowFactors)
77
78
  for gfvn in GrowFactors.VALID_NAMES:
78
- _gfvn = '_{}'.format(gfvn)
79
+ _gfvn = f'_{gfvn}'
79
80
  for i in range(0, self.num_years):
80
81
  cyr = i + self.start_year
81
82
  diff_array = getattr(self, _gfvn)
82
83
  growfactors.update(gfvn, cyr, diff_array[i])
84
+
85
+ def set_rates(self):
86
+ """
87
+ Unimplemented base class method that is not used here.
88
+ """
@@ -0,0 +1,65 @@
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
2
+ 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
3
+ 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
4
+ 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
5
+ 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
6
+ 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
7
+ 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
8
+ 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
9
+ 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
10
+ 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
11
+ 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
12
+ 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
13
+ 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
14
+ 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
15
+ 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
16
+ 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
17
+ 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
18
+ 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
19
+ 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
20
+ 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
21
+ 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
22
+ 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
23
+ 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
24
+ 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
25
+ 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
26
+ 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
27
+ 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
28
+ 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
29
+ 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
30
+ 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
31
+ 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
32
+ 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
33
+ 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
34
+ 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
35
+ 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
36
+ 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
37
+ 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
38
+ 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
39
+ 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
40
+ 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
41
+ 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
42
+ 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
43
+ 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
44
+ 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
45
+ 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
46
+ 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
47
+ 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
48
+ 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
49
+ 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
50
+ 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
51
+ 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
52
+ 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
53
+ 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
54
+ 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
55
+ 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
56
+ 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
57
+ 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
58
+ 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
59
+ 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
60
+ 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
61
+ 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
62
+ 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
63
+ 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
64
+ 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
65
+ 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
@@ -17,14 +17,15 @@ class GrowFactors():
17
17
 
18
18
  Parameters
19
19
  ----------
20
- growfactors_filename: string
21
- string is name of CSV file in which grow factors reside;
22
- default value is name of file containing baseline grow factors.
20
+ growfactors_filename: None or string
21
+ string is path to the CSV file in which grow factors reside;
22
+ default value of None uses file containing puf/cps grow factors.
23
23
 
24
24
  Raises
25
25
  ------
26
26
  ValueError:
27
- if growfactors_filename is not a string.
27
+ if growfactors_filename is neither None or a string.
28
+ if growfactors_filename string points to a non-existent file.
28
29
 
29
30
  Returns
30
31
  -------
@@ -33,10 +34,11 @@ class GrowFactors():
33
34
  Notes
34
35
  -----
35
36
  Typical usage is "gfactor = GrowFactors()", which produces an object
36
- containing the default growth factors in the GrowFactors.FILE_NAME file.
37
+ containing baseline growth factors in the GrowFactors.FILE_NAME file,
38
+ which is for use with puf and cps data from the taxdata repository.
37
39
  """
38
40
 
39
- FILE_NAME = 'growfactors.csv'
41
+ PACKAGE_FILE_NAMES = ['growfactors.csv', 'tmd_growfactors.csv']
40
42
  FILE_PATH = os.path.abspath(os.path.dirname(__file__))
41
43
 
42
44
  VALID_NAMES = set(['ABOOK', 'ACGNS', 'ACPIM', 'ACPIU',
@@ -48,24 +50,34 @@ class GrowFactors():
48
50
  'ABENSSI', 'ABENSNAP', 'ABENWIC',
49
51
  'ABENHOUSING', 'ABENTANF', 'ABENVET'])
50
52
 
51
- def __init__(self, growfactors_filename=FILE_NAME):
53
+ def __init__(self, growfactors_filename=None):
52
54
  # read grow factors from specified growfactors_filename
53
55
  gfdf = pd.DataFrame()
54
- if isinstance(growfactors_filename, str):
55
- full_filename = os.path.join(GrowFactors.FILE_PATH,
56
- growfactors_filename)
57
- if os.path.isfile(full_filename):
58
- gfdf = pd.read_csv(full_filename, index_col='YEAR')
59
- else: # find file in conda package
60
- gfdf = read_egg_csv(os.path.basename(growfactors_filename),
56
+ if growfactors_filename is None:
57
+ # read puf/cps growfactors from package
58
+ gfdf = read_egg_csv(GrowFactors.PACKAGE_FILE_NAMES[0],
59
+ index_col='YEAR') # pragma: no cover
60
+ elif isinstance(growfactors_filename, str):
61
+ if growfactors_filename in GrowFactors.PACKAGE_FILE_NAMES:
62
+ # read growfactors from package
63
+ gfdf = read_egg_csv(growfactors_filename,
61
64
  index_col='YEAR') # pragma: no cover
65
+ else:
66
+ if os.path.isfile(growfactors_filename):
67
+ gfdf = pd.read_csv(growfactors_filename, index_col='YEAR')
68
+ else: # file does not exist
69
+ msg = (
70
+ f'growfactors file {growfactors_filename} '
71
+ 'does not exist'
72
+ )
73
+ raise ValueError(msg)
62
74
  else:
63
75
  raise ValueError('growfactors_filename is not a string')
64
76
  assert isinstance(gfdf, pd.DataFrame)
65
77
  # check validity of gfdf column names
66
78
  gfdf_names = set(list(gfdf))
67
79
  if gfdf_names != GrowFactors.VALID_NAMES:
68
- msg = ('missing names are: {} and invalid names are: {}')
80
+ msg = 'missing names are: {} and invalid names are: {}'
69
81
  missing = GrowFactors.VALID_NAMES - gfdf_names
70
82
  invalid = gfdf_names - GrowFactors.VALID_NAMES
71
83
  raise ValueError(msg.format(missing, invalid))
@@ -143,17 +155,16 @@ class GrowFactors():
143
155
  if year > self.last_year:
144
156
  msg = 'year={} > GrowFactors.last_year={}'
145
157
  raise ValueError(msg.format(year, self.last_year))
146
- return self.gfdf[name][year]
158
+ return self.gfdf.loc[year, name]
147
159
 
148
160
  def update(self, name, year, diff):
149
161
  """
150
- Add to self.gfdf[name][year] the specified diff amount.
162
+ Add to self.gfdf (for name and year) the specified diff amount.
151
163
  """
152
164
  if self.used:
153
165
  msg = 'cannot update growfactors after they have been used'
154
166
  raise ValueError(msg)
155
167
  assert name in GrowFactors.VALID_NAMES
156
- assert year >= self.first_year
157
- assert year <= self.last_year
158
- assert isinstance(diff, float)
159
- self.gfdf[name][year] += diff
168
+ if year >= self.first_year and year <= self.last_year:
169
+ assert isinstance(diff, float)
170
+ self.gfdf.loc[year, name] += diff