Skip to content

Commit

Permalink
Merge pull request #1 from ydataai/fix/broken_references
Browse files Browse the repository at this point in the history
fix: update deprecated methods
  • Loading branch information
alexbarros authored May 30, 2023
2 parents 68b6d11 + 7764129 commit c6def3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions pdf_reports/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import datetime
import textwrap

from matplotlib.axes import Axes


def dataframe_to_html(
dataframe,
Expand Down Expand Up @@ -157,8 +159,7 @@ def figure_data(fig, size=None, fmt="png", bbox_inches="tight", **kwargs):
**kwargs
Any other option of Matplotlib's figure.savefig() method.
"""
if "AxesSubplot" in str(fig.__class__):
# A matplotlib axis was provided: take its containing figure.
if isinstance(fig, Axes):
fig = fig.figure
output = BytesIO()
original_size = fig.get_size_inches()
Expand Down
10 changes: 5 additions & 5 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

matplotlib.use("Agg")
import matplotlib.pyplot as plt
from PyPDF2 import PdfFileReader
from PyPDF2 import PdfReader


def test_pug_to_html():
Expand All @@ -25,8 +25,8 @@ def test_basics(tmpdir):
html = pug_to_html(template_path, title="Summary of your order")
write_report(html, pdf_path)
with open(pdf_path, "rb") as f:
reader = PdfFileReader(f)
assert reader.numPages == 2
reader = PdfReader(f)
assert len(reader.pages) == 2

pdf_data = write_report(html)
assert len(pdf_data) > 10000
Expand All @@ -49,8 +49,8 @@ def test_with_plots_and_tables(tmpdir):
html = pug_to_html(template_path, dataframe=dataframe)
write_report(html, pdf_path)
with open(pdf_path, "rb") as f:
reader = PdfFileReader(f)
assert reader.numPages == 2
reader = PdfReader(f)
assert len(reader.pages) == 2

pdf_data = write_report(html)
assert len(pdf_data) > 10000
Expand Down

0 comments on commit c6def3f

Please sign in to comment.