From 5ef5c2f3f4728c788c829982cd9c3b4f29fb6e03 Mon Sep 17 00:00:00 2001 From: Peter-Metz Date: Wed, 11 Mar 2020 14:47:35 -0400 Subject: [PATCH 1/3] changes to keep up with bokeh 2.0 --- cs-config/cs_config/outputs.py | 58 +++++++++++++++++++--------------- environment.yml | 2 +- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/cs-config/cs_config/outputs.py b/cs-config/cs_config/outputs.py index e17c2b2..e242153 100644 --- a/cs-config/cs_config/outputs.py +++ b/cs-config/cs_config/outputs.py @@ -24,14 +24,14 @@ def liability_plot(df_base, df_reform, span, mtr_opt): fig.add_layout(axis) iitax_base = fig.line(x="Axis", y="Individual Income Tax", line_color='#2b83ba', muted_color='#2b83ba', - line_width=2, legend="Individual Income Tax Liability", muted_alpha=0.1, source=df_base) + line_width=2, legend_label="Individual Income Tax Liability", muted_alpha=0.1, source=df_base) payroll_base = fig.line(x="Axis", y="Payroll Tax", line_color='#abdda4', muted_color='#abdda4', - line_width=2, legend='Payroll Tax Liability', muted_alpha=0.1, source=df_base) + line_width=2, legend_label='Payroll Tax Liability', muted_alpha=0.1, source=df_base) iitax_reform = fig.line(x="Axis", y="Individual Income Tax", line_color='#2b83ba', muted_color='#2b83ba', - line_width=2, line_dash='dashed', legend="Individual Income Tax Liability", muted_alpha=0.1, source=df_reform) + line_width=2, line_dash='dashed', legend_label="Individual Income Tax Liability", muted_alpha=0.1, source=df_reform) payroll_reform = fig.line(x="Axis", y="Payroll Tax", line_color='#abdda4', muted_color='#abdda4', - line_width=2, line_dash='dashed', legend='Payroll Tax Liability', muted_alpha=0.1, source=df_reform) + line_width=2, line_dash='dashed', legend_label='Payroll Tax Liability', muted_alpha=0.1, source=df_reform) iitax_base.muted = False payroll_base.muted = False @@ -44,15 +44,17 @@ def liability_plot(df_base, df_reform, span, mtr_opt): """ base_callback = CustomJS(code=plot_js, args={}) base_toggle = Toggle(label="Base (Solid)", button_type="default", - callback=base_callback, active=True) + active=True) base_callback.args = {"toggle": base_toggle, "object1": iitax_base, "object2": payroll_base} + base_toggle.js_on_change('active', base_callback) reform_callback = CustomJS(code=plot_js, args={}) reform_toggle = Toggle(label="Reform (Dashed)", button_type="default", - callback=reform_callback, active=True) + active=True) reform_callback.args = {"toggle": reform_toggle, "object1": iitax_reform, "object2": payroll_reform} + reform_toggle.js_on_change('active', reform_callback) fig.xaxis.formatter = NumeralTickFormatter(format="$0,000") fig.xaxis.axis_label = mtr_opt @@ -92,22 +94,22 @@ def rate_plot(df_base, df_reform, span, mtr_opt): fig.add_layout(axis) iitax_atr_base = fig.line(x="Axis", y="IATR", line_color='#2b83ba', muted_color='#2b83ba', - line_width=2, legend="Income Tax Average Rate", muted_alpha=0.1, source=df_base) + line_width=2, legend_label="Income Tax Average Rate", muted_alpha=0.1, source=df_base) payroll_atr_base = fig.line(x="Axis", y="PATR", line_color='#abdda4', muted_color='#abdda4', - line_width=2, legend='Payroll Tax Average Rate', muted_alpha=0.1, source=df_base) + line_width=2, legend_label='Payroll Tax Average Rate', muted_alpha=0.1, source=df_base) iitax_mtr_base = fig.line(x="Axis", y="Income Tax MTR", line_color='#fdae61', muted_color='#fdae61', - line_width=2, legend="Income Tax Marginal Rate", muted_alpha=0.1, source=df_base) + line_width=2, legend_label="Income Tax Marginal Rate", muted_alpha=0.1, source=df_base) payroll_mtr_base = fig.line(x="Axis", y="Payroll Tax MTR", line_color='#d7191c', muted_color='#d7191c', - line_width=2, legend='Payroll Tax Marginal Rate', muted_alpha=0.1, source=df_base) + line_width=2, legend_label='Payroll Tax Marginal Rate', muted_alpha=0.1, source=df_base) iitax_atr_reform = fig.line(x="Axis", y="IATR", line_color='#2b83ba', muted_color='#2b83ba', line_width=2, - line_dash='dashed', legend="Income Tax Average Rate", muted_alpha=0.1, source=df_reform) + line_dash='dashed', legend_label="Income Tax Average Rate", muted_alpha=0.1, source=df_reform) payroll_atr_reform = fig.line(x="Axis", y="PATR", line_color='#abdda4', muted_color='#abdda4', line_width=2, - line_dash='dashed', legend='Payroll Tax Average Rate', muted_alpha=0.1, source=df_reform) + line_dash='dashed', legend_label='Payroll Tax Average Rate', muted_alpha=0.1, source=df_reform) iitax_mtr_reform = fig.line(x="Axis", y="Income Tax MTR", line_color='#fdae61', muted_color='#fdae61', - line_width=2, line_dash='dashed', legend="Income Tax Marginal Rate", muted_alpha=0.1, source=df_reform) + line_width=2, line_dash='dashed', legend_label="Income Tax Marginal Rate", muted_alpha=0.1, source=df_reform) payroll_mtr_reform = fig.line(x="Axis", y="Payroll Tax MTR", line_color='#d7191c', muted_color='#d7191c', - line_width=2, line_dash='dashed', legend='Payroll Tax Marginal Rate', muted_alpha=0.1, source=df_reform) + line_width=2, line_dash='dashed', legend_label='Payroll Tax Marginal Rate', muted_alpha=0.1, source=df_reform) iitax_atr_base.muted = False iitax_mtr_base.muted = True @@ -126,17 +128,19 @@ def rate_plot(df_base, df_reform, span, mtr_opt): """ base_callback = CustomJS(code=plot_js, args={}) base_toggle = Toggle(label="Base (Solid)", button_type="default", - callback=base_callback, active=True) + active=True) base_callback.args = {"toggle": base_toggle, "object1": iitax_atr_base, "object2": payroll_atr_base, "object3": iitax_mtr_base, "object4": payroll_mtr_base} + base_toggle.js_on_change('active', base_callback) reform_callback = CustomJS(code=plot_js, args={}) reform_toggle = Toggle(label="Reform (Dashed)", button_type="default", - callback=reform_callback, active=True) + active=True) reform_callback.args = {"toggle": reform_toggle, "object1": iitax_atr_reform, "object2": payroll_atr_reform, "object3": iitax_mtr_reform, "object4": payroll_mtr_reform} + reform_toggle.js_on_change('active', reform_callback) fig.xaxis.formatter = NumeralTickFormatter(format="$0,000") fig.xaxis.axis_label = mtr_opt @@ -174,22 +178,22 @@ def credit_plot(df_base, df_reform, span, mtr_opt): fig.add_layout(axis) eitc_base = fig.line(x="Axis", y="EITC", line_color='#2b83ba', muted_color='#2b83ba', - line_width=2, legend="Earned Income Tax Credit", muted_alpha=0.1, source=df_base) + line_width=2, legend_label="Earned Income Tax Credit", muted_alpha=0.1, source=df_base) ctc_base = fig.line(x="Axis", y="CTC", line_color='#abdda4', muted_color='#abdda4', - line_width=2, legend='Nonrefundable Child Tax Credit', muted_alpha=0.1, source=df_base) + line_width=2, legend_label='Nonrefundable Child Tax Credit', muted_alpha=0.1, source=df_base) ctc_refund_base = fig.line(x="Axis", y="CTC Refundable", line_color='#fdae61', muted_color='#fdae61', - line_width=2, legend='Refundable Child Tax Credit', muted_alpha=0.1, source=df_base) + line_width=2, legend_label='Refundable Child Tax Credit', muted_alpha=0.1, source=df_base) cdcc_base = fig.line(x="Axis", y="Child care credit", line_color='#d7191c', muted_color='#d7191c', - line_width=2, legend='Child and Dependent Care Credit', muted_alpha=0.1, source=df_base) + line_width=2, legend_label='Child and Dependent Care Credit', muted_alpha=0.1, source=df_base) eitc_reform = fig.line(x="Axis", y="EITC", line_color='#2b83ba', muted_color='#2b83ba', line_width=2, - line_dash='dashed', legend="Earned Income Tax Credit", muted_alpha=0.1, source=df_reform) + line_dash='dashed', legend_label="Earned Income Tax Credit", muted_alpha=0.1, source=df_reform) ctc_reform = fig.line(x="Axis", y="CTC", line_color='#abdda4', muted_color='#abdda4', line_width=2, - line_dash='dashed', legend='Nonrefundable Child Tax Credit', muted_alpha=0.1, source=df_reform) + line_dash='dashed', legend_label='Nonrefundable Child Tax Credit', muted_alpha=0.1, source=df_reform) ctc_refund_reform = fig.line(x="Axis", y="CTC Refundable", line_color='#fdae61', muted_color='#fdae61', - line_width=2, line_dash='dashed', legend='Refundable Child Tax Credit', muted_alpha=0.1, source=df_reform) + line_width=2, line_dash='dashed', legend_label='Refundable Child Tax Credit', muted_alpha=0.1, source=df_reform) cdcc_reform = fig.line(x="Axis", y="Child care credit", line_color='#d7191c', muted_color='#d7191c', line_width=2, - line_dash='dashed', legend='Child and Dependent Care Credit', muted_alpha=0.1, source=df_reform) + line_dash='dashed', legend_label='Child and Dependent Care Credit', muted_alpha=0.1, source=df_reform) ctc_base.muted = True ctc_refund_base.muted = True @@ -206,17 +210,19 @@ def credit_plot(df_base, df_reform, span, mtr_opt): """ base_callback = CustomJS(code=plot_js, args={}) base_toggle = Toggle(label="Base (Solid)", button_type="default", - callback=base_callback, active=True) + active=True) base_callback.args = {"toggle": base_toggle, "object1": eitc_base, "object2": cdcc_base, "object3": ctc_base, "object4": ctc_refund_base} + base_toggle.js_on_change('active', base_callback) reform_callback = CustomJS(code=plot_js, args={}) reform_toggle = Toggle(label="Reform (Dashed)", button_type="default", - callback=reform_callback, active=True) + active=True) reform_callback.args = {"toggle": reform_toggle, "object1": eitc_reform, "object2": cdcc_reform, "object3": ctc_reform, "object4": ctc_refund_reform} + reform_toggle.js_on_change('active', reform_callback) fig.yaxis.formatter = NumeralTickFormatter(format="$0,000") fig.yaxis.axis_label = "Tax Credits" diff --git a/environment.yml b/environment.yml index f9bc737..d55e82d 100644 --- a/environment.yml +++ b/environment.yml @@ -12,7 +12,7 @@ dependencies: - ipython - pytest - dask -- bokeh<2.0.0 +- bokeh - markdown - pip - pip: From 4f152fed2387f1f5a636f3adbb0cbea58f71c97f Mon Sep 17 00:00:00 2001 From: Peter-Metz Date: Wed, 11 Mar 2020 15:00:47 -0400 Subject: [PATCH 2/3] update tests for taxcalc 2.8 --- cs-config/cs_config/tests/test_functions.py | 4 ++-- environment.yml | 2 +- taxcrunch/tests/expected_calc_table.csv | 4 ++-- taxcrunch/tests/expected_multi_table.csv | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cs-config/cs_config/tests/test_functions.py b/cs-config/cs_config/tests/test_functions.py index 49ba0e0..dde4a4f 100644 --- a/cs-config/cs_config/tests/test_functions.py +++ b/cs-config/cs_config/tests/test_functions.py @@ -29,10 +29,10 @@ def test_convert_adj(): assert res == { "STD": { - 2019: [0, 1, 12268.8, 18403.2, 24537.6] + 2019: [0, 1, 12200.0, 18350.0, 24400.0] }, "EITC_c": { - 2019: [1000.0, 3538.53, 5844.04, 6575.05] + 2019: [1000.0, 3526.0, 5828.0, 6557.0] }, "BEN_ssi_repeal": { 2019: True diff --git a/environment.yml b/environment.yml index d55e82d..13c9b12 100644 --- a/environment.yml +++ b/environment.yml @@ -4,7 +4,7 @@ channels: - conda-forge dependencies: - python>=3.6.5 -- taxcalc<2.8.0 +- taxcalc - behresp>=0.9.0 - pandas>=0.23 - numpy>=1.13 diff --git a/taxcrunch/tests/expected_calc_table.csv b/taxcrunch/tests/expected_calc_table.csv index e2bcfd9..1ee8d97 100644 --- a/taxcrunch/tests/expected_calc_table.csv +++ b/taxcrunch/tests/expected_calc_table.csv @@ -3,7 +3,7 @@ Adjusted Gross Income (AGI),100000.0,100000.0,100001.0 Unemployment Insurance in AGI,0.0,0.0,0.0 Social Security in AGI,0.0,0.0,0.0 Itemized Deductions,0.0,0.0,0.0 -Taxable Income,87731.2,89115.07,89116.07 +Taxable Income,87800.0,89115.07,89116.07 Child Tax Credit (CTC),0.0,0.0,0.0 CTC Refundable,0.0,0.0,0.0 Child Care Credit,0.0,0.0,0.0 @@ -11,4 +11,4 @@ Earned Income Tax Credit (EITC),0.0,0.0,0.0 Alternative Minimum Tax (AMT) Taxable Income,100000.0,100000.0,100001.0 AMT Liability,0.0,0.0,0.0 Net Investment Income Tax,0.0,0.0,0.0 -Income Tax Before Credits,15217.07,17818.82,17819.07 +Income Tax Before Credits,15246.5,17818.82,17819.07 diff --git a/taxcrunch/tests/expected_multi_table.csv b/taxcrunch/tests/expected_multi_table.csv index 5b0ed54..aa8dc29 100644 --- a/taxcrunch/tests/expected_multi_table.csv +++ b/taxcrunch/tests/expected_multi_table.csv @@ -1,8 +1,8 @@ ,ID,Individual Income Tax,Payroll Tax,Wages,AGI,UI in AGI,OASDI in AGI,Itemized Deductions,Taxable Inc,CTC,CTC Refundable,Child care credit,EITC,AMT Taxable Income,AMT Liability,Net Investment Income Tax,Income Tax Before Credits,FICA,Payroll Tax MTR,Income Tax MTR,Combined MTR -0,1.0,23397.147199999996,21137.961919999998,160000.0,164500.0,0.0,0.0,0.0,146096.8,4000.0,0.0,0.0,0.0,164500.0,0.0,0.0,27397.147199999996,21137.961919999998,0.02899999999499414,0.240000000121654,0.26900000011664815 -1,2.0,-5385.396063999999,7267.5,47500.0,47800.0,0.0,0.0,0.0,23262.4,2365.9536000000003,3634.0463999999997,0.0,1751.3496639999994,47800.0,0.0,0.0,2365.9536000000003,7267.5,0.15300000004572212,0.3305999999611231,0.4836000000068452 -2,3.0,10049.4088,10710.0,70000.0,80000.0,0.0,0.0,0.0,67731.2,0.0,0.0,0.0,0.0,80000.0,0.0,0.0,10049.4088,10710.0,0.15299999995477265,0.21999999989930075,0.37300000003597233 -3,4.0,6538.8175999999985,18819.0,123000.0,124200.0,0.0,0.0,0.0,99662.4,6000.0,0.0,0.0,0.0,124200.0,0.0,0.0,13538.817599999998,18819.0,0.1530000001366716,0.22000000026309863,0.3730000003997702 -4,5.0,40659.7456,23747.961919999998,250000.0,251200.0,0.0,0.0,0.0,226662.4,2000.0,0.0,0.0,0.0,251200.0,0.0,45.6,42614.1456,23747.961919999998,0.0380000001314329,0.23999999975785613,0.2780000002530869 +0,1.0,23425.0,21119.6,160000.0,164500.0,0.0,0.0,0.0,146150.0,4000.0,0.0,0.0,0.0,164500.0,0.0,0.0,27425.0,21119.6,0.02899999999499414,0.240000000121654,0.26900000011664815 +1,2.0,-5333.411999999999,7267.5,47500.0,47800.0,0.0,0.0,0.0,23400.0,2384.0,3616.0,0.0,1717.4119999999994,47800.0,0.0,0.0,2384.0,7267.5,0.15300000004572212,0.3305999999611231,0.4836000000068452 +2,3.0,10074.5,10710.0,70000.0,80000.0,0.0,0.0,0.0,67800.0,0.0,0.0,0.0,0.0,80000.0,0.0,0.0,10074.5,10710.0,0.15299999995477265,0.21999999989930075,0.37299999967217445 +3,4.0,6589.0,18819.0,123000.0,124200.0,0.0,0.0,0.0,99800.0,6000.0,0.0,0.0,0.0,124200.0,0.0,0.0,13589.0,18819.0,0.1530000001366716,0.21999999989930075,0.37300000003597233 +4,5.0,40718.6,23729.6,250000.0,251200.0,0.0,0.0,0.0,226800.0,2000.0,0.0,0.0,0.0,251200.0,0.0,45.6,42673.0,23729.6,0.0380000001314329,0.23999999975785613,0.27799999952549115 5,6.0,0.0,1683.0,11000.0,11000.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,11000.0,0.0,0.0,0.0,1683.0,0.15300000000024738,0.0,0.15300000000024738 -6,7.0,-3402.289388,5967.0,39000.0,39250.0,0.0,0.0,0.0,20846.8,2193.5231999999996,1806.4768000000004,0.0,1595.8125879999998,39250.0,0.0,0.0,2193.5231999999996,5967.0,0.15300000004572212,0.33060000014302204,0.48360000018874416 +6,7.0,-3368.6679999999997,5967.0,39000.0,39250.0,0.0,0.0,0.0,20900.0,2201.0,1799.0,0.0,1569.6679999999997,39250.0,0.0,0.0,2201.0,5967.0,0.15300000004572212,0.33060000000659784,0.48360000005231996 From 79af2153030e5a74603a7bf81336cf493f0dfcaa Mon Sep 17 00:00:00 2001 From: Peter-Metz Date: Wed, 11 Mar 2020 15:02:51 -0400 Subject: [PATCH 3/3] pep8 --- cs-config/cs_config/outputs.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/cs-config/cs_config/outputs.py b/cs-config/cs_config/outputs.py index e242153..ffe4075 100644 --- a/cs-config/cs_config/outputs.py +++ b/cs-config/cs_config/outputs.py @@ -14,13 +14,15 @@ def liability_plot(df_base, df_reform, span, mtr_opt): fig.yaxis.axis_label = "Tax Liabilities" fig.yaxis.formatter = NumeralTickFormatter(format="$0,000") - filer_income = Span(location=span, dimension='height', line_color='black', line_dash='dotted', line_width=1.5) + filer_income = Span(location=span, dimension='height', + line_color='black', line_dash='dotted', line_width=1.5) fig.add_layout(filer_income) label_format = f'{span:,}' filer_income_label = Label(x=span, y=25, y_units='screen', x_offset=10, text="{}: $".format(mtr_opt) + label_format, - text_color='#303030', text_font="arial", text_font_style="italic", text_font_size = "10pt") + text_color='#303030', text_font="arial", text_font_style="italic", text_font_size="10pt") fig.add_layout(filer_income_label) - axis = Span(location=0, dimension='width', line_color='#bfbfbf', line_width=1.5) + axis = Span(location=0, dimension='width', + line_color='#bfbfbf', line_width=1.5) fig.add_layout(axis) iitax_base = fig.line(x="Axis", y="Individual Income Tax", line_color='#2b83ba', muted_color='#2b83ba', @@ -80,19 +82,21 @@ def rate_plot(df_base, df_reform, span, mtr_opt): df_reform = ColumnDataSource(df_reform) tools = "pan, zoom_in, zoom_out, reset" fig = figure(plot_width=600, plot_height=500, - x_range=(-10000, 300000), y_range=(-0.3, 0.5), tools=tools, active_drag="pan") + x_range=(-10000, 300000), y_range=(-0.3, 0.5), tools=tools, active_drag="pan") fig.yaxis.axis_label = "Tax Rate" fig.yaxis.formatter = NumeralTickFormatter(format="0%") - - filer_income = Span(location=span, dimension='height', line_color='black', line_dash='dotted', line_width=1.5) + + filer_income = Span(location=span, dimension='height', + line_color='black', line_dash='dotted', line_width=1.5) fig.add_layout(filer_income) label_format = f'{span:,}' - filer_income_label = Label(x=span, y=25, y_units='screen', x_offset=10, text="{}: $".format(mtr_opt) + label_format, - text_color='#303030', text_font="arial", text_font_style="italic", text_font_size = "10pt") + filer_income_label = Label(x=span, y=25, y_units='screen', x_offset=10, text="{}: $".format(mtr_opt) + label_format, + text_color='#303030', text_font="arial", text_font_style="italic", text_font_size="10pt") fig.add_layout(filer_income_label) - axis = Span(location=0, dimension='width', line_color='#bfbfbf', line_width=1.5) + axis = Span(location=0, dimension='width', + line_color='#bfbfbf', line_width=1.5) fig.add_layout(axis) - + iitax_atr_base = fig.line(x="Axis", y="IATR", line_color='#2b83ba', muted_color='#2b83ba', line_width=2, legend_label="Income Tax Average Rate", muted_alpha=0.1, source=df_base) payroll_atr_base = fig.line(x="Axis", y="PATR", line_color='#abdda4', muted_color='#abdda4', @@ -168,13 +172,15 @@ def credit_plot(df_base, df_reform, span, mtr_opt): fig = figure(plot_width=600, plot_height=500, x_range=( -2500, 70000), tools=tools, active_drag="pan") - filer_income = Span(location=span, dimension='height', line_color='black', line_dash='dotted', line_width=1.5) + filer_income = Span(location=span, dimension='height', + line_color='black', line_dash='dotted', line_width=1.5) fig.add_layout(filer_income) label_format = f'{span:,}' filer_income_label = Label(x=span, y=45, y_units='screen', x_offset=10, text="{}: $".format(mtr_opt) + label_format, - text_color='#303030', text_font="arial", text_font_style="italic", text_font_size = "10pt") + text_color='#303030', text_font="arial", text_font_style="italic", text_font_size="10pt") fig.add_layout(filer_income_label) - axis = Span(location=0, dimension='width', line_color='#bfbfbf', line_width=1.5) + axis = Span(location=0, dimension='width', + line_color='#bfbfbf', line_width=1.5) fig.add_layout(axis) eitc_base = fig.line(x="Axis", y="EITC", line_color='#2b83ba', muted_color='#2b83ba', @@ -242,4 +248,4 @@ def credit_plot(df_base, df_reform, span, mtr_opt): "data": data } - return outputs \ No newline at end of file + return outputs