boltzkit.utils.pdf

Functions

matplotlib_to_pdf_buffer(obj)

Convert a matplotlib Figure or Axes to a PDF stored in memory.

pdf_to_pillow_image(pdf_buffer[, dpi])

pdf_to_wandb_image(pdf_buffer[, dpi])

plot_pdf(pdf_buffer[, dpi, ax, show, title])

This function is mainly for debugging purposes

save_pdf(obj, path)

Save a pdf in the form of a buffer into a PDF file.

save_pdfs(pdfs, dirpath)

Save a dict of pdfs into a directory.

Classes

PdfBuffer

A wrapper to allow differentiation of raw data by type.

class boltzkit.utils.pdf.PdfBuffer[source]

Bases: object

A wrapper to allow differentiation of raw data by type.

buffer: BytesIO
__init__(buffer: BytesIO) None
boltzkit.utils.pdf.matplotlib_to_pdf_buffer(obj: Figure | Axes) PdfBuffer[source]

Convert a matplotlib Figure or Axes to a PDF stored in memory.

Returns:

Buffer containing PDF bytes.

Return type:

io.BytesIO

boltzkit.utils.pdf.save_pdf(obj: PdfBuffer, path: str) None[source]

Save a pdf in the form of a buffer into a PDF file.

boltzkit.utils.pdf.save_pdfs(pdfs: dict[str, PdfBuffer], dirpath: str) None[source]

Save a dict of pdfs into a directory. dir must exist.

boltzkit.utils.pdf.pdf_to_pillow_image(pdf_buffer: PdfBuffer, dpi=50)[source]
boltzkit.utils.pdf.pdf_to_wandb_image(pdf_buffer: PdfBuffer, dpi=50)[source]
boltzkit.utils.pdf.plot_pdf(pdf_buffer: PdfBuffer, dpi=500, ax=None, show: bool = False, title: str | None = None)[source]

This function is mainly for debugging purposes