From 656cd554ef0225a4e983457048b6acf06ff258b2 Mon Sep 17 00:00:00 2001
From: Martin Holmer
Date: Tue, 5 Feb 2019 14:35:37 -0500
Subject: [PATCH 1/6] Add removed_param_names set to policy.py
---
taxcalc/policy.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/taxcalc/policy.py b/taxcalc/policy.py
index e8cb80458..5bd7c370e 100644
--- a/taxcalc/policy.py
+++ b/taxcalc/policy.py
@@ -451,7 +451,9 @@ def _validate_parameter_names_types(self, reform):
in the specified reform dictionary.
"""
# pylint: disable=too-many-branches,too-many-nested-blocks
- # pylint: disable=too-many-locals
+ # pylint: disable=too-many-statements,too-many-locals
+ removed_param_names = set([
+ ])
param_names = set(self._vals.keys())
for year in sorted(reform.keys()):
for name in reform[year]:
@@ -459,7 +461,10 @@ def _validate_parameter_names_types(self, reform):
if isinstance(reform[year][name], bool):
pname = name[:-4] # root parameter name
if pname not in param_names:
- msg = '{} {} unknown parameter name'
+ if pname in removed_param_names:
+ msg = '{} {} is a removed parameter name'
+ else:
+ msg = '{} {} is an unknown parameter name'
self.parameter_errors += (
'ERROR: ' + msg.format(year, name) + '\n'
)
@@ -477,7 +482,10 @@ def _validate_parameter_names_types(self, reform):
)
else: # if name does not end with '_cpi'
if name not in param_names:
- msg = '{} {} unknown parameter name'
+ if name in removed_param_names:
+ msg = '{} {} is a removed parameter name'
+ else:
+ msg = '{} {} is an unknown parameter name'
self.parameter_errors += (
'ERROR: ' + msg.format(year, name) + '\n'
)
From 8f8da66d8dbca877311e465a5a85ca7ec94d4320 Mon Sep 17 00:00:00 2001
From: Martin Holmer
Date: Tue, 5 Feb 2019 17:40:14 -0500
Subject: [PATCH 2/6] Rename/remove a few policy parameters
---
docs/index.htmx | 15 ++-
taxcalc/calcfunctions.py | 57 ++++--------
taxcalc/policy.py | 4 +
taxcalc/policy_current_law.json | 152 ++++++++++---------------------
taxcalc/records_variables.json | 4 +-
taxcalc/reforms/2017_law.json | 5 +-
taxcalc/reforms/TCJA.json | 20 ++--
taxcalc/tests/conftest.py | 2 +-
taxcalc/tests/reforms.json | 39 ++------
taxcalc/tests/reforms_expect.csv | 18 ++--
taxcalc/tests/test_policy.py | 10 +-
taxcalc/tests/test_reforms.py | 2 +-
12 files changed, 118 insertions(+), 210 deletions(-)
diff --git a/docs/index.htmx b/docs/index.htmx
index 397525f10..ce7d91869 100644
--- a/docs/index.htmx
+++ b/docs/index.htmx
@@ -1029,8 +1029,6 @@ section.
-
-
@@ -1038,6 +1036,17 @@ section.
Back to Section Contents
+Child/Dependent Credits
+
+
+
+
+
+
+
+Back to Section Contents
+
+
Itemized Deductions
@@ -1098,8 +1107,6 @@ section.
-
-
diff --git a/taxcalc/calcfunctions.py b/taxcalc/calcfunctions.py
index 9512d9a14..b68dbd126 100644
--- a/taxcalc/calcfunctions.py
+++ b/taxcalc/calcfunctions.py
@@ -283,7 +283,7 @@ def ALD_InvInc_ec_base(p22250, p23250, sep,
@iterate_jit(nopython=True)
def CapGains(p23250, p22250, sep, ALD_StudentLoan_hc,
- ALD_InvInc_ec_rt, invinc_ec_base, ALD_InvInc_ec_base_RyanBrady,
+ ALD_InvInc_ec_rt, invinc_ec_base,
e00200, e00300, e00600, e00650, e00700, e00800,
CG_nodiff, CG_ec, CG_reinvest_ec_rt,
ALD_BusinessLosses_c, MARS,
@@ -301,18 +301,6 @@ def CapGains(p23250, p22250, sep, ALD_StudentLoan_hc,
invinc = e00300 + e00600 + c01000 + e01100 + e01200
# compute exclusion of investment income from AGI
invinc_agi_ec = ALD_InvInc_ec_rt * max(0., invinc_ec_base)
- # compute exclusion of investment income for Ryan-Brady plan
- if ALD_InvInc_ec_base_RyanBrady:
- # This RyanBrady code interprets the Blueprint reform as providing
- # an investment income AGI exclusion for each of three investment
- # income types (e00300, e00650, p23250) separately. The alternative
- # interpretation (that is not adopted here) is that the investment
- # income AGI exclusion is calculated using a base that is the sum
- # of those three investment income types, with the base being zero
- # if the sum of the three is negative.
- CG_ec_RyanBrady = (c01000 - max(-3000. / sep,
- p22250 + ALD_InvInc_ec_rt * p23250))
- invinc_agi_ec = ALD_InvInc_ec_rt * (e00300 + e00650) + CG_ec_RyanBrady
# compute ymod1 variable that is included in AGI
ymod1 = (e00200 + e00700 + e00800 + e01400 + e01700 +
invinc - invinc_agi_ec + e02100 + e02300 +
@@ -1233,20 +1221,17 @@ def ChildDepTaxCredit(n24, MARS, c00100, XTOT, num, c05800,
c07230,
e07240, CR_RetirementSavings_hc,
c07200,
- CTC_c, CTC_ps, CTC_prt, exact,
- DependentCredit_Child_c, DependentCredit_Nonchild_c,
+ CTC_c, CTC_ps, CTC_prt, exact, ODC_c,
CTC_c_under5_bonus, nu05, FilerCredit_c,
- c07220, dep_credit, codtc_limited):
+ c07220, odc, codtc_limited):
"""
Computes amounts on "Child Tax Credit and Credit for Other Dependents
Worksheet" in 2018 Publication 972, which pertain to these two
nonrefundable tax credits.
"""
# Worksheet Part 1
- line1 = ((CTC_c + DependentCredit_Child_c) * n24 +
- CTC_c_under5_bonus * nu05)
- line2 = (DependentCredit_Nonchild_c * max(0, XTOT - n24 - num) +
- FilerCredit_c[MARS - 1])
+ line1 = CTC_c * n24 + CTC_c_under5_bonus * nu05
+ line2 = ODC_c * max(0, XTOT - n24 - num) + FilerCredit_c[MARS - 1]
line3 = line1 + line2
modAGI = c00100 # no foreign earned income exclusion to add to AGI (line6)
if line3 > 0. and modAGI > CTC_ps[MARS - 1]:
@@ -1273,14 +1258,14 @@ def ChildDepTaxCredit(n24, MARS, c00100, XTOT, num, c05800,
line16 = 0.
# separate the CTC and ODTC amounts
c07220 = 0. # nonrefundable CTC amount
- dep_credit = 0. # nonrefundable ODTC amount
+ odc = 0. # nonrefundable ODTC amount
if line16 > 0.:
if line1 > 0.:
c07220 = line16 * line1 / line3
- dep_credit = max(0., line16 - c07220)
+ odc = max(0., line16 - c07220)
# compute codtc_limited for use in AdditionalCTC function
codtc_limited = max(0., line10 - line16)
- return (c07220, dep_credit, codtc_limited)
+ return (c07220, odc, codtc_limited)
@iterate_jit(nopython=True)
@@ -1500,14 +1485,13 @@ def CharityCredit(e19800, e20100, c00100, CR_Charity_rt, CR_Charity_f,
@iterate_jit(nopython=True)
def NonrefundableCredits(c05800, e07240, e07260, e07300, e07400,
- e07600, p08000, dep_credit,
+ e07600, p08000, odc,
personal_nonrefundable_credit,
CR_RetirementSavings_hc, CR_ForeignTax_hc,
CR_ResidentialEnergy_hc, CR_GeneralBusiness_hc,
CR_MinimumTax_hc, CR_OtherCredits_hc, charity_credit,
c07180, c07200, c07220, c07230, c07240,
- c07260, c07300, c07400, c07600, c08000,
- DependentCredit_before_CTC):
+ c07260, c07300, c07400, c07600, c08000):
"""
NonRefundableCredits function sequentially limits credits to tax liability.
@@ -1534,13 +1518,12 @@ def NonrefundableCredits(c05800, e07240, e07260, e07300, e07400,
# Retirement savings credit - Form 8880
c07240 = min(e07240 * (1. - CR_RetirementSavings_hc), avail)
avail = avail - c07240
- if DependentCredit_before_CTC:
- # Other dependent credit
- dep_credit = min(dep_credit, avail)
- avail = avail - dep_credit
# Child tax credit
c07220 = min(c07220, avail)
avail = avail - c07220
+ # Other dependent credit
+ odc = min(odc, avail)
+ avail = avail - odc
# Residential energy credit - Form 5695
c07260 = min(e07260 * (1. - CR_ResidentialEnergy_hc), avail)
avail = avail - c07260
@@ -1553,10 +1536,6 @@ def NonrefundableCredits(c05800, e07240, e07260, e07300, e07400,
# Schedule R credit
c07200 = min(c07200, avail)
avail = avail - c07200
- if not DependentCredit_before_CTC:
- # Dependent credit
- dep_credit = min(dep_credit, avail)
- avail = avail - dep_credit
# Other credits
c08000 = min(p08000 * (1. - CR_OtherCredits_hc), avail)
avail = avail - c08000
@@ -1565,13 +1544,13 @@ def NonrefundableCredits(c05800, e07240, e07260, e07300, e07400,
# Personal nonrefundable credit
personal_nonrefundable_credit = min(personal_nonrefundable_credit, avail)
avail = avail - personal_nonrefundable_credit
- return (c07180, c07200, c07220, c07230, c07240, dep_credit,
+ return (c07180, c07200, c07220, c07230, c07240, odc,
c07260, c07300, c07400, c07600, c08000, charity_credit,
personal_nonrefundable_credit)
@iterate_jit(nopython=True)
-def AdditionalCTC(codtc_limited, CTC_c, n24, earned, ACTC_Income_thd,
+def AdditionalCTC(codtc_limited, ACTC_c, n24, earned, ACTC_Income_thd,
ACTC_rt, nu05, ACTC_rt_bonus_under5family, ACTC_ChildNum,
ptax_was, c03260, e09800, c59660, e11200,
c11070):
@@ -1581,7 +1560,7 @@ def AdditionalCTC(codtc_limited, CTC_c, n24, earned, ACTC_Income_thd,
"""
# Part I
line3 = codtc_limited
- line4 = CTC_c * n24
+ line4 = ACTC_c * n24
c11070 = 0. # line15
if line3 > 0. and line4 > 0.:
line5 = min(line3, line4)
@@ -1612,7 +1591,7 @@ def AdditionalCTC(codtc_limited, CTC_c, n24, earned, ACTC_Income_thd,
@iterate_jit(nopython=True)
def C1040(c05800, c07180, c07200, c07220, c07230, c07240, c07260, c07300,
c07400, c07600, c08000, e09700, e09800, e09900, niit, othertaxes,
- c07100, c09200, dep_credit, charity_credit,
+ c07100, c09200, odc, charity_credit,
personal_nonrefundable_credit):
"""
Computes total used nonrefundable credits, c07100, othertaxes, and
@@ -1620,7 +1599,7 @@ def C1040(c05800, c07180, c07200, c07220, c07230, c07240, c07260, c07300,
"""
# total used nonrefundable credits (as computed in NonrefundableCredits)
c07100 = (c07180 + c07200 + c07600 + c07300 + c07400 + c07220 + c08000 +
- c07230 + c07240 + c07260 + dep_credit + charity_credit +
+ c07230 + c07240 + c07260 + odc + charity_credit +
personal_nonrefundable_credit)
# tax after credits (2016 Form 1040, line 56)
tax_net_nonrefundable_credits = max(0., c05800 - c07100)
diff --git a/taxcalc/policy.py b/taxcalc/policy.py
index 5bd7c370e..a6d102a73 100644
--- a/taxcalc/policy.py
+++ b/taxcalc/policy.py
@@ -453,6 +453,10 @@ def _validate_parameter_names_types(self, reform):
# pylint: disable=too-many-branches,too-many-nested-blocks
# pylint: disable=too-many-statements,too-many-locals
removed_param_names = set([
+ '_DependentCredit_Child_c',
+ '_DependentCredit_Nonchild_c',
+ '_DependentCredit_before_CTC',
+ '_ALD_InvInc_ec_base_RyanBrady'
])
param_names = set(self._vals.keys())
for year in sorted(reform.keys()):
diff --git a/taxcalc/policy_current_law.json b/taxcalc/policy_current_law.json
index ff419140e..94d1f1989 100644
--- a/taxcalc/policy_current_law.json
+++ b/taxcalc/policy_current_law.json
@@ -647,30 +647,6 @@
"compatible_data": {"puf": true, "cps": true}
},
- "_ALD_InvInc_ec_base_RyanBrady": {
- "long_name": "Investment income exclusion base for Ryan-Brady tax blueprint",
- "description": "Exclusion is applied to long-term gains before loss limitation, taxable interest and qualified dividends. Interpretation of the sparsely-detailed Ryan-Brady provision.",
- "section_1": "Above The Line Deductions",
- "section_2": "Misc. Exclusions",
- "irs_ref": "",
- "notes": "",
- "row_var": "FLPDYR",
- "row_label": ["2013"],
- "start_year": 2013,
- "cpi_inflatable": false,
- "cpi_inflated": false,
- "col_var": "",
- "col_label": "",
- "boolean_value": true,
- "integer_value": false,
- "value": [false],
- "range": {"min": false, "max": true},
- "out_of_range_minmsg": "",
- "out_of_range_maxmsg": "",
- "out_of_range_action": "stop",
- "compatible_data": {"puf": true, "cps": false}
- },
-
"_ALD_Dependents_hc": {
"long_name": "Deduction for childcare costs haircut",
"description": "This decimal fraction, if greater than zero, reduces the portion of childcare costs that can be deducted from AGI.",
@@ -5057,9 +5033,9 @@
},
"_CTC_c": {
- "long_name": "Maximum child tax credit per child",
- "description": "The maximum amount of credit allowed for each child.",
- "section_1": "Nonrefundable Credits",
+ "long_name": "Maximum nonrefundable child tax credit per child",
+ "description": "The maximum nonrefundable credit allowed for each child.",
+ "section_1": "Child/Dependent Credits",
"section_2": "Child Tax Credit",
"irs_ref": "Form 1040, line 12, worksheet, line 1.",
"notes": "",
@@ -5090,14 +5066,14 @@
1000.0,
1000.0,
1000.0,
- 1400.0,
- 1400.0,
- 1400.0,
- 1400.0,
- 1500.0,
- 1500.0,
- 1500.0,
- 1600.0,
+ 2000.0,
+ 2000.0,
+ 2000.0,
+ 2000.0,
+ 2000.0,
+ 2000.0,
+ 2000.0,
+ 2000.0,
1000.0],
"range": {"min": 0, "max": 9e99},
"out_of_range_minmsg": "",
@@ -5109,7 +5085,7 @@
"_CTC_c_under5_bonus": {
"long_name": "Bonus child tax credit maximum for qualifying children under five",
"description": "The maximum amount of child tax credit allowed for each child is increased by this amount for qualifying children under 5 years old.",
- "section_1": "Nonrefundable Credits",
+ "section_1": "Child/Dependent Credits",
"section_2": "Child Tax Credit",
"irs_ref": "",
"notes": "",
@@ -5133,7 +5109,7 @@
"_CTC_ps": {
"long_name": "Child tax credit phaseout MAGI start",
"description": "Child tax credit begins to decrease when MAGI is above this level; read descriptions of the dependent credit amounts for how they phase out when MAGI is above this level.",
- "section_1": "Nonrefundable Credits",
+ "section_1": "Child/Dependent Credits",
"section_2": "Child Tax Credit",
"irs_ref": "Form 1040, line 12, worksheet, line 5.",
"notes": "",
@@ -5183,7 +5159,7 @@
"_CTC_prt": {
"long_name": "Child and dependent tax credit phaseout rate",
"description": "The amount of the credit starts to decrease at this rate if MAGI is higher than child tax credit phaseout start.",
- "section_1": "Nonrefundable Credits",
+ "section_1": "Child/Dependent Credits",
"section_2": "Child Tax Credit",
"irs_ref": "Form 1040, line 12, instruction (child tax credit worksheet, line 7)",
"notes": "",
@@ -5204,13 +5180,13 @@
"compatible_data": {"puf": true, "cps": true}
},
- "_DependentCredit_Child_c": {
- "long_name": "Nonrefundable credit for child dependents on top of the child tax credit",
- "description": "This nonrefundable credit is applied to child dependents and phases out exactly like the CTC amount.",
- "section_1": "Nonrefundable Credits",
- "section_2": "Child Tax Credit",
+ "_ACTC_c": {
+ "long_name": "Maximum refundable additional child tax credit",
+ "description": "This refundable credit is applied to child dependents and phases out exactly like the CTC amount.",
+ "section_1": "Child/Dependent Credits",
+ "section_2": "Additional Child Tax Credit",
"irs_ref": "",
- "notes": "Become current-law policy with passage of TCJA",
+ "notes": "",
"row_var": "FLPDYR",
"row_label": ["2013",
"2014",
@@ -5233,34 +5209,34 @@
"col_label": "",
"boolean_value": false,
"integer_value": false,
- "value": [0.0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- 600.0,
- 600.0,
- 600.0,
- 600.0,
- 500.0,
- 500.0,
- 500.0,
- 400.0,
- 0.0],
- "range": {"min": 0, "max": 9e99},
+ "value": [1000.0,
+ 1000.0,
+ 1000.0,
+ 1000.0,
+ 1000.0,
+ 1400.0,
+ 1400.0,
+ 1400.0,
+ 1400.0,
+ 1500.0,
+ 1500.0,
+ 1500.0,
+ 1600.0,
+ 1000.0],
+ "range": {"min": 0, "max": "_CTC_c"},
"out_of_range_minmsg": "",
- "out_of_range_maxmsg": "",
+ "out_of_range_maxmsg": "for _CTC_c",
"out_of_range_action": "stop",
"compatible_data": {"puf": true, "cps": true}
},
- "_DependentCredit_Nonchild_c": {
- "long_name": "Nonrefundable credit for non-child dependents on top of the child tax credit",
- "description": "This nonrefundable credit is applied to non-child dependents and phases out exactly like the CTC amount.",
- "section_1": "Nonrefundable Credits",
- "section_2": "Child Tax Credit",
+ "_ODC_c": {
+ "long_name": "Maximum nonrefundable other-dependent credit",
+ "description": "This nonrefundable credit is applied to non-child dependents and phases out along with the CTC amount.",
+ "section_1": "Child/Dependent Credits",
+ "section_2": "Other Dependent Tax Credit",
"irs_ref": "Form 1040, line 12, instruction (child tax credit worksheet, line 2)",
- "notes": "Become current-law policy with passage of TCJA",
+ "notes": "Became current-law policy with passage of TCJA",
"row_var": "FLPDYR",
"row_label": ["2013",
"2014",
@@ -5304,44 +5280,10 @@
"compatible_data": {"puf": true, "cps": true}
},
- "_DependentCredit_before_CTC": {
- "long_name": "Stack the Dependent Credit before the Child Tax Credit",
- "description": "Place the drawdown of the nonrefundable Dependent Credit against tax liability before the drawdown of the Child Tax Credit.",
- "section_1": "Nonrefundable Credits",
- "section_2": "Child Tax Credit",
- "irs_ref": "",
- "notes": "Become part of current-law policy with passage of TCJA",
- "row_var": "FLPDYR",
- "row_label": ["2013",
- "2014",
- "2015",
- "2016",
- "2017",
- "2018"],
- "start_year": 2013,
- "cpi_inflatable": false,
- "cpi_inflated": false,
- "col_var": "",
- "col_label": "",
- "boolean_value": true,
- "integer_value": false,
- "value": [false,
- false,
- false,
- false,
- false,
- true],
- "range": {"min": false, "max": true},
- "out_of_range_minmsg": "",
- "out_of_range_maxmsg": "",
- "out_of_range_action": "stop",
- "compatible_data": {"puf": true, "cps": true}
- },
-
"_FilerCredit_c": {
"long_name": "Nonrefundable credit for each filing unit",
"description": "This nonrefundable credit is applied to the filing unit and begins phasing out after the CTC phaseout ends.",
- "section_1": "Nonrefundable Credits",
+ "section_1": "Child/Dependent Credits",
"section_2": "Child Tax Credit",
"irs_ref": "",
"notes": "First introduced in House TCJA bills",
@@ -5843,7 +5785,7 @@
"_ACTC_rt": {
"long_name": "Additional Child Tax Credit rate",
"description": "This is the fraction of earnings used in calculating the ACTC, which is a partially refundable credit that supplements the CTC for some taxpayers.",
- "section_1": "Refundable Credits",
+ "section_1": "Child/Dependent Credits",
"section_2": "Additional Child Tax Credit",
"irs_ref": "Form 8812, line 8, inline.",
"notes": "",
@@ -5867,7 +5809,7 @@
"_ACTC_rt_bonus_under5family": {
"long_name": "Bonus additional child tax credit rate for families with qualifying children under 5",
"description": "For families with qualifying children under 5 years old, this bonus rate is added to the fraction of earnings (additional child tax credit rate) used in calculating the ACTC.",
- "section_1": "Refundable Credits",
+ "section_1": "Child/Dependent Credits",
"section_2": "Additional Child Tax Credit",
"irs_ref": "",
"notes": "",
@@ -5891,7 +5833,7 @@
"_ACTC_Income_thd": {
"long_name": "Additional Child Tax Credit income threshold",
"description": "The portion of earned income below this threshold does not count as base for the Additional Child Tax Credit.",
- "section_1": "Refundable Credits",
+ "section_1": "Child/Dependent Credits",
"section_2": "Additional Child Tax Credit",
"irs_ref": "Form 8812, line 7, in-line.",
"notes": "",
@@ -5941,7 +5883,7 @@
"_ACTC_ChildNum": {
"long_name": "Additional Child Tax Credit minimum number of qualified children for different formula",
"description": "Families with this number of qualified children or more may qualify for a different formula to calculate the Additional Child Tax Credit, which is a partially refundable credit that supplements the Child Tax Credit for some taxpayers.",
- "section_1": "Refundable Credits",
+ "section_1": "Child/Dependent Credits",
"section_2": "Additional Child Tax Credit",
"irs_ref": "Form 8812, Part II. ",
"notes": "",
diff --git a/taxcalc/records_variables.json b/taxcalc/records_variables.json
index 0a7e84571..147242198 100644
--- a/taxcalc/records_variables.json
+++ b/taxcalc/records_variables.json
@@ -976,9 +976,9 @@
"desc": "search taxcalc/calcfunctions.py for how calculated and used",
"form": {"2013-20??": "calculated variable"}
},
- "dep_credit": {
+ "odc": {
"type": "float",
- "desc": "Dependent Credit added on top of Child Tax Credit",
+ "desc": "Other Dependent Credit",
"form": {"2013-20??": "calculated variable"}
},
"personal_refundable_credit": {
diff --git a/taxcalc/reforms/2017_law.json b/taxcalc/reforms/2017_law.json
index 41f8c143e..7962d44d2 100644
--- a/taxcalc/reforms/2017_law.json
+++ b/taxcalc/reforms/2017_law.json
@@ -59,12 +59,11 @@
"_PT_excl_wagelim_prt": {"2018": [[0, 0, 0, 0, 0]]},
"_STD": {"2017": [[6350, 12700, 6350, 9350, 12700]]},
"_II_em": {"2017": [4050]},
+ "_ODC_c": {"2018": [0]},
"_CTC_c": {"2018": [1000]},
"_CTC_ps": {"2018": [[75000, 110000, 55000, 75000, 75000]]},
+ "_ACTC_c": {"2018": [1000]},
"_ACTC_Income_thd": {"2018": [3000]},
- "_DependentCredit_Child_c": {"2018": [0]},
- "_DependentCredit_Nonchild_c": {"2018": [0]},
- "_DependentCredit_before_CTC": {"2018": [false]},
"_AMT_em": {"2017": [[54300, 84500, 42250, 54300, 84500]]},
"_AMT_em_ps": {"2017": [[120700, 160900, 80450, 120700, 160900]]},
"_AMT_em_pe": {"2017": [249450]},
diff --git a/taxcalc/reforms/TCJA.json b/taxcalc/reforms/TCJA.json
index 3cde84291..25078b8dd 100644
--- a/taxcalc/reforms/TCJA.json
+++ b/taxcalc/reforms/TCJA.json
@@ -18,7 +18,7 @@
// - 2: _PT_*
// - 3: _STD (can safely ignore WARNINGs about 2026+ values)
// - 4: _II_em
-// - 5: _DependentCredit_*, _CTC_c, _CTC_ps, _ACTC_Income_thd
+// - 5: _ODC_c, _CTC_c, _CTC_ps, _ACTC_c, _ACTC_Income_thd
// - 6: _AMT_em*
// - 7: _ALD_*
// - 8: _ID_* (can safely ignore WARNINGs about values for several parameters)
@@ -122,24 +122,20 @@
"_II_em":
{"2018": [0],
"2026": [4883]},
+ "_ODC_c":
+ {"2018": [500],
+ "2026": [0]},
+ "_CTC_c":
+ {"2018": [2000],
+ "2026": [1000]},
"_CTC_ps":
{"2018": [[200000, 400000, 200000, 200000, 400000]],
"2026": [[75000, 110000, 55000, 75000, 75000]]},
- "_CTC_c":
+ "_ACTC_c":
{"2018": [1400],
"2022": [1500],
"2025": [1600],
"2026": [1000]},
- "_DependentCredit_Child_c":
- {"2018": [600],
- "2022": [500],
- "2025": [400],
- "2026": [0]},
- "_DependentCredit_Nonchild_c":
- {"2018": [500],
- "2026": [0]},
- "_DependentCredit_before_CTC":
- {"2018": [true]},
"_ACTC_Income_thd":
{"2018": [2500],
"2026": [3000]},
diff --git a/taxcalc/tests/conftest.py b/taxcalc/tests/conftest.py
index a3e30751b..89939694b 100644
--- a/taxcalc/tests/conftest.py
+++ b/taxcalc/tests/conftest.py
@@ -53,7 +53,7 @@ def fixture_test_reforms(tests_path):
Execute logic only once rather than on each pytest-xdist node.
"""
# pylint: disable=too-many-locals
- num_reforms = 64 # must be same as NUM_REFORMS in test_reforms.py
+ num_reforms = 62 # must be same as NUM_REFORMS in test_reforms.py
handling_logic = ('PYTEST_XDIST_WORKER' not in os.environ or
os.environ['PYTEST_XDIST_WORKER'] == 'gw0')
initfile = os.path.join(tests_path, 'reforms_actual_init')
diff --git a/taxcalc/tests/reforms.json b/taxcalc/tests/reforms.json
index 2b472489c..17ee9d847 100644
--- a/taxcalc/tests/reforms.json
+++ b/taxcalc/tests/reforms.json
@@ -282,11 +282,11 @@
"31": {
"baseline": "policy_current_law.json",
- "start_year": 2015,
- "value": {},
- "name": "No reform",
+ "start_year": 2016,
+ "value": {"_ODC_c": [600]},
+ "name": "Increase Other-Dependent Credit to $600",
"output_type": "iitax",
- "compare_with": {"[ADD NEXT REFORM AS 31] Logic:": [0, 0, 0, 0]}
+ "compare_with": {}
},
"32": {
@@ -552,25 +552,6 @@
},
"56": {
- "baseline": "2017_law.json",
- "start_year": 2017,
- "value": {"_DependentCredit_Child_c": [500]},
- "name": "Set Dependent Credit for Children at $500",
- "output_type": "iitax",
- "compare_with": {}
- },
-
- "57": {
- "baseline": "2017_law.json",
- "start_year": 2017,
- "value": {"_DependentCredit_before_CTC": [true],
- "_DependentCredit_Child_c": [500]},
- "name": "Set Dependent Credit for Children at $500 AND stack dependent credit before CTC",
- "output_type": "iitax",
- "compare_with": {}
- },
-
- "58": {
"baseline": "policy_current_law.json",
"start_year": 2017,
"value": {"_cpi_offset": [0.0025]},
@@ -579,7 +560,7 @@
"compare_with": {}
},
- "59": {
+ "57": {
"baseline": "2017_law.json",
"start_year": 2017,
"value": {"_PT_rt7": [0.35],
@@ -589,7 +570,7 @@
"compare_with": {}
},
- "60": {
+ "58": {
"baseline": "2017_law.json",
"start_year": 2017,
"value": {"_PT_wages_active_income": [true],
@@ -600,7 +581,7 @@
"compare_with": {}
},
- "61": {
+ "59": {
"baseline": "2017_law.json",
"start_year": 2017,
"value": {"_CTC_new_c": [1000],
@@ -612,7 +593,7 @@
"compare_with": {}
},
- "62": {
+ "60": {
"baseline": "2017_law.json",
"start_year": 2017,
"value": {"_CTC_new_c": [1000],
@@ -625,7 +606,7 @@
"compare_with": {}
},
- "63": {
+ "61": {
"baseline": "2017_law.json",
"start_year": 2017,
"value": {"_ID_Charity_hc": [1],
@@ -636,7 +617,7 @@
"compare_with": {}
},
- "64": {
+ "62": {
"baseline": "2017_law.json",
"start_year": 2019,
"value": {"_EITC_basic_frac": [0.5]},
diff --git a/taxcalc/tests/reforms_expect.csv b/taxcalc/tests/reforms_expect.csv
index 3765cc6d4..16b2ea922 100644
--- a/taxcalc/tests/reforms_expect.csv
+++ b/taxcalc/tests/reforms_expect.csv
@@ -29,7 +29,7 @@ rid,res1,res2,res3,res4
28,4.0,4.1,4.4,0.0
29,14.8,15.7,16.2,15.7
30,14.7,13.3,16.3,18.1
-31,0.0,0.0,0.0,0.0
+31,-6.2,-6.2,-1.5,-1.6
32,58.7,60.1,62.7,63.7
33,13.2,13.4,14.3,13.5
34,8.4,8.5,9.0,9.0
@@ -54,12 +54,10 @@ rid,res1,res2,res3,res4
53,-107.5,-109.0,-112.3,-115.9
54,28.7,34.5,36.5,35.8
55,85.4,85.0,90.5,96.2
-56,-16.8,-16.8,-16.7,-16.6
-57,-16.8,-16.8,-16.7,-16.6
-58,0.0,0.0,-2.2,-4.6
-59,-14.5,-15.1,-15.7,-15.2
-60,-16.0,-16.6,-17.2,-16.7
-61,-64.6,-65.0,-65.4,-65.6
-62,-65.7,-66.1,-66.4,-66.5
-63,-5.1,-4.7,-5.0,-5.3
-64,-6.6,-6.7,-6.9,-7.1
+56,0.0,0.0,-2.2,-4.6
+57,-14.5,-15.1,-15.7,-15.2
+58,-16.0,-16.6,-17.2,-16.7
+59,-64.6,-65.0,-65.4,-65.6
+60,-65.7,-66.1,-66.4,-66.5
+61,-5.1,-4.7,-5.0,-5.3
+62,-6.6,-6.7,-6.9,-7.1
diff --git a/taxcalc/tests/test_policy.py b/taxcalc/tests/test_policy.py
index e89ca24a0..2122dff1c 100644
--- a/taxcalc/tests/test_policy.py
+++ b/taxcalc/tests/test_policy.py
@@ -140,8 +140,7 @@ def test_multi_year_reform():
atol=0.01, rtol=0.0)
assert np.allclose(getattr(pol, '_CTC_c'),
Policy._expand_array(
- np.array([1000] * 5 + [1400] * 4 +
- [1500] * 3 + [1600] + [1000],
+ np.array([1000] * 5 + [2000] * 8 + [1000],
dtype=np.float64),
False, False,
inflate=False,
@@ -664,9 +663,13 @@ def generate_section_dictionary(html_text):
'Nonrefundable Credits': {
'Misc. Credit Limits': 0,
'Child And Dependent Care': 0,
- 'Child Tax Credit': 0,
'Personal Nonrefundable Credit': 0
},
+ 'Child/Dependent Credits': {
+ 'Child Tax Credit': 0,
+ 'Additional Child Tax Credit': 0,
+ 'Other Dependent Tax Credit': 0
+ },
'Itemized Deductions': {
'Medical Expenses': 0,
'State And Local Income And Sales Taxes': 0,
@@ -695,7 +698,6 @@ def generate_section_dictionary(html_text):
},
'Refundable Credits': {
'Earned Income Tax Credit': 0,
- 'Additional Child Tax Credit': 0,
'New Refundable Child Tax Credit': 0,
'Personal Refundable Credit': 0
},
diff --git a/taxcalc/tests/test_reforms.py b/taxcalc/tests/test_reforms.py
index fb9b10418..3c230da9c 100644
--- a/taxcalc/tests/test_reforms.py
+++ b/taxcalc/tests/test_reforms.py
@@ -310,7 +310,7 @@ def fixture_reforms_dict(tests_path):
return json.loads(rjson)
-NUM_REFORMS = 64 # when changing this also change num_reforms in conftest.py
+NUM_REFORMS = 62 # when changing this also change num_reforms in conftest.py
@pytest.mark.requires_pufcsv
From 5971411f8954bb52ab01222348639478bd796896 Mon Sep 17 00:00:00 2001
From: Martin Holmer
Date: Wed, 6 Feb 2019 09:37:53 -0500
Subject: [PATCH 3/6] Simplify taxcalc/reforms/TCJA.md documentation
---
docs/cookbook/recipe01.py | 55 ++++----
taxcalc/calcfunctions.py | 4 +-
taxcalc/policy.py | 1 +
taxcalc/policy_current_law.json | 24 ----
taxcalc/reforms/TCJA.md | 224 ++------------------------------
taxcalc/tests/test_reforms.py | 2 +-
6 files changed, 37 insertions(+), 273 deletions(-)
diff --git a/docs/cookbook/recipe01.py b/docs/cookbook/recipe01.py
index 68a3c4295..8bb46ab17 100644
--- a/docs/cookbook/recipe01.py
+++ b/docs/cookbook/recipe01.py
@@ -1,11 +1,8 @@
import pandas as pd
from taxcalc import *
-# read two "old" reform files from Tax-Calculator website
-# ("old" means the reform files are defined relative to pre-TCJA policy)
-# For more about the compound-reform technique used in this recipe,
-# read answer to Question 1 of FAQ at the following URL:
-# https://github.com/PSLmodels/Tax-Calculator/issues/1830
+# read an "old" reform file from Tax-Calculator website
+# ("old" means the reform file is defined relative to pre-TCJA policy)
REFORMS_URL = ('https://raw.githubusercontent.com/'
'PSLmodels/Tax-Calculator/master/taxcalc/reforms/')
@@ -13,31 +10,30 @@
baseline_url = REFORMS_URL + baseline_name
baseline = Calculator.read_json_param_objects(baseline_url, None)
-reform1_name = 'TCJA_Senate.json' # TCJA as orginally proposed in Senate
-reform1_url = REFORMS_URL + reform1_name
-reform2_name = 'TCJA_Reconciliation.json' # TCJA as passed by Congress
-reform2_url = REFORMS_URL + reform2_name
+reform_name = 'TCJA.json' # TCJA as passed by Congress
+reform_url = REFORMS_URL + reform_name
-# specify Policy object for static analysis of reform1 relative to pre-TCJA
-reform1 = Calculator.read_json_param_objects(reform1_url, None)
-policy1 = Policy()
-policy1.implement_reform(baseline['policy'], print_warnings=False)
-policy1.implement_reform(reform1['policy'], print_warnings=False)
+# specify Policy object for pre-TCJA baseline
+bpolicy = Policy()
+bpolicy.implement_reform(baseline['policy'], print_warnings=False)
+assert not bpolicy.parameter_errors
-# specify Policy object for static analysis of reform2 relative to pre-TCJA
-reform2 = Calculator.read_json_param_objects(reform2_url, None)
-policy2 = Policy()
-policy1.implement_reform(baseline['policy'], print_warnings=False)
-policy2.implement_reform(reform2['policy'], print_warnings=False)
+# specify Policy object for static analysis of reform relative to pre-TCJA
+reform = Calculator.read_json_param_objects(reform_url, None)
+rpolicy = Policy()
+rpolicy.implement_reform(baseline['policy'], print_warnings=False)
+assert not rpolicy.parameter_errors
+rpolicy.implement_reform(reform['policy'], print_warnings=False)
+assert not rpolicy.parameter_errors
cyr = 2018
-# specify Calculator objects using policy1 and policy2 and calculate for cyr
+# specify Calculator objects using bpolicy and rpolicy and calculate for cyr
recs = Records.cps_constructor()
-calc1 = Calculator(policy=policy1, records=recs)
+calc1 = Calculator(policy=bpolicy, records=recs)
calc1.advance_to_year(cyr)
calc1.calc_all()
-calc2 = Calculator(policy=policy2, records=recs)
+calc2 = Calculator(policy=rpolicy, records=recs)
calc2.advance_to_year(cyr)
calc2.calc_all()
@@ -45,8 +41,8 @@
iitax_rev1 = calc1.weighted_total('iitax')
iitax_rev2 = calc2.weighted_total('iitax')
-# construct reform2-vs-reform1 difference table with results for income deciles
-diff_table = calc1.difference_table(calc2, 'weighted_deciles', 'iitax')
+# construct reform-vs-baseline difference table with results for income deciles
+diff_table = calc2.difference_table(calc1, 'weighted_deciles', 'iitax')
assert isinstance(diff_table, pd.DataFrame)
diff_extract = pd.DataFrame()
dif_colnames = ['count', 'tax_cut', 'tax_inc',
@@ -58,12 +54,9 @@
# print total revenue estimates for cyr
# (estimates in billons of dollars rounded to nearest tenth of a billion)
-print('{}_REFORM1_iitax_rev($B)= {:.3f}'.format(cyr, iitax_rev1 * 1e-9))
-print('{}_REFORM2_iitax_rev($B)= {:.3f}'.format(cyr, iitax_rev2 * 1e-9))
+print('{}_BASELINE_iitax_rev($B)= {:.3f}'.format(cyr, iitax_rev1 * 1e-9))
+print('{}_REFORM___iitax_rev($B)= {:.3f}'.format(cyr, iitax_rev2 * 1e-9))
print('')
-title = 'Extract of {} income-tax difference table by expanded-income decile'
-print(title.format(cyr))
-print('(taxfall is count of funits with cut in income tax in reform 2 vs 1)')
-print('(taxrise is count of funits with rise in income tax in reform 2 vs 1)')
-print(diff_extract.to_string())
+# print reform-vs-baseline difference table
+print(diff_extract)
diff --git a/taxcalc/calcfunctions.py b/taxcalc/calcfunctions.py
index b68dbd126..598f616e3 100644
--- a/taxcalc/calcfunctions.py
+++ b/taxcalc/calcfunctions.py
@@ -1222,7 +1222,7 @@ def ChildDepTaxCredit(n24, MARS, c00100, XTOT, num, c05800,
e07240, CR_RetirementSavings_hc,
c07200,
CTC_c, CTC_ps, CTC_prt, exact, ODC_c,
- CTC_c_under5_bonus, nu05, FilerCredit_c,
+ CTC_c_under5_bonus, nu05,
c07220, odc, codtc_limited):
"""
Computes amounts on "Child Tax Credit and Credit for Other Dependents
@@ -1231,7 +1231,7 @@ def ChildDepTaxCredit(n24, MARS, c00100, XTOT, num, c05800,
"""
# Worksheet Part 1
line1 = CTC_c * n24 + CTC_c_under5_bonus * nu05
- line2 = ODC_c * max(0, XTOT - n24 - num) + FilerCredit_c[MARS - 1]
+ line2 = ODC_c * max(0, XTOT - n24 - num)
line3 = line1 + line2
modAGI = c00100 # no foreign earned income exclusion to add to AGI (line6)
if line3 > 0. and modAGI > CTC_ps[MARS - 1]:
diff --git a/taxcalc/policy.py b/taxcalc/policy.py
index a6d102a73..670521fa4 100644
--- a/taxcalc/policy.py
+++ b/taxcalc/policy.py
@@ -456,6 +456,7 @@ def _validate_parameter_names_types(self, reform):
'_DependentCredit_Child_c',
'_DependentCredit_Nonchild_c',
'_DependentCredit_before_CTC',
+ '_FilerCredit_c',
'_ALD_InvInc_ec_base_RyanBrady'
])
param_names = set(self._vals.keys())
diff --git a/taxcalc/policy_current_law.json b/taxcalc/policy_current_law.json
index 748721b56..3f767fb33 100644
--- a/taxcalc/policy_current_law.json
+++ b/taxcalc/policy_current_law.json
@@ -5312,30 +5312,6 @@
"compatible_data": {"puf": true, "cps": true}
},
- "_FilerCredit_c": {
- "long_name": "Nonrefundable credit for each filing unit",
- "description": "This nonrefundable credit is applied to the filing unit and begins phasing out after the CTC phaseout ends.",
- "section_1": "Child/Dependent Credits",
- "section_2": "Child Tax Credit",
- "irs_ref": "",
- "notes": "First introduced in House TCJA bills",
- "row_var": "FLPDYR",
- "row_label": ["2013"],
- "start_year": 2013,
- "cpi_inflatable": true,
- "cpi_inflated": false,
- "col_var": "MARS",
- "col_label": ["single", "joint", "separate", "headhousehold", "widow"],
- "boolean_value": false,
- "integer_value": false,
- "value": [[0.0, 0.0, 0.0, 0.0, 0.0]],
- "range": {"min": 0, "max": 9e99},
- "out_of_range_minmsg": "",
- "out_of_range_maxmsg": "",
- "out_of_range_action": "stop",
- "compatible_data": {"puf": true, "cps": true}
- },
-
"_NIIT_thd": {
"long_name": "Net Investment Income Tax modified AGI threshold",
"description": "If modified AGI is more than this threshold, filing unit is subject to the Net Investment Income Tax.",
diff --git a/taxcalc/reforms/TCJA.md b/taxcalc/reforms/TCJA.md
index 72801a578..c2170d724 100644
--- a/taxcalc/reforms/TCJA.md
+++ b/taxcalc/reforms/TCJA.md
@@ -12,33 +12,20 @@ You need to use the new
as a "reform", and then, if you want to compare that pre-TCJA policy
to an old reform, implement the old reform as usual. This
compound-reform technique works well and is being used extensively in
-the Tax-Calculator unit tests. Here is a code fragment illustrating
-the use of this compound-reform technique, where we want to analyze
-the effects of the [Brown-Khanna EITC
-reform](https://github.com/open-source-economics/Tax-Calculator/blob/master/taxcalc/reforms/BrownKhanna.json)
-relative to pre-TCJA policy:
-```
-pol = Policy() # pol is TCJA
-param = Calculator.read_json_param_objects('...../2017_law.json', None)
-pol.implement_reform(param['policy']) # now pol is pre-TCJA law
-if pol.reform_errors:
- print(pol.reform_errors)
- exit(1)
-calc_base = Calculator(policy=pol, records=Records(), verbose=False)
-
-param = Calculator.read_json_param_objects('...../BrownKhanna.json', None)
-pol.implement_reform(param['policy']) # now pol is EITC reform relative to pre-TCJA law
-if pol.reform_errors:
- print(pol.reform_errors)
- exit(1)
-calc_reform = Calculator(policy=pol, records=Records(), verbose=False)
-```
+the Tax-Calculator test suite. This technique is illustrated in
+recipe 01 of the [Cookbook of Tested Recipes for Python Programming
+with
+Tax-Calculator](https://pslmodels.github.io/Tax-Calculator/cookbook.html)
+using the `2017_law.json` and `TCJA.json` reform files. For a check
+of the consistency of the `2017_law.json` and `TCJA.json` reform
+files, see `test_round_trip_tcja_reform` in the
+`taxcalc/tests/test_reforms.py` file.
**2. Does Tax-Calculator produce the same results for pre-TCJA policy
as before?**
Yes, release 0.14.3 and 0.15.0 produce the same aggregate results for
-pre-TCJA policy even though the contents of `current_law_policy.json`
+pre-TCJA policy even though the contents of `policy_current_law.json`
have changed.
For an analysis that shows the pre-TCJA tax revenues for 2019 are the
@@ -54,201 +41,8 @@ income tax revenues between the Tax-Calculator releases 0.15.0 and
Tax-Calculator 0.14.3. See pull requests #1818 and #1819 for details
on the newly added TCJA provisions.
-For an analysis of the 2019 difference in aggregate revenues, see
-below at the heading **TCJA and pre-TCJA Comparisons**.
-
-For a compound reform that shows the consistency of the new
-`2017_law.json` file and the revised `TCJA_Reconciliation.json` file,
-see below at the heading **A Round-Trip Compound Reform**.
-
**4. Does TCJA current-law policy incorporate any behavior responses?**
Beginning with release 0.25.0, Tax-Calculator incorporates a new CBO
budget outlook that presumably includes the effects of any behavioral
changes and growth effects that one might expect to be caused by TCJA.
-
-
-TCJA and pre-TCJA Comparisons
------------------------------
-
-This addendum shows that the 2019 aggregate revenues are identical for
-pre-TCJA policy and very close for TCJA policy.
-
-Here are the contents of `aggresults.py`:
-```
-from __future__ import print_function
-import sys
-import urllib
-import taxcalc
-from taxcalc import Policy, Records, Calculator
-
-if len(sys.argv) == 1:
- reform = 'clp'
-else:
- base_url = ('https://raw.githubusercontent.com/'
- 'open-source-economics/Tax-Calculator/{}/taxcalc/reforms/')
- if '0.14.3' in taxcalc.__version__:
- reform = 'TCJA_Reconciliation.json'
- reform_text = urllib.urlopen(base_url.format('0.14.3') + reform).read()
- else:
- reform = '2017_law.json'
- reform_text = urllib.urlopen(base_url.format('master') + reform).read()
-
-cyr = 2019
-
-print('taxcalc version', taxcalc.__version__)
-print('policy regime', reform)
-print('year', cyr)
-
-pol = Policy()
-if reform != 'clp':
- params = Calculator.read_json_param_objects(reform_text, None)
- pol.implement_reform(params['policy'])
- if pol.reform_errors:
- print(pol.reform_errors)
- exit(1)
-calc = Calculator(policy=pol, records=Records(), verbose=False)
-calc.advance_to_year(cyr)
-calc.calc_all()
-itax = calc.weighted_total('iitax') * 1e-9
-ptax = calc.weighted_total('payrolltax') * 1e-9
-ctax = itax + ptax
-res = 'itax,ptax,combined($B) {:7.3f} {:7.3f} {:7.3f}'
-print(res.format(itax, ptax, ctax))
-```
-Here are the content of the `testing.sh` bash script that executes
-`aggresults.py` in four different ways:
-```
-#!/bin/bash
-date
-# stop if not on master branch
-pushd ../tax-calculator 2>&1 > /dev/null
-git branch | awk '$1~/\*/{if($2~/master/){exit 0}else{exit 1}}'
-if [ $? -ne 0 ]; then
- echo "STOPPING: not on master branch of local git repo"
- exit 1
-fi
-popd 2>&1 > /dev/null
-# generate results using taxcalc 0.14.3
-echo Starting 0.14.3 work ...
-conda install -c ospc taxcalc=0.14.3 --yes 2>&1 > /dev/null
-python aggresults.py > 0143-2017.aggres
-python aggresults.py ref > 0143-tcja.aggres
-# generate results using taxcalc 0.15.0
-echo Starting 0.15.0 work ...
-pushd ../tax-calculator/conda.recipe 2>&1 > /dev/null
-./install_local_taxcalc_package.sh 2>&1 > /dev/null
-popd 2>&1 > /dev/null
-python aggresults.py > 0150-tcja.aggres
-python aggresults.py ref > 0150-2017.aggres
-date
-# show results
-set -x
-cat 0150-2017.aggres
-diff 0143-2017.aggres 0150-2017.aggres
-diff 0143-tcja.aggres 0150-tcja.aggres
-```
-And here are the results generated by executing `testing.sh`:
-```
-+ cat 0150-2017.aggres
-taxcalc version unknown
-policy regime 2017_law.json
-year 2019
-itax,ptax,combined($B) 1858.468 1187.071 3045.539
-+ diff 0143-2017.aggres 0150-2017.aggres
-1,2c1,2
-< taxcalc version 0.14.3
-< policy regime clp
----
-> taxcalc version unknown
-> policy regime 2017_law.json
-+ diff 0143-tcja.aggres 0150-tcja.aggres
-1,2c1,2
-< taxcalc version 0.14.3
-< policy regime TCJA_Reconciliation.json
----
-> taxcalc version unknown
-> policy regime clp
-4c4
-< itax,ptax,combined($B) 1662.372 1187.071 2849.442
----
-> itax,ptax,combined($B) 1671.110 1187.071 2858.181
-```
-So, the new, more complete characterization of TCJA used in
-Tax-Calculator 0.15.0 generates 2019 income tax revenue that is about
-0.5% higher than the old, less complete characterization of TCJA used
-in Tax-Calculator 0.14.3.
-
-**A Round-Trip Compound Reform**
-
-This addendum shows that the diagnostic table generated by the default
-policy object, `Policy()`, is the same as the diagnostic table
-generated by applying first the `2017_law.json` reform and then the
-`TCJA_Reconciliation.json` reform to the default policy object. So,
-implementing these two reforms sequentially on the default policy
-object produces a compound-reformed policy object that is identical to
-the original default policy object. In other words, the
-`TCJA_Reconciliation.json` reform "undoes" the `2017_law.json` reform.
-
-Here are the contents of `compoundreform.py`:
-```
-from __future__ import print_function
-import sys
-import urllib
-import numpy as np
-import taxcalc
-from taxcalc import Policy, Records, Calculator
-
-assert taxcalc.__version__ == 'unknown' # that is, 0.15.0
-
-base_url = ('https://raw.githubusercontent.com/'
- 'open-source-economics/Tax-Calculator/master/taxcalc/reforms/')
-reform1 = urllib.urlopen(base_url + '2017_law.json').read()
-reform2 = urllib.urlopen(base_url + 'TCJA_Reconciliation.json').read()
-
-fyear = 2016
-nyears = 12
-
-pol = Policy() # pol represents TCJA
-
-calc1 = Calculator(policy=pol, records=Records(), verbose=False)
-calc1.advance_to_year(fyear)
-diag1 = calc1.diagnostic_table(num_years=nyears)
-
-param1 = Calculator.read_json_param_objects(reform1, None)
-pol.implement_reform(param1['policy']) # now pol represents 2017 pre-TCJA law
-if pol.reform_errors:
- print(pol.reform_errors)
- exit(1)
-
-param2 = Calculator.read_json_param_objects(reform2, None)
-pol.implement_reform(param2['policy']) # now pol represents TCJA law
-if pol.reform_errors:
- print(pol.reform_errors)
- exit(1)
-
-calc2 = Calculator(policy=pol, records=Records(), verbose=False)
-calc2.advance_to_year(fyear)
-diag2 = calc1.diagnostic_table(num_years=nyears)
-
-for cyr in diag1:
- print('comparing diagnostic tables for', cyr)
- assert np.allclose(diag1[cyr], diag2[cyr])
-```
-Here are the results of executing `python compoundreform.py`:
-```
-comparing diagnostic tables for 2016
-comparing diagnostic tables for 2017
-comparing diagnostic tables for 2018
-comparing diagnostic tables for 2019
-comparing diagnostic tables for 2020
-comparing diagnostic tables for 2021
-comparing diagnostic tables for 2022
-comparing diagnostic tables for 2023
-comparing diagnostic tables for 2024
-comparing diagnostic tables for 2025
-comparing diagnostic tables for 2026
-comparing diagnostic tables for 2027
-```
-None of the `assert` statements that compare year columns in the two
-diagnostic tables failed.
diff --git a/taxcalc/tests/test_reforms.py b/taxcalc/tests/test_reforms.py
index c5b7f0115..06467e290 100644
--- a/taxcalc/tests/test_reforms.py
+++ b/taxcalc/tests/test_reforms.py
@@ -134,7 +134,7 @@ def test_round_trip_tcja_reform(tests_path):
if fail_params:
raise ValueError(msg)
-
+@pytest.mark.one
@pytest.mark.pre_release
def test_reform_json_and_output(tests_path):
"""
From 128bec1bc69204412021c1696711fe1fc343e1cb Mon Sep 17 00:00:00 2001
From: Martin Holmer
Date: Wed, 6 Feb 2019 10:06:23 -0500
Subject: [PATCH 4/6] Archive reforms that can no longer be simulated
---
taxcalc/reforms/2017_law.json | 8 ++++----
taxcalc/reforms/REFORMS.md | 12 ++----------
taxcalc/reforms/RyanBrady.out | 15 ---------------
.../reforms/{TCJA_Reconciliation.out => TCJA.out} | 0
taxcalc/reforms/TCJA_House.out | 15 ---------------
taxcalc/reforms/TCJA_House_Amended.out | 15 ---------------
taxcalc/reforms/TCJA_Senate.out | 15 ---------------
taxcalc/reforms/TCJA_Senate_111417.out | 15 ---------------
taxcalc/reforms/TCJA_Senate_120117.out | 15 ---------------
taxcalc/reforms/{ => archive}/RyanBrady.json | 0
taxcalc/reforms/{ => archive}/TCJA_House.json | 0
.../reforms/{ => archive}/TCJA_House_Amended.json | 0
.../{ => archive}/TCJA_Reconciliation.json | 0
taxcalc/reforms/{ => archive}/TCJA_Senate.json | 0
.../reforms/{ => archive}/TCJA_Senate_111417.json | 0
.../reforms/{ => archive}/TCJA_Senate_120117.json | 0
taxcalc/tests/test_reforms.py | 3 +--
17 files changed, 7 insertions(+), 106 deletions(-)
delete mode 100644 taxcalc/reforms/RyanBrady.out
rename taxcalc/reforms/{TCJA_Reconciliation.out => TCJA.out} (100%)
delete mode 100644 taxcalc/reforms/TCJA_House.out
delete mode 100644 taxcalc/reforms/TCJA_House_Amended.out
delete mode 100644 taxcalc/reforms/TCJA_Senate.out
delete mode 100644 taxcalc/reforms/TCJA_Senate_111417.out
delete mode 100644 taxcalc/reforms/TCJA_Senate_120117.out
rename taxcalc/reforms/{ => archive}/RyanBrady.json (100%)
rename taxcalc/reforms/{ => archive}/TCJA_House.json (100%)
rename taxcalc/reforms/{ => archive}/TCJA_House_Amended.json (100%)
rename taxcalc/reforms/{ => archive}/TCJA_Reconciliation.json (100%)
rename taxcalc/reforms/{ => archive}/TCJA_Senate.json (100%)
rename taxcalc/reforms/{ => archive}/TCJA_Senate_111417.json (100%)
rename taxcalc/reforms/{ => archive}/TCJA_Senate_120117.json (100%)
diff --git a/taxcalc/reforms/2017_law.json b/taxcalc/reforms/2017_law.json
index 47b99e175..16ea71a5e 100644
--- a/taxcalc/reforms/2017_law.json
+++ b/taxcalc/reforms/2017_law.json
@@ -8,7 +8,7 @@
// - Set pre-TCJA handling of pass-through income (2)
// - Set pre-TCJA standard deduction and personal exemption (3)
// - Set pre-TCJA child tax credit (CTC) and additional CTC policy (4)
-// - Set pre-TCJA dependent credit policy parameters (5)
+// - Set pre-TCJA other dependent credit policy parameters (5)
// - Set pre-TCJA AMT exemption parameters (6)
// - Set pre-TCJA above the line deduction policy (7)
// - Set pre-TCJA itemized deduction policy (8)
@@ -17,8 +17,8 @@
// - 1: _II_rt?/_II_brk? and _PT_rt?/_PT_brk?
// - 2: four _PT_excl_* parameters
// - 3: _STD and _II_em parameters
-// - 4: _CTC_c and _CTC_ps and _ACTC_Income_thd
-// - 5: three different _DependentCredit_* parameters
+// - 4: _CTC_* and _ACTC_* parameters
+// - 5: _ODC_c parameter
// - 6: three different _AMT_em* parameters
// - 7: three _ALD_* parameters
// - 8: seven different _ID_* parameters
@@ -60,11 +60,11 @@
"_PT_excl_wagelim_prt": {"2018": [[0, 0, 0, 0, 0]]},
"_STD": {"2017": [[6350, 12700, 6350, 9350, 12700]]},
"_II_em": {"2017": [4050]},
- "_ODC_c": {"2018": [0]},
"_CTC_c": {"2018": [1000]},
"_CTC_ps": {"2018": [[75000, 110000, 55000, 75000, 75000]]},
"_ACTC_c": {"2018": [1000]},
"_ACTC_Income_thd": {"2018": [3000]},
+ "_ODC_c": {"2018": [0]},
"_AMT_em": {"2017": [[54300, 84500, 42250, 54300, 84500]]},
"_AMT_em_ps": {"2017": [[120700, 160900, 80450, 120700, 160900]]},
"_AMT_em_pe": {"2017": [249450]},
diff --git a/taxcalc/reforms/REFORMS.md b/taxcalc/reforms/REFORMS.md
index c3903c0e7..5be0574d0 100644
--- a/taxcalc/reforms/REFORMS.md
+++ b/taxcalc/reforms/REFORMS.md
@@ -32,21 +32,13 @@ in this section.
- [2016 Clinton Campaign Tax Plan](Clinton2016.json)
-- [2016 Ryan-Brady "Better Way" Tax Plan](RyanBrady.json)
-
- [2017 Trump Administration Tax Plan](Trump2017.json)
- [2017 Brown-Khanna GAIN Act](BrownKhanna.json)
-- [2017 Tax Cuts and Jobs Act, House version](TCJA_House.json)
-
-- [2017 Tax Cuts and Jobs Act, Passed House version](TCJA_House_Amended.json)
-
-- [2017 Tax Cuts and Jobs Act, Senate version](TCJA_Senate.json)
-
-- [2017 Tax Cuts and Jobs Act, Passed Senate version](TCJA_Senate_120117.json)
+- [2017 Simplifying America's Tax System (Renacci)](Renacci.json)
-- [2017 Tax Cuts and Jobs Act, Conference bill](TCJA_Reconciliation.json)
+- [2017 Tax Cuts and Jobs Act, as passed by Congress](TCJA.json)
## Structure and Syntax of Reform Files
diff --git a/taxcalc/reforms/RyanBrady.out b/taxcalc/reforms/RyanBrady.out
deleted file mode 100644
index 42c05cbdd..000000000
--- a/taxcalc/reforms/RyanBrady.out
+++ /dev/null
@@ -1,15 +0,0 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 0 32090 27910 3349 82 9180 55328
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 0 57761 122239 15523 11023 27540 155207
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 0 44926 195074 31150 28150 36720 193490
-$200-500K 600000 0 38508 561492 135915 135915 66070 430330
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 0 173284 906716 185937 175170 139510 834355
\ No newline at end of file
diff --git a/taxcalc/reforms/TCJA_Reconciliation.out b/taxcalc/reforms/TCJA.out
similarity index 100%
rename from taxcalc/reforms/TCJA_Reconciliation.out
rename to taxcalc/reforms/TCJA.out
diff --git a/taxcalc/reforms/TCJA_House.out b/taxcalc/reforms/TCJA_House.out
deleted file mode 100644
index 3fafd4c13..000000000
--- a/taxcalc/reforms/TCJA_House.out
+++ /dev/null
@@ -1,15 +0,0 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 0 31227 28773 3453 -675 9180 56085
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 0 56209 123791 14942 8942 27540 157288
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 0 43718 196282 27758 22308 36720 199332
-$200-500K 600000 0 37473 562527 136297 132997 66070 433248
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 0 168627 911373 182449 163571 139510 845954
\ No newline at end of file
diff --git a/taxcalc/reforms/TCJA_House_Amended.out b/taxcalc/reforms/TCJA_House_Amended.out
deleted file mode 100644
index 3fafd4c13..000000000
--- a/taxcalc/reforms/TCJA_House_Amended.out
+++ /dev/null
@@ -1,15 +0,0 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 0 31227 28773 3453 -675 9180 56085
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 0 56209 123791 14942 8942 27540 157288
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 0 43718 196282 27758 22308 36720 199332
-$200-500K 600000 0 37473 562527 136297 132997 66070 433248
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 0 168627 911373 182449 163571 139510 845954
\ No newline at end of file
diff --git a/taxcalc/reforms/TCJA_Senate.out b/taxcalc/reforms/TCJA_Senate.out
deleted file mode 100644
index 973d12d9d..000000000
--- a/taxcalc/reforms/TCJA_Senate.out
+++ /dev/null
@@ -1,15 +0,0 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 0 31227 28773 3029 -549 9180 55959
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 0 56209 123791 14736 9786 27540 156444
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 0 43718 196282 30333 25383 36720 196257
-$200-500K 600000 0 37473 562527 138938 135638 66070 430606
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 0 168627 911373 187036 170258 139510 839267
\ No newline at end of file
diff --git a/taxcalc/reforms/TCJA_Senate_111417.out b/taxcalc/reforms/TCJA_Senate_111417.out
deleted file mode 100644
index 05fc68405..000000000
--- a/taxcalc/reforms/TCJA_Senate_111417.out
+++ /dev/null
@@ -1,15 +0,0 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 0 31227 28773 3029 -899 9180 56309
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 0 56209 123791 14699 8699 27540 157531
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 0 43718 196282 29622 23622 36720 198018
-$200-500K 600000 0 37473 562527 136612 132612 66070 433633
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 0 168627 911373 183962 164034 139510 845491
\ No newline at end of file
diff --git a/taxcalc/reforms/TCJA_Senate_120117.out b/taxcalc/reforms/TCJA_Senate_120117.out
deleted file mode 100644
index 05fc68405..000000000
--- a/taxcalc/reforms/TCJA_Senate_120117.out
+++ /dev/null
@@ -1,15 +0,0 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 0 31227 28773 3029 -899 9180 56309
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 0 56209 123791 14699 8699 27540 157531
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 0 43718 196282 29622 23622 36720 198018
-$200-500K 600000 0 37473 562527 136612 132612 66070 433633
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 0 168627 911373 183962 164034 139510 845491
\ No newline at end of file
diff --git a/taxcalc/reforms/RyanBrady.json b/taxcalc/reforms/archive/RyanBrady.json
similarity index 100%
rename from taxcalc/reforms/RyanBrady.json
rename to taxcalc/reforms/archive/RyanBrady.json
diff --git a/taxcalc/reforms/TCJA_House.json b/taxcalc/reforms/archive/TCJA_House.json
similarity index 100%
rename from taxcalc/reforms/TCJA_House.json
rename to taxcalc/reforms/archive/TCJA_House.json
diff --git a/taxcalc/reforms/TCJA_House_Amended.json b/taxcalc/reforms/archive/TCJA_House_Amended.json
similarity index 100%
rename from taxcalc/reforms/TCJA_House_Amended.json
rename to taxcalc/reforms/archive/TCJA_House_Amended.json
diff --git a/taxcalc/reforms/TCJA_Reconciliation.json b/taxcalc/reforms/archive/TCJA_Reconciliation.json
similarity index 100%
rename from taxcalc/reforms/TCJA_Reconciliation.json
rename to taxcalc/reforms/archive/TCJA_Reconciliation.json
diff --git a/taxcalc/reforms/TCJA_Senate.json b/taxcalc/reforms/archive/TCJA_Senate.json
similarity index 100%
rename from taxcalc/reforms/TCJA_Senate.json
rename to taxcalc/reforms/archive/TCJA_Senate.json
diff --git a/taxcalc/reforms/TCJA_Senate_111417.json b/taxcalc/reforms/archive/TCJA_Senate_111417.json
similarity index 100%
rename from taxcalc/reforms/TCJA_Senate_111417.json
rename to taxcalc/reforms/archive/TCJA_Senate_111417.json
diff --git a/taxcalc/reforms/TCJA_Senate_120117.json b/taxcalc/reforms/archive/TCJA_Senate_120117.json
similarity index 100%
rename from taxcalc/reforms/TCJA_Senate_120117.json
rename to taxcalc/reforms/archive/TCJA_Senate_120117.json
diff --git a/taxcalc/tests/test_reforms.py b/taxcalc/tests/test_reforms.py
index 06467e290..df031a2a8 100644
--- a/taxcalc/tests/test_reforms.py
+++ b/taxcalc/tests/test_reforms.py
@@ -134,8 +134,7 @@ def test_round_trip_tcja_reform(tests_path):
if fail_params:
raise ValueError(msg)
-@pytest.mark.one
-@pytest.mark.pre_release
+
def test_reform_json_and_output(tests_path):
"""
Check that each JSON reform file can be converted into a reform dictionary
From 2be33690cf4e44ebb194d1fc8aecb5df647b9e1c Mon Sep 17 00:00:00 2001
From: Martin Holmer
Date: Wed, 6 Feb 2019 17:54:25 -0500
Subject: [PATCH 5/6] Eliminate use of nonsmall_diffs in test_reforms.py tests
---
taxcalc/reforms/2017_law.out | 25 ++++------
taxcalc/reforms/BrownKhanna.out | 25 ++++------
taxcalc/reforms/Clinton2016.out | 25 ++++------
taxcalc/reforms/Renacci.out | 25 ++++------
taxcalc/reforms/TCJA.out | 25 ++++------
taxcalc/reforms/Trump2016.out | 25 ++++------
taxcalc/reforms/Trump2017.out | 25 ++++------
taxcalc/reforms/cases.csv | 2 +-
taxcalc/reforms/clp.out | 25 ++++------
taxcalc/reforms/ptaxes0.out | 25 ++++------
taxcalc/reforms/ptaxes1.out | 25 ++++------
taxcalc/reforms/ptaxes2.out | 25 ++++------
taxcalc/reforms/ptaxes3.out | 25 ++++------
taxcalc/tests/test_reforms.py | 82 +++++++++++++--------------------
14 files changed, 154 insertions(+), 230 deletions(-)
diff --git a/taxcalc/reforms/2017_law.out b/taxcalc/reforms/2017_law.out
index 93a80b89b..6888af361 100644
--- a/taxcalc/reforms/2017_law.out
+++ b/taxcalc/reforms/2017_law.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 12996 16794 30210 3466 488 9180 54922
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 30325 30378 119297 16513 13513 27540 152717
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 25993 23586 190421 32341 30841 36720 190799
-$200-500K 600000 18878 20377 560745 142805 142805 66070 423440
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 88192 91135 900673 195125 187648 139510 821877
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,6799.60,18863.65,2330.29,4590.00
+12,60000.00,6799.60,48863.65,7652.95,9180.00
+13,460000.00,6799.60,453200.40,132158.00,33101.61
+21,60000.00,13599.21,29053.79,1359.54,9180.00
+22,120000.00,13599.21,89053.79,11637.52,18360.00
+23,240000.00,13599.21,209053.79,44490.93,36720.00
+31,30000.00,10012.02,11314.48,-1853.53,4590.00
+32,60000.00,10012.02,41314.48,4482.41,9180.00
+33,120000.00,10012.02,101314.48,19174.17,18360.00
diff --git a/taxcalc/reforms/BrownKhanna.out b/taxcalc/reforms/BrownKhanna.out
index d58d93d4c..ca9563ff3 100644
--- a/taxcalc/reforms/BrownKhanna.out
+++ b/taxcalc/reforms/BrownKhanna.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 12996 16794 30210 3466 -4407 9180 59817
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 30325 30378 119297 16513 8694 27540 157536
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 25993 23586 190421 32341 30841 36720 190799
-$200-500K 600000 18878 20377 560745 142805 142805 66070 423440
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 88192 91135 900673 195125 177933 139510 831591
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,6799.60,18863.65,773.63,4590.00
+12,60000.00,6799.60,48863.65,7652.95,9180.00
+13,460000.00,6799.60,453200.40,132158.00,33101.61
+21,60000.00,13599.21,29053.79,-2949.68,9180.00
+22,120000.00,13599.21,89053.79,11637.52,18360.00
+23,240000.00,13599.21,209053.79,44490.93,36720.00
+31,30000.00,10012.02,11314.48,-5203.00,4590.00
+32,60000.00,10012.02,41314.48,3941.96,9180.00
+33,120000.00,10012.02,101314.48,19174.17,18360.00
diff --git a/taxcalc/reforms/Clinton2016.out b/taxcalc/reforms/Clinton2016.out
index 5d08b14da..b147786ae 100644
--- a/taxcalc/reforms/Clinton2016.out
+++ b/taxcalc/reforms/Clinton2016.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 12996 16794 30210 3466 -512 9180 55922
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 30325 30378 119297 16513 11513 27540 154717
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 25993 23586 190421 32341 29841 36720 191799
-$200-500K 600000 18878 20377 560745 142805 142805 66070 423440
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 88192 91135 900673 195125 183648 139510 825877
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,6799.60,18863.65,2330.29,4590.00
+12,60000.00,6799.60,48863.65,7652.95,9180.00
+13,460000.00,6799.60,453200.40,132158.00,33101.61
+21,60000.00,13599.21,29053.79,359.54,9180.00
+22,120000.00,13599.21,89053.79,10637.52,18360.00
+23,240000.00,13599.21,209053.79,44490.93,36720.00
+31,30000.00,10012.02,11314.48,-2853.53,4590.00
+32,60000.00,10012.02,41314.48,3482.41,9180.00
+33,120000.00,10012.02,101314.48,19174.17,18360.00
diff --git a/taxcalc/reforms/Renacci.out b/taxcalc/reforms/Renacci.out
index 371153cb4..2f6b1a939 100644
--- a/taxcalc/reforms/Renacci.out
+++ b/taxcalc/reforms/Renacci.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 16045 32090 11865 1187 -3246 9180 58656
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 37438 64179 78383 7838 3674 27540 162556
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 32090 48135 159776 21944 20444 36720 201196
-$200-500K 600000 23306 48135 528559 108072 108072 66070 458172
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 108879 192538 778583 139041 128944 139510 880580
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,16062.06,8583.92,858.39,4590.00
+12,60000.00,16062.06,38583.92,3858.39,9180.00
+13,460000.00,16062.06,443937.94,102953.46,33101.61
+21,60000.00,32124.12,6459.80,-2535.43,9180.00
+22,120000.00,32124.12,66459.80,5145.98,18360.00
+23,240000.00,32124.12,186459.80,30552.89,36720.00
+31,30000.00,16062.06,3229.90,-4118.27,4590.00
+32,60000.00,16062.06,33229.90,2322.99,9180.00
+33,120000.00,16062.06,93229.90,15276.44,18360.00
diff --git a/taxcalc/reforms/TCJA.out b/taxcalc/reforms/TCJA.out
index 33368c5d1..927f429ba 100644
--- a/taxcalc/reforms/TCJA.out
+++ b/taxcalc/reforms/TCJA.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 0 31227 28773 3029 -899 9180 56309
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 0 56209 123791 14699 8699 27540 157531
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 0 43718 196282 29361 23361 36720 198279
-$200-500K 600000 0 37473 562527 136039 132039 66070 434206
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 0 168627 911373 183129 163201 139510 846324
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,12519.07,17480.93,1898.97,4590.00
+12,60000.00,12519.07,47480.93,6209.66,9180.00
+13,460000.00,12519.07,447480.93,131256.26,33101.61
+21,60000.00,25038.14,34961.86,-202.06,9180.00
+22,120000.00,25038.14,94961.86,8419.33,18360.00
+23,240000.00,25038.14,214961.86,35675.82,36720.00
+31,30000.00,18778.60,11221.40,-2805.42,4590.00
+32,60000.00,18778.60,41221.40,2662.80,9180.00
+33,120000.00,18778.60,101221.40,14883.93,18360.00
diff --git a/taxcalc/reforms/Trump2016.out b/taxcalc/reforms/Trump2016.out
index dd115df5d..881baccd2 100644
--- a/taxcalc/reforms/Trump2016.out
+++ b/taxcalc/reforms/Trump2016.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 0 32090 27910 3349 372 9180 55038
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 0 64179 115821 14898 11898 27540 154332
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 0 48135 191865 32323 30823 36720 190817
-$200-500K 600000 0 48135 551865 140212 140212 66070 426033
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 0 192538 887462 190782 183304 139510 826221
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,16062.06,13937.94,1672.55,4590.00
+12,60000.00,16062.06,43937.94,5764.32,9180.00
+13,460000.00,16062.06,443937.94,131642.11,33101.61
+21,60000.00,32124.12,27875.88,1345.11,9180.00
+22,120000.00,32124.12,87875.88,10028.63,18360.00
+23,240000.00,32124.12,207875.88,41528.63,36720.00
+31,30000.00,16062.06,13937.94,-1312.43,4590.00
+32,60000.00,16062.06,43937.94,4764.32,9180.00
+33,120000.00,16062.06,103937.94,20764.32,18360.00
diff --git a/taxcalc/reforms/Trump2017.out b/taxcalc/reforms/Trump2017.out
index f9e63279e..57f2e6d6b 100644
--- a/taxcalc/reforms/Trump2017.out
+++ b/taxcalc/reforms/Trump2017.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 12996 33587 13416 1342 -1636 9180 57046
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 30325 60757 88919 9115 6115 27540 160115
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 25993 47172 166835 22233 20733 36720 200907
-$200-500K 600000 18878 40754 540368 116825 116825 66070 449420
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 88192 182270 809538 149515 142037 139510 867488
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,13599.21,12064.04,1206.40,4590.00
+12,60000.00,13599.21,42064.04,4420.46,9180.00
+13,460000.00,13599.21,446400.79,105524.32,33101.61
+21,60000.00,27198.43,15454.57,-454.54,9180.00
+22,120000.00,27198.43,75454.57,6045.46,18360.00
+23,240000.00,27198.43,195454.57,36672.54,36720.00
+31,30000.00,20024.03,1302.47,-2854.73,4590.00
+32,60000.00,20024.03,31302.47,2130.25,9180.00
+33,120000.00,20024.03,91302.47,14666.09,18360.00
diff --git a/taxcalc/reforms/cases.csv b/taxcalc/reforms/cases.csv
index d6db65e3d..cf64ba4fc 100644
--- a/taxcalc/reforms/cases.csv
+++ b/taxcalc/reforms/cases.csv
@@ -1,7 +1,7 @@
RECID,s006,MARS,XTOT,EIC,n24,nu05,e00200,e00200p,e00200s
11, 1, 1, 1, 0, 0, 0, 30000, 30000, 0
12, 1, 1, 1, 0, 0, 0, 60000, 60000, 0
- 13, 1, 1, 1, 0, 0, 0,360000, 360000, 0
+ 13, 1, 1, 1, 0, 0, 0,460000, 460000, 0
21, 1, 2, 4, 2, 2, 1, 60000, 30000, 30000
22, 1, 2, 4, 2, 2, 1,120000, 60000, 60000
23, 1, 2, 4, 2, 2, 1,240000, 120000, 120000
diff --git a/taxcalc/reforms/clp.out b/taxcalc/reforms/clp.out
index 33368c5d1..927f429ba 100644
--- a/taxcalc/reforms/clp.out
+++ b/taxcalc/reforms/clp.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 0 31227 28773 3029 -899 9180 56309
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 0 56209 123791 14699 8699 27540 157531
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 0 43718 196282 29361 23361 36720 198279
-$200-500K 600000 0 37473 562527 136039 132039 66070 434206
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 0 168627 911373 183129 163201 139510 846324
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,12519.07,17480.93,1898.97,4590.00
+12,60000.00,12519.07,47480.93,6209.66,9180.00
+13,460000.00,12519.07,447480.93,131256.26,33101.61
+21,60000.00,25038.14,34961.86,-202.06,9180.00
+22,120000.00,25038.14,94961.86,8419.33,18360.00
+23,240000.00,25038.14,214961.86,35675.82,36720.00
+31,30000.00,18778.60,11221.40,-2805.42,4590.00
+32,60000.00,18778.60,41221.40,2662.80,9180.00
+33,120000.00,18778.60,101221.40,14883.93,18360.00
diff --git a/taxcalc/reforms/ptaxes0.out b/taxcalc/reforms/ptaxes0.out
index ccf5a4e88..41f15ddc7 100644
--- a/taxcalc/reforms/ptaxes0.out
+++ b/taxcalc/reforms/ptaxes0.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 12996 16794 30210 3466 488 10200 54412
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 30325 30378 119297 16513 13513 30600 151187
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 25993 23586 190421 32341 30841 40800 188759
-$200-500K 600000 18878 20377 560745 142805 142805 72765 420092
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 88192 91135 900673 195125 187648 154365 814450
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,6799.60,18863.65,2330.29,5100.00
+12,60000.00,6799.60,48863.65,7652.95,10200.00
+13,460000.00,6799.60,453200.40,132158.00,35809.56
+21,60000.00,13599.21,29053.79,1359.54,10200.00
+22,120000.00,13599.21,89053.79,11637.52,20400.00
+23,240000.00,13599.21,209053.79,44490.93,40800.00
+31,30000.00,10012.02,11314.48,-1853.53,5100.00
+32,60000.00,10012.02,41314.48,4482.41,10200.00
+33,120000.00,10012.02,101314.48,19174.17,20400.00
diff --git a/taxcalc/reforms/ptaxes1.out b/taxcalc/reforms/ptaxes1.out
index 28f21eddb..70d4f9439 100644
--- a/taxcalc/reforms/ptaxes1.out
+++ b/taxcalc/reforms/ptaxes1.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 12996 16794 30210 3466 488 9180 54922
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 30325 30378 119297 16513 13513 27540 152717
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 25993 23586 190421 32341 30841 36720 190799
-$200-500K 600000 18878 20377 560745 142805 142805 79600 416675
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 88192 91135 900673 195125 187648 153040 815112
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,6799.60,18863.65,2330.29,4590.00
+12,60000.00,6799.60,48863.65,7652.95,9180.00
+13,460000.00,6799.60,453200.40,132158.00,46680.00
+21,60000.00,13599.21,29053.79,1359.54,9180.00
+22,120000.00,13599.21,89053.79,11637.52,18360.00
+23,240000.00,13599.21,209053.79,44490.93,36720.00
+31,30000.00,10012.02,11314.48,-1853.53,4590.00
+32,60000.00,10012.02,41314.48,4482.41,9180.00
+33,120000.00,10012.02,101314.48,19174.17,18360.00
diff --git a/taxcalc/reforms/ptaxes2.out b/taxcalc/reforms/ptaxes2.out
index 3e6d36da0..152acf3ac 100644
--- a/taxcalc/reforms/ptaxes2.out
+++ b/taxcalc/reforms/ptaxes2.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 12996 16794 30210 3466 488 9180 54922
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 30325 30378 119297 16513 13513 27540 152717
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 25993 23586 190421 32341 30841 36720 190799
-$200-500K 600000 18878 20377 560745 142805 142805 93240 409855
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 88192 91135 900673 195125 187648 166680 808292
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,6799.60,18863.65,2330.29,4590.00
+12,60000.00,6799.60,48863.65,7652.95,9180.00
+13,460000.00,6799.60,453200.40,132158.00,72720.00
+21,60000.00,13599.21,29053.79,1359.54,9180.00
+22,120000.00,13599.21,89053.79,11637.52,18360.00
+23,240000.00,13599.21,209053.79,44490.93,36720.00
+31,30000.00,10012.02,11314.48,-1853.53,4590.00
+32,60000.00,10012.02,41314.48,4482.41,9180.00
+33,120000.00,10012.02,101314.48,19174.17,18360.00
diff --git a/taxcalc/reforms/ptaxes3.out b/taxcalc/reforms/ptaxes3.out
index f1086ee42..63ea87eb0 100644
--- a/taxcalc/reforms/ptaxes3.out
+++ b/taxcalc/reforms/ptaxes3.out
@@ -1,15 +1,10 @@
- AGI pexempt stdded taxinc tax-wo-credits inctax paytax ataxinc
-<$0K 0 0 0 0 0 0 0 0
-=$0K 0 0 0 0 0 0 0 0
-$0-10K 0 0 0 0 0 0 0 0
-$10-20K 0 0 0 0 0 0 0 0
-$20-30K 0 0 0 0 0 0 0 0
-$30-40K 60000 12996 16794 30210 3466 488 9180 54922
-$40-50K 0 0 0 0 0 0 0 0
-$50-75K 180000 30325 30378 119297 16513 13513 27540 152717
-$75-100K 0 0 0 0 0 0 0 0
-$100-200K 240000 25993 23586 190421 32341 30841 36720 190799
-$200-500K 600000 18878 20377 560745 142805 142805 65673 423837
-$500-1000K 0 0 0 0 0 0 0 0
->$1000K 0 0 0 0 0 0 0 0
-ALL 1080000 88192 91135 900673 195125 187648 139113 822275
\ No newline at end of file
+RECID,c00100,standard,c04800,iitax,payrolltax
+11,30000.00,6799.60,18863.65,2330.29,4590.00
+12,60000.00,6799.60,48863.65,7652.95,9180.00
+13,460000.00,6799.60,453200.40,132158.00,32805.61
+21,60000.00,13599.21,29053.79,1359.54,9180.00
+22,120000.00,13599.21,89053.79,11637.52,18360.00
+23,240000.00,13599.21,209053.79,44490.93,36720.00
+31,30000.00,10012.02,11314.48,-1853.53,4590.00
+32,60000.00,10012.02,41314.48,4482.41,9180.00
+33,120000.00,10012.02,101314.48,19174.17,18360.00
diff --git a/taxcalc/tests/test_reforms.py b/taxcalc/tests/test_reforms.py
index df031a2a8..4f60d419a 100644
--- a/taxcalc/tests/test_reforms.py
+++ b/taxcalc/tests/test_reforms.py
@@ -10,9 +10,9 @@
import json
import pytest
import numpy as np
+import pandas as pd
# pylint: disable=import-error
-from taxcalc import Calculator, Policy, Records, DIST_TABLE_COLUMNS
-from taxcalc import nonsmall_diffs
+from taxcalc import Calculator, Policy, Records
def test_2017_law_reform(tests_path):
@@ -142,40 +142,23 @@ def test_reform_json_and_output(tests_path):
generates no parameter_errors.
Then use each reform to generate static tax results for small set of
filing units in a single tax_year and compare those results with
- expected results from a text file.
+ expected results from a CSV-formatted file.
"""
# pylint: disable=too-many-statements,too-many-locals
- used_dist_stats = ['c00100', # AGI
- 'c04600', # personal exemptions
- 'standard', # standard deduction
- 'c04800', # regular taxable income
- 'c05800', # income tax before credits
- 'iitax', # income tax after credits
- 'payrolltax', # payroll taxes
- 'aftertax_income'] # aftertax expanded income
- unused_dist_stats = set(DIST_TABLE_COLUMNS) - set(used_dist_stats)
- renamed_columns = {'c00100': 'AGI',
- 'c04600': 'pexempt',
- 'standard': 'stdded',
- 'c04800': 'taxinc',
- 'c05800': 'tax-wo-credits',
- 'iitax': 'inctax',
- 'payrolltax': 'paytax',
- 'aftertax_income': 'ataxinc'}
# embedded function used only in test_reform_json_and_output
- def write_distribution_table(calc, resfilename):
+ def write_res_file(calc, resfilename):
"""
- Write abbreviated distribution table calc to file with resfilename.
+ Write calc output to CSV-formatted file with resfilename.
"""
- dist, _ = calc.distribution_tables(None, 'standard_income_bins',
- scaling=False)
- for stat in unused_dist_stats:
- del dist[stat]
- dist = dist[used_dist_stats]
- dist.rename(mapper=renamed_columns, axis='columns', inplace=True)
+ varlist = [
+ 'RECID', 'c00100', 'standard', 'c04800', 'iitax', 'payrolltax'
+ ]
+ # varnames AGI STD TaxInc ITAX PTAX
+ stats = calc.dataframe(varlist)
+ stats['RECID'] = stats['RECID'].astype(int)
with open(resfilename, 'w') as resfile:
- dist.to_string(resfile, float_format='%7.0f')
+ stats.to_csv(resfile, index=False, float_format='%.2f')
# embedded function used only in test_reform_json_and_output
def res_and_out_are_same(base):
@@ -183,17 +166,15 @@ def res_and_out_are_same(base):
Return True if base.res and base.out file contents are the same;
return False if base.res and base.out file contents differ.
"""
- with open(base + '.res') as resfile:
- act_res = resfile.read()
- with open(base + '.out') as outfile:
- exp_res = outfile.read()
- # check to see if act_res & exp_res have differences
- diffs = nonsmall_diffs(act_res.splitlines(True),
- exp_res.splitlines(True), small=1)
- dump = True
- if dump and diffs:
- print('{} ACTUAL:\n{}', base, act_res)
- print('{} EXPECT:\n{}', base, exp_res)
+ resdf = pd.read_csv(base + '.res')
+ outdf = pd.read_csv(base + '.out')
+ diffs = False
+ for col in resdf:
+ if col in outdf:
+ if not np.allclose(resdf[col], outdf[col]):
+ diffs = True
+ else:
+ diffs = True
return not diffs
# specify Records object containing cases data
@@ -207,15 +188,16 @@ def res_and_out_are_same(base):
# specify list of reform failures
failures = list()
# specify current-law-policy Calculator object
- calc1 = Calculator(policy=Policy(), records=cases, verbose=False)
- calc1.advance_to_year(tax_year)
- calc1.calc_all()
+ calc = Calculator(policy=Policy(), records=cases, verbose=False)
+ calc.advance_to_year(tax_year)
+ calc.calc_all()
res_path = cases_path.replace('cases.csv', 'clp.res')
- write_distribution_table(calc1, res_path)
+ write_res_file(calc, res_path)
if res_and_out_are_same(res_path.replace('.res', '')):
os.remove(res_path)
else:
failures.append(res_path)
+ del calc
# read 2017_law.json reform file and specify its parameters dictionary
pre_tcja_jrf = os.path.join(tests_path, '..', 'reforms', '2017_law.json')
pre_tcja = Calculator.read_json_param_objects(pre_tcja_jrf, None)
@@ -226,23 +208,25 @@ def res_and_out_are_same(base):
# determine reform's baseline by reading contents of jrf
with open(jrf, 'r') as rfile:
jrf_text = rfile.read()
- pre_tcja_baseline = 'Reform_Baseline: 2017_law.json' in jrf_text
+ pre_tcja_baseline = 'Reform_Baseline: 2017_law.json' in jrf_text
# implement the reform relative to its baseline
reform = Calculator.read_json_param_objects(jrf_text, None)
pol = Policy() # current-law policy
if pre_tcja_baseline:
pol.implement_reform(pre_tcja['policy'])
+ assert not pol.parameter_errors
pol.implement_reform(reform['policy'])
assert not pol.parameter_errors
- calc2 = Calculator(policy=pol, records=cases, verbose=False)
- calc2.advance_to_year(tax_year)
- calc2.calc_all()
+ calc = Calculator(policy=pol, records=cases, verbose=False)
+ calc.advance_to_year(tax_year)
+ calc.calc_all()
res_path = jrf.replace('.json', '.res')
- write_distribution_table(calc2, res_path)
+ write_res_file(calc, res_path)
if res_and_out_are_same(res_path.replace('.res', '')):
os.remove(res_path)
else:
failures.append(res_path)
+ del calc
if failures:
msg = 'Following reforms have res-vs-out differences:\n'
for ref in failures:
From 50a890c61a6d6368c3cf280159786caffd107fb2 Mon Sep 17 00:00:00 2001
From: Martin Holmer
Date: Wed, 6 Feb 2019 18:53:34 -0500
Subject: [PATCH 6/6] Add tests of removed_param_names errors to maintain
complete code coverage
---
taxcalc/tests/test_policy.py | 89 +++++++++++++++++++++++-------------
1 file changed, 56 insertions(+), 33 deletions(-)
diff --git a/taxcalc/tests/test_policy.py b/taxcalc/tests/test_policy.py
index 2122dff1c..082799aeb 100644
--- a/taxcalc/tests/test_policy.py
+++ b/taxcalc/tests/test_policy.py
@@ -864,49 +864,59 @@ def test_validate_param_names_types_errors():
"""
Check detection of invalid policy parameter names and types in reforms.
"""
- pol0 = Policy()
- ref0 = {2020: {'_STD_cpi': 2}}
+ pol = Policy()
+ ref = {2020: {'_STD_cpi': 2}}
with pytest.raises(ValueError):
- pol0.implement_reform(ref0)
- pol1 = Policy()
- ref1 = {2020: {'_badname_cpi': True}}
+ pol.implement_reform(ref)
+ del pol
+ pol = Policy()
+ ref = {2020: {'_badname_cpi': True}}
with pytest.raises(ValueError):
- pol1.implement_reform(ref1)
- pol2 = Policy()
- ref2 = {2020: {'_II_em_cpi': 5}}
+ pol.implement_reform(ref)
+ del pol
+ pol = Policy()
+ ref = {2020: {'_II_em_cpi': 5}}
with pytest.raises(ValueError):
- pol2.implement_reform(ref2)
- pol3 = Policy()
- ref3 = {2020: {'_badname': [0.4]}}
+ pol.implement_reform(ref)
+ del pol
+ pol = Policy()
+ ref = {2020: {'_badname': [0.4]}}
with pytest.raises(ValueError):
- pol3.implement_reform(ref3)
- pol4 = Policy()
- ref4 = {2020: {'_EITC_MinEligAge': [21.4]}}
+ pol.implement_reform(ref)
+ del pol
+ pol = Policy()
+ ref = {2020: {'_EITC_MinEligAge': [21.4]}}
with pytest.raises(ValueError):
- pol4.implement_reform(ref4)
- pol5 = Policy()
- ref5 = {2025: {'_ID_BenefitSurtax_Switch': [[False, True, 0, 1, 0, 1, 0]]}}
+ pol.implement_reform(ref)
+ del pol
+ pol = Policy()
+ ref = {2025: {'_ID_BenefitSurtax_Switch': [[False, True, 0, 1, 0, 1, 0]]}}
with pytest.raises(ValueError):
- pol5.implement_reform(ref5)
- pol6 = Policy()
- ref6 = {2021: {'_II_em': ['not-a-number']}}
+ pol.implement_reform(ref)
+ del pol
+ pol = Policy()
+ ref = {2021: {'_II_em': ['not-a-number']}}
with pytest.raises(ValueError):
- pol6.implement_reform(ref6)
- pol7 = Policy()
- ref7 = {2019: {'_FICA_ss_trt_cpi': True}}
+ pol.implement_reform(ref)
+ del pol
+ pol = Policy()
+ ref = {2019: {'_FICA_ss_trt_cpi': True}}
with pytest.raises(ValueError):
- pol7.implement_reform(ref7)
- # test 8 was contributed by Hank Doupe in bug report #1956
- pol8 = Policy()
- ref8 = {2019: {'_AMEDT_rt': [True]}}
+ pol.implement_reform(ref)
+ del pol
+ # this test was contributed by Hank Doupe in bug report #1956
+ pol = Policy()
+ ref = {2019: {'_AMEDT_rt': [True]}}
with pytest.raises(ValueError):
- pol8.implement_reform(ref8)
- # test 9 extends test 8 to integer parameters
- pol9 = Policy()
- ref9 = {2019: {'_AMT_KT_c_Age': [True]}}
+ pol.implement_reform(ref)
+ del pol
+ # this test extends the prior test to integer parameters
+ pol = Policy()
+ ref = {2019: {'_AMT_KT_c_Age': [True]}}
with pytest.raises(ValueError):
- pol9.implement_reform(ref9)
- # test 10 was contributed by Hank Doupe in bug report #1980
+ pol.implement_reform(ref)
+ del pol
+ # this test was contributed by Hank Doupe in bug report #1980
json_reform = """
{"policy": {"_ID_BenefitSurtax_Switch_medical": {"2018": [true]}}}
"""
@@ -914,6 +924,19 @@ def test_validate_param_names_types_errors():
pol = Policy()
pol.implement_reform(pdict["policy"], raise_errors=False)
assert pol.parameter_errors == ''
+ del pol
+ # this test checks "is a removed parameter" error for base parameter
+ pol = Policy()
+ ref = {2019: {'_DependentCredit_Child_c': [400]}}
+ with pytest.raises(ValueError):
+ pol.implement_reform(ref)
+ del pol
+ # this test checks "is a removed parameter" error for _cpi parameter
+ pol = Policy()
+ ref = {2019: {'_DependentCredit_Child_c_cpi': False}}
+ with pytest.raises(ValueError):
+ pol.implement_reform(ref)
+ del pol
def test_validate_param_values_warnings_errors():