Skip to content

Commit

Permalink
Merge pull request #113 from Peter-Metz/data-update
Browse files Browse the repository at this point in the history
Updates for recent releases of Bokeh and Tax-Calculator
  • Loading branch information
hdoupe authored Mar 24, 2020
2 parents a59c61b + 5aeb70d commit 94c4ab5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cs-config/cs_config/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"choice": {
"choices": [
yr for yr in range(TaxBrain.FIRST_BUDGET_YEAR,
TaxBrain.LAST_BUDGET_YEAR)
TaxBrain.LAST_BUDGET_YEAR + 1)
]
}
}
Expand Down Expand Up @@ -135,7 +135,7 @@ class MetaParameters(paramtools.Parameters):
"choice": {
"choices": [
yr for yr in range(TaxBrain.FIRST_BUDGET_YEAR,
TaxBrain.LAST_BUDGET_YEAR)
TaxBrain.LAST_BUDGET_YEAR + 1)
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions cs-config/cs_config/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def handle_data_source(param_data):

new_pcl = defaultdict(dict)
new_pcl["schema"] = POLICY_SCHEMA
LAST_YEAR = 2026
LAST_YEAR = 2030
pol = Policy()
pol.set_year(2026)
pol.set_year(2030)
for param, item in pcl.items():
values = []
pol_val = getattr(pol, f"_{param}").tolist()
Expand Down
22 changes: 12 additions & 10 deletions cs-config/cs_config/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ def aggregate_plot(tb):
fig = figure(title="Aggregate Tax Liability by Year",
width=700, height=500, tools="save")
ii_base = fig.line(x="index", y="iitax", line_width=4,
line_color="#12719e", legend="Income Tax - Base",
line_color="#12719e", legend_label="Income Tax - Base",
source=base_cds)
ii_reform = fig.line(x="index", y="iitax", line_width=4,
line_color="#73bfe2", legend="Income Tax - Reform",
line_color="#73bfe2", legend_label="Income Tax - Reform",
source=reform_cds)
proll_base = fig.line(x="index", y="payrolltax", line_width=4,
line_color="#408941", legend="Payroll Tax - Base",
line_color="#408941", legend_label="Payroll Tax - Base",
source=base_cds)
proll_reform = fig.line(x="index", y="payrolltax", line_width=4,
line_color="#98cf90", legend="Payroll Tax - Reform",
line_color="#98cf90", legend_label="Payroll Tax - Reform",
source=reform_cds)
comb_base = fig.line(x="index", y="combined", line_width=4,
line_color="#a4201d", legend="Combined - Base",
line_color="#a4201d", legend_label="Combined - Base",
source=base_cds)
comb_reform = fig.line(x="index", y="combined", line_width=4,
line_color="#e9807d", legend="Combined - Reform",
line_color="#e9807d", legend_label="Combined - Reform",
source=reform_cds)

# format figure
Expand Down Expand Up @@ -84,18 +84,20 @@ def aggregate_plot(tb):
object2.visible = toggle.active
object3.visible = toggle.active
"""
base_callback = CustomJS.from_coffeescript(code=plot_js, args={})
base_callback = CustomJS(code=plot_js, args={})
base_toggle = Toggle(label="Base", button_type="primary",
callback=base_callback, active=True)
active=True)
base_callback.args = {"toggle": base_toggle, "object1": ii_base,
"object2": proll_base, "object3": comb_base}
base_toggle.js_on_change('active', base_callback)

reform_callback = CustomJS.from_coffeescript(code=plot_js, args={})
reform_callback = CustomJS(code=plot_js, args={})
reform_toggle = Toggle(label="Reform", button_type="primary",
callback=reform_callback, active=True)
active=True)
reform_callback.args = {"toggle": reform_toggle, "object1": ii_reform,
"object2": proll_reform, "object3": comb_reform}
fig_layout = layout([fig], [base_toggle, reform_toggle])
reform_toggle.js_on_change('active', reform_callback)

# Components needed to embed the figure
data = json_item(fig_layout)
Expand Down
12 changes: 6 additions & 6 deletions cs-config/cs_config/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ def test_convert_adj():

assert res == {
"STD": {
2019: [0, 1, 12268.8, 18403.2, 24537.6],
2022: [0.0, 10, 13081.03, 19621.54, 26162.06]
2019: [0, 1, 12200.0, 18350.0, 24400.0],
2022: [0.0, 10, 12950.37, 19478.63, 25900.74]
},
"CPI_offset": {2019: -0.001},
"EITC_c": {2019: [1000.0, 3538.53, 5844.04, 6575.05]},
"EITC_c": {2019: [1000.0, 3526.0, 5828.0, 6557.0]},
"BEN_ssi_repeal": {2019: True}
}

Expand All @@ -125,8 +125,8 @@ def test_convert_adj_w_index():
},
"ACTC_c": {2019: 2000.0, 2026: 1000.0},
"STD": {
2019: [2000.0, 24537.6, 12268.8, 18403.2, 24537.6],
2020: [2000.0, 12345, 12268.8, 18403.2, 24537.6],
2026: [1000.0, 12345.0, 12268.8, 18403.2, 24537.6]
2019: [2000.0, 24400.0, 12200.0, 18350.0, 24400.0],
2020: [2000.0, 12345, 12200.0, 18350.0, 24400.0],
2026: [1000.0, 12345.0, 12200.0, 18350.0, 24400.0]
}
}
2 changes: 1 addition & 1 deletion cs-config/install.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# bash commands for installing your package
conda install -c pslmodels -c conda-forge nodejs "taxbrain>=2.3.2" "taxcalc>=2.5.0" "paramtools>=0.10.2" pypandoc
conda install -c pslmodels -c conda-forge nodejs "taxbrain>=2.3.2" "taxcalc>=2.5.0" "paramtools>=0.10.2" bokeh pypandoc
2 changes: 1 addition & 1 deletion taxbrain/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def export_plot(plot, graph):
else:
filename = f"{graph}_graph.svg"
full_filename = Path(output_path, filename)
export_svgs(plot, full_filename)
export_svgs(plot, filename=full_filename)

return filename

Expand Down
6 changes: 3 additions & 3 deletions taxbrain/tests/expected_weighted_table.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
,2018,2019
Base,2469977377368.852,2615396291735.824
Reform,2469977377368.852,2643836717370.0815
Difference,0.0,28440425634.257324
Base,2481877857290.395,2626559393875.8115
Reform,2481877857290.395,2651607151121.6987
Difference,0.0,25047757245.887207

0 comments on commit 94c4ab5

Please sign in to comment.