Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into benefits_totals
Browse files Browse the repository at this point in the history
  • Loading branch information
jdebacker committed Jun 19, 2020
2 parents 8e80407 + dfe852e commit 876d728
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ dependencies:
- pypandoc
- nodejs
- pip
- geckodriver
- firefox
- pip:
- cs-kit

20 changes: 6 additions & 14 deletions taxbrain/report.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import behresp
import taxbrain
import taxcalc as tc
import cairocffi as cairo
from pathlib import Path
from bokeh.io import export_png, export_svgs
from .report_utils import (form_intro, form_baseline_intro, write_text, date,
Expand Down Expand Up @@ -45,20 +44,13 @@ def format_table(df):

def export_plot(plot, graph):
"""
Export a bokeh plot based on Cairo version
Export bokeh plot as a PNG
"""
# export graph as a PNG or SVG depending on Cairo version is installed
# higher quality SVG only works with Cairo version >= 1.15.4
cairo_version = cairo.cairo_version()
if cairo_version < 11504:
filename = f"{graph}_graph.png"
full_filename = Path(output_path, filename)
export_png(plot, full_filename)
print("For a higher quality SVG image file, install Cairo 1.15.4")
else:
filename = f"{graph}_graph.svg"
full_filename = Path(output_path, filename)
export_svgs(plot, filename=full_filename)
# we could get a higher quality image with an SVG, but the SVG plots
# do not render correctly in the PDF document
filename = f"{graph}_graph.png"
full_filename = Path(output_path, filename)
export_png(plot, filename=str(full_filename))

return filename

Expand Down
6 changes: 2 additions & 4 deletions taxbrain/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def test_report(tb_static):
assert Path(dir_path, "Test-Report.pdf").exists()
assert Path(dir_path, "Test-Report.html").exists()
diff_png = Path(dir_path, "difference_graph.png")
diff_svg = Path(dir_path, "difference_graph.svg")
assert diff_png.exists() or diff_svg.exists()
assert diff_png.exists()
dist_png = Path(dir_path, "dist_graph.png")
dist_svg = Path(dir_path, "dist_graph.svg")
assert dist_png.exists() or dist_svg.exists()
assert dist_png.exists()
shutil.rmtree(dir_path)

0 comments on commit 876d728

Please sign in to comment.