taxcalc 4.2.1__py3-none-any.whl → 4.3.0__py3-none-any.whl

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 (123) hide show
  1. taxcalc/__init__.py +1 -1
  2. taxcalc/assumptions/ASSUMPTIONS.md +53 -0
  3. taxcalc/assumptions/README.md +17 -0
  4. taxcalc/assumptions/economic_assumptions_template.json +77 -0
  5. taxcalc/calcfunctions.py +7 -4
  6. taxcalc/data.py +10 -5
  7. taxcalc/policy.py +1 -1
  8. taxcalc/policy_current_law.json +4649 -288
  9. taxcalc/records.py +20 -15
  10. taxcalc/reforms/2017_law.json +125 -0
  11. taxcalc/reforms/2017_law.out.csv +10 -0
  12. taxcalc/reforms/ARPA.json +78 -0
  13. taxcalc/reforms/ARPA.out.csv +10 -0
  14. taxcalc/reforms/BrownKhanna.json +23 -0
  15. taxcalc/reforms/BrownKhanna.out.csv +10 -0
  16. taxcalc/reforms/CARES.json +40 -0
  17. taxcalc/reforms/CARES.out.csv +10 -0
  18. taxcalc/reforms/ConsolidatedAppropriationsAct2021.json +15 -0
  19. taxcalc/reforms/ConsolidatedAppropriationsAct2021.out.csv +10 -0
  20. taxcalc/reforms/Larson2019.json +36 -0
  21. taxcalc/reforms/Larson2019.out.csv +10 -0
  22. taxcalc/reforms/README.md +22 -0
  23. taxcalc/reforms/REFORMS.md +92 -0
  24. taxcalc/reforms/Renacci.json +61 -0
  25. taxcalc/reforms/Renacci.out.csv +10 -0
  26. taxcalc/reforms/SandersDeFazio.json +15 -0
  27. taxcalc/reforms/SandersDeFazio.out.csv +10 -0
  28. taxcalc/reforms/TCJA.json +160 -0
  29. taxcalc/reforms/TCJA.md +48 -0
  30. taxcalc/reforms/TCJA.out.csv +10 -0
  31. taxcalc/reforms/Trump2016.json +71 -0
  32. taxcalc/reforms/Trump2016.out.csv +10 -0
  33. taxcalc/reforms/Trump2017.json +51 -0
  34. taxcalc/reforms/Trump2017.out.csv +10 -0
  35. taxcalc/reforms/archive/Clinton2016.json +56 -0
  36. taxcalc/reforms/archive/RyanBrady.json +104 -0
  37. taxcalc/reforms/archive/TCJA_House.json +144 -0
  38. taxcalc/reforms/archive/TCJA_House_Amended.json +152 -0
  39. taxcalc/reforms/archive/TCJA_Reconciliation.json +187 -0
  40. taxcalc/reforms/archive/TCJA_Senate.json +116 -0
  41. taxcalc/reforms/archive/TCJA_Senate_111417.json +169 -0
  42. taxcalc/reforms/archive/TCJA_Senate_120117.json +174 -0
  43. taxcalc/reforms/cases.csv +10 -0
  44. taxcalc/reforms/clp.out.csv +10 -0
  45. taxcalc/reforms/ext.json +59 -0
  46. taxcalc/reforms/growfactors_ext.csv +65 -0
  47. taxcalc/reforms/ptaxes0.json +37 -0
  48. taxcalc/reforms/ptaxes0.out.csv +10 -0
  49. taxcalc/reforms/ptaxes1.json +21 -0
  50. taxcalc/reforms/ptaxes1.out.csv +10 -0
  51. taxcalc/reforms/ptaxes2.json +18 -0
  52. taxcalc/reforms/ptaxes2.out.csv +10 -0
  53. taxcalc/reforms/ptaxes3.json +28 -0
  54. taxcalc/reforms/ptaxes3.out.csv +10 -0
  55. taxcalc/taxcalcio.py +44 -22
  56. taxcalc/tests/benefits_expect.csv +169 -0
  57. taxcalc/tests/cmpi_cps_expect.txt +132 -0
  58. taxcalc/tests/cmpi_puf_expect.txt +132 -0
  59. taxcalc/tests/conftest.py +143 -0
  60. taxcalc/tests/cpscsv_agg_expect.csv +26 -0
  61. taxcalc/tests/puf_var_correl_coeffs_2016.csv +80 -0
  62. taxcalc/tests/puf_var_wght_means_by_year.csv +80 -0
  63. taxcalc/tests/pufcsv_agg_expect.csv +26 -0
  64. taxcalc/tests/pufcsv_mtr_expect.txt +63 -0
  65. taxcalc/tests/reforms.json +649 -0
  66. taxcalc/tests/reforms_expect.csv +65 -0
  67. taxcalc/tests/test_4package.py +67 -0
  68. taxcalc/tests/test_benefits.py +86 -0
  69. taxcalc/tests/test_calcfunctions.py +871 -0
  70. taxcalc/tests/test_calculator.py +1021 -0
  71. taxcalc/tests/test_compare.py +336 -0
  72. taxcalc/tests/test_compatible_data.py +338 -0
  73. taxcalc/tests/test_consumption.py +144 -0
  74. taxcalc/tests/test_cpscsv.py +163 -0
  75. taxcalc/tests/test_data.py +133 -0
  76. taxcalc/tests/test_decorators.py +332 -0
  77. taxcalc/tests/test_growdiff.py +102 -0
  78. taxcalc/tests/test_growfactors.py +94 -0
  79. taxcalc/tests/test_parameters.py +617 -0
  80. taxcalc/tests/test_policy.py +1557 -0
  81. taxcalc/tests/test_puf_var_stats.py +194 -0
  82. taxcalc/tests/test_pufcsv.py +385 -0
  83. taxcalc/tests/test_records.py +234 -0
  84. taxcalc/tests/test_reforms.py +386 -0
  85. taxcalc/tests/test_responses.py +41 -0
  86. taxcalc/tests/test_taxcalcio.py +755 -0
  87. taxcalc/tests/test_utils.py +792 -0
  88. taxcalc/validation/CSV_INPUT_VARS.md +29 -0
  89. taxcalc/validation/CSV_OUTPUT_VARS.md +63 -0
  90. taxcalc/validation/README.md +68 -0
  91. taxcalc/validation/taxsim35/Differences_Explained.md +54 -0
  92. taxcalc/validation/taxsim35/README.md +139 -0
  93. taxcalc/validation/taxsim35/expected_differences/a17-taxdiffs-expect.csv +25 -0
  94. taxcalc/validation/taxsim35/expected_differences/a18-taxdiffs-expect.csv +25 -0
  95. taxcalc/validation/taxsim35/expected_differences/a19-taxdiffs-expect.csv +25 -0
  96. taxcalc/validation/taxsim35/expected_differences/a20-taxdiffs-expect.csv +25 -0
  97. taxcalc/validation/taxsim35/expected_differences/a21-taxdiffs-expect.csv +25 -0
  98. taxcalc/validation/taxsim35/expected_differences/b17-taxdiffs-expect.csv +25 -0
  99. taxcalc/validation/taxsim35/expected_differences/b18-taxdiffs-expect.csv +25 -0
  100. taxcalc/validation/taxsim35/expected_differences/b19-taxdiffs-expect.csv +25 -0
  101. taxcalc/validation/taxsim35/expected_differences/b20-taxdiffs-expect.csv +25 -0
  102. taxcalc/validation/taxsim35/expected_differences/b21-taxdiffs-expect.csv +25 -0
  103. taxcalc/validation/taxsim35/expected_differences/c17-taxdiffs-expect.csv +25 -0
  104. taxcalc/validation/taxsim35/expected_differences/c18-taxdiffs-expect.csv +25 -0
  105. taxcalc/validation/taxsim35/expected_differences/c19-taxdiffs-expect.csv +25 -0
  106. taxcalc/validation/taxsim35/input_setup.py +67 -0
  107. taxcalc/validation/taxsim35/main_comparison.py +183 -0
  108. taxcalc/validation/taxsim35/prepare_taxcalc_input.py +161 -0
  109. taxcalc/validation/taxsim35/process_taxcalc_output.py +140 -0
  110. taxcalc/validation/taxsim35/taxsim_emulation.json +49 -0
  111. taxcalc/validation/taxsim35/taxsim_input.py +321 -0
  112. taxcalc/validation/taxsim35/tc_sims.py +98 -0
  113. taxcalc/validation/taxsim35/tests_35.py +80 -0
  114. taxcalc/validation/tests_35.sh +13 -0
  115. {taxcalc-4.2.1.dist-info → taxcalc-4.3.0.dist-info}/METADATA +3 -4
  116. taxcalc-4.3.0.dist-info/RECORD +139 -0
  117. {taxcalc-4.2.1.dist-info → taxcalc-4.3.0.dist-info}/WHEEL +1 -1
  118. taxcalc/tmd_growfactors.csv +0 -55
  119. taxcalc/tmd_weights.csv.gz +0 -0
  120. taxcalc-4.2.1.dist-info/RECORD +0 -34
  121. {taxcalc-4.2.1.dist-info → taxcalc-4.3.0.dist-info}/LICENSE +0 -0
  122. {taxcalc-4.2.1.dist-info → taxcalc-4.3.0.dist-info}/entry_points.txt +0 -0
  123. {taxcalc-4.2.1.dist-info → taxcalc-4.3.0.dist-info}/top_level.txt +0 -0
taxcalc/__init__.py CHANGED
@@ -14,4 +14,4 @@ from taxcalc.taxcalcio import *
14
14
  from taxcalc.utils import *
15
15
  from taxcalc.cli import *
16
16
 
17
- __version__ = '4.2.1'
17
+ __version__ = '4.3.0'
@@ -0,0 +1,53 @@
1
+ # HOW TO SPECIFY ECONOMIC ASSUMPTIONS IN A JSON ASSUMPTION FILE
2
+
3
+ There is a way to specify in a text file the collection of economic
4
+ assumptions about how individuals and the overall economy respond to a
5
+ tax reform.
6
+
7
+ Here we provide a link to an economic assumptions template file, and
8
+ then provide a more general explanation of the structure and syntax of
9
+ assumption files.
10
+
11
+ ## Example of an Economic Assumption File
12
+
13
+ The following example serves as a template:
14
+
15
+ - [Economic Assumptions Template](economic_assumptions_template.json)
16
+
17
+ ## Structure and Syntax of Assumption Files
18
+
19
+ The assumption files are JSON files. JSON, which stands for
20
+ JavaScript Object Notation, is an easy way to specify structured
21
+ information that is widely used. Below we provide an abstract example
22
+ of a JSON assumption file with some explanation.
23
+
24
+ Here is an abstract example of an economic assumption file that
25
+ consists of several parameters. The structure of this file is as
26
+ follows:
27
+
28
+ ```
29
+ {
30
+ "consumption": {
31
+ <parameter_name>: {<calyear>: <parameter-value>}
32
+ },
33
+ "growdiff_baseline": {
34
+ },
35
+ "growdiff_response": {
36
+ <parameter_name>: {<calyear>: <parameter-value>}
37
+ }
38
+ }
39
+ ```
40
+
41
+ Notice that an assumption file must always contain these top-level keys:
42
+ consumption, growdiff_baseline, and growdiff_response.
43
+ Any key can have an empty value like the growdiff_baseline key above.
44
+ Empty values mean that the default assumption parameter values are
45
+ used.
46
+
47
+ The rules about structuring a non-empty value for a top-level key are
48
+ the same as for policy reform files, which are described
49
+ [here](https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/reforms/REFORMS.md#how-to-specify-a-tax-reform-in-a-json-policy-reform-file).
50
+ The assumption parameter names recognized by Tax-Calculator, and their
51
+ default values, are listed in [this
52
+ section](https://PSLmodels.github.io/Tax-Calculator/uguide.html#params)
53
+ of the user guide.
@@ -0,0 +1,17 @@
1
+ Economic Assumption Files
2
+ -------------------------
3
+
4
+ This directory contains an example of an economic assumption file that can
5
+ be combined and modified to construct your own economic assumption files
6
+ that are stored on your local computer.
7
+
8
+ Such an economic assumption file can then be used by the `tc`
9
+ command-line interface to Tax-Calculator or be read in a Python
10
+ program that imports the Tax-Calculator `taxcalc` package, as
11
+ described in the [user
12
+ guide](https://PSLmodels.github.io/Tax-Calculator/uguide.html).
13
+
14
+ [This
15
+ document](https://github.com/PSLmodels/Tax-Calculator/blob/master/taxcalc/assumptions/ASSUMPTIONS.md#how-to-specify-economic-assumptions-in-a-json-assumption-file)
16
+ provides access to a template economic assumption file and guidelines
17
+ about how to prepare your own assumption files.
@@ -0,0 +1,77 @@
1
+ // Parameters used to specify economic assumptions used in tax policy analysis.
2
+ //
3
+ // This JSON file serves as a template for specifying economic assumptions
4
+ // about how individuals and the overall economy respond to a tax reform.
5
+ //
6
+ // Detailed documentation on these parameters can be found at
7
+ // <http://PSLmodels.github.io/Tax-Calculator/#params>.
8
+ {
9
+ "consumption": {
10
+ "MPC_e17500": {"2017": 0.0},
11
+ "MPC_e18400": {"2017": 0.0},
12
+ "MPC_e19800": {"2017": 0.0},
13
+ "MPC_e20400": {"2017": 0.0},
14
+ "BEN_housing_value": {"2017": 1.0},
15
+ "BEN_snap_value": {"2017": 1.0},
16
+ "BEN_tanf_value": {"2017": 1.0},
17
+ "BEN_vet_value": {"2017": 1.0},
18
+ "BEN_wic_value": {"2017": 1.0},
19
+ "BEN_mcare_value": {"2017": 1.0},
20
+ "BEN_mcaid_value": {"2017": 1.0},
21
+ "BEN_other_value": {"2017": 1.0}
22
+ },
23
+ "growdiff_baseline": {
24
+ "ABOOK": {"2017": 0.0},
25
+ "ACGNS": {"2017": 0.0},
26
+ "ACPIM": {"2017": 0.0},
27
+ "ACPIU": {"2017": 0.0},
28
+ "ADIVS": {"2017": 0.0},
29
+ "AINTS": {"2017": 0.0},
30
+ "AIPD": {"2017": 0.0},
31
+ "ASCHCI": {"2017": 0.0},
32
+ "ASCHCL": {"2017": 0.0},
33
+ "ASCHEI": {"2017": 0.0},
34
+ "ASCHEL": {"2017": 0.0},
35
+ "ASCHF": {"2017": 0.0},
36
+ "ASOCSEC": {"2017": 0.0},
37
+ "ATXPY": {"2017": 0.0},
38
+ "AUCOMP": {"2017": 0.0},
39
+ "AWAGE": {"2017": 0.0},
40
+ "ABENOTHER": {"2017": 0.0},
41
+ "ABENMCARE": {"2017": 0.0},
42
+ "ABENMCAID": {"2017": 0.0},
43
+ "ABENSSI": {"2017": 0.0},
44
+ "ABENSNAP": {"2017": 0.0},
45
+ "ABENWIC": {"2017": 0.0},
46
+ "ABENHOUSING": {"2017": 0.0},
47
+ "ABENTANF": {"2017": 0.0},
48
+ "ABENVET": {"2017": 0.0}
49
+ },
50
+ "growdiff_response": {
51
+ "ABOOK": {"2017": 0.0},
52
+ "ACGNS": {"2017": 0.0},
53
+ "ACPIM": {"2017": 0.0},
54
+ "ACPIU": {"2017": 0.0},
55
+ "ADIVS": {"2017": 0.0},
56
+ "AINTS": {"2017": 0.0},
57
+ "AIPD": {"2017": 0.0},
58
+ "ASCHCI": {"2017": 0.0},
59
+ "ASCHCL": {"2017": 0.0},
60
+ "ASCHEI": {"2017": 0.0},
61
+ "ASCHEL": {"2017": 0.0},
62
+ "ASCHF": {"2017": 0.0},
63
+ "ASOCSEC": {"2017": 0.0},
64
+ "ATXPY": {"2017": 0.0},
65
+ "AUCOMP": {"2017": 0.0},
66
+ "AWAGE": {"2017": 0.0},
67
+ "ABENOTHER": {"2017": 0.0},
68
+ "ABENMCARE": {"2017": 0.0},
69
+ "ABENMCAID": {"2017": 0.0},
70
+ "ABENSSI": {"2017": 0.0},
71
+ "ABENSNAP": {"2017": 0.0},
72
+ "ABENWIC": {"2017": 0.0},
73
+ "ABENHOUSING": {"2017": 0.0},
74
+ "ABENTANF": {"2017": 0.0},
75
+ "ABENVET": {"2017": 0.0}
76
+ }
77
+ }
taxcalc/calcfunctions.py CHANGED
@@ -2809,7 +2809,7 @@ def SchR(age_head, age_spouse, MARS, c00100,
2809
2809
 
2810
2810
 
2811
2811
  @iterate_jit(nopython=True)
2812
- def EducationTaxCredit(exact, e87530, MARS, c00100, num, c05800,
2812
+ def EducationTaxCredit(exact, e87530, MARS, c00100, c05800,
2813
2813
  e07300, c07180, c07200, c87668,
2814
2814
  LLC_Expense_c, ETC_pe_Single, ETC_pe_Married,
2815
2815
  CR_Education_hc,
@@ -2828,8 +2828,6 @@ def EducationTaxCredit(exact, e87530, MARS, c00100, num, c05800,
2828
2828
  Filing (marital) status. (1=single, 2=joint, 3=separate, 4=household-head, 5=widow(er))
2829
2829
  c00100: float
2830
2830
  Adjusted Gross Income (AGI)
2831
- num: int
2832
- 2 when MARS is 2 (married filing jointly), otherwise 1
2833
2831
  c05800: float
2834
2832
  Total (regular + AMT) income tax liability before credits
2835
2833
  e07300: float
@@ -2860,14 +2858,19 @@ def EducationTaxCredit(exact, e87530, MARS, c00100, num, c05800,
2860
2858
  -----
2861
2859
  Tax Law Parameters that are not parameterized:
2862
2860
  0.2: Lifetime Learning Credit ratio against expense
2861
+ 10000.0: AGI range bewteen ETC_pe_Single and single phase-out start;
2862
+ twice this amount for ETC_pe_Married
2863
2863
  """
2864
2864
  c87560 = 0.2 * min(e87530, LLC_Expense_c)
2865
+ # on the following credit phase-out law see:
2866
+ # https://www.law.cornell.edu/uscode/text/26/25A#d_1
2865
2867
  if MARS == 2:
2866
2868
  c87570 = ETC_pe_Married * 1000.
2869
+ c87600 = 20000.
2867
2870
  else:
2868
2871
  c87570 = ETC_pe_Single * 1000.
2872
+ c87600 = 10000.
2869
2873
  c87590 = max(0., c87570 - c00100)
2870
- c87600 = 10000. * num
2871
2874
  if exact == 1: # exact calculation as on tax forms
2872
2875
  c87610 = min(1., round(c87590 / c87600, 3))
2873
2876
  else:
taxcalc/data.py CHANGED
@@ -102,7 +102,7 @@ class Data():
102
102
  # ... weights must be same size as data
103
103
  if self.array_length > len(self.WT.index):
104
104
  raise ValueError("Data has more records than weights.")
105
- elif self.array_length < len(self.WT.index):
105
+ if self.array_length < len(self.WT.index):
106
106
  # scale-up sub-sample weights by year-specific factor
107
107
  sum_full_weights = self.WT.sum()
108
108
  self.WT = self.WT.iloc[self.__index]
@@ -110,9 +110,11 @@ class Data():
110
110
  factor = sum_full_weights / sum_sub_weights
111
111
  self.WT *= factor
112
112
  # ... construct sample weights for current_year
113
- wt_colname = 'WT{}'.format(self.current_year)
114
- if wt_colname in self.WT.columns:
115
- self.s006 = self.WT[wt_colname] * 0.01
113
+ wt_colname = f'WT{self.current_year}'
114
+ assert wt_colname in self.WT.columns, (
115
+ f'no weights for start year {self.current_year}'
116
+ )
117
+ self.s006 = self.WT[wt_colname] * 0.01
116
118
 
117
119
  @property
118
120
  def data_year(self):
@@ -146,7 +148,10 @@ class Data():
146
148
  # ... apply variable extrapolation growth factors
147
149
  self._extrapolate(self.__current_year)
148
150
  # ... specify current-year sample weights
149
- wt_colname = 'WT{}'.format(self.__current_year)
151
+ wt_colname = f'WT{self.__current_year}'
152
+ assert wt_colname in self.WT.columns, (
153
+ f'no weights for new year {self.current_year}'
154
+ )
150
155
  self.s006 = self.WT[wt_colname] * 0.01
151
156
 
152
157
  # ----- begin private methods of Data class -----
taxcalc/policy.py CHANGED
@@ -37,7 +37,7 @@ class Policy(Parameters):
37
37
  DEFAULTS_FILE_NAME = 'policy_current_law.json'
38
38
  DEFAULTS_FILE_PATH = os.path.abspath(os.path.dirname(__file__))
39
39
  JSON_START_YEAR = 2013 # remains the same unless earlier data added
40
- LAST_KNOWN_YEAR = 2022 # last year for which indexed param vals are known
40
+ LAST_KNOWN_YEAR = 2024 # last year for which indexed param vals are known
41
41
  # should increase LAST_KNOWN_YEAR by one every calendar year
42
42
  LAST_BUDGET_YEAR = 2034 # last extrapolation year
43
43
  # should increase LAST_BUDGET_YEAR by one every calendar year