report¶
PDF reporting.
toric_spines_sim.report
¶
PDF report builder wrapping ReportLab (matplotlib and Plotly figures).
Use PdfReport to accumulate titles, tables, and figures, then build().
PdfReport(output_path, *, pagesize=letter, left_margin=0.75 * inch, right_margin=0.75 * inch, top_margin=0.75 * inch, bottom_margin=0.75 * inch)
¶
Accumulate a letter-size PDF of text, tables, and figures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
str
|
Destination |
required |
pagesize
|
Tuple[float, float]
|
ReportLab page setup (defaults: letter, 0.75 in margins). |
letter
|
left_margin
|
Tuple[float, float]
|
ReportLab page setup (defaults: letter, 0.75 in margins). |
letter
|
right_margin
|
Tuple[float, float]
|
ReportLab page setup (defaults: letter, 0.75 in margins). |
letter
|
top_margin
|
Tuple[float, float]
|
ReportLab page setup (defaults: letter, 0.75 in margins). |
letter
|
bottom_margin
|
Tuple[float, float]
|
ReportLab page setup (defaults: letter, 0.75 in margins). |
letter
|
Examples:
>>> report = PdfReport("out.pdf")
>>> report.add_title("TS1")
>>> report.add_figure(fig) # matplotlib or plotly
>>> report.build()
Source code in toric_spines_sim/report.py
content_width
property
¶
Usable page width in points (ReportLab units).
content_width_in
property
¶
Usable page width in inches.
content_max_height
property
¶
Maximum embeddable figure height in points.
content_max_height_in
property
¶
Maximum embeddable figure height in inches.
figure_size(fig_width, fig_height)
¶
Matplotlib figsize (inches) scaled to this report's content area.
Source code in toric_spines_sim/report.py
add_title(text)
¶
add_heading(text, *, level=1)
¶
Append a heading (level 1–3).
Source code in toric_spines_sim/report.py
add_paragraph(text)
¶
add_spacer(height=0.1 * inch)
¶
add_page_break()
¶
add_table(data, *, col_widths=None, row_heights=None, grid=True, header_row=False)
¶
Append a grid table. First row is styled as a header if header_row.
Source code in toric_spines_sim/report.py
add_dict_table(data, *, column_names=('Key', 'Value'), columns=None, grid=True, header=True)
¶
Append a key/value table, optionally split across even column pairs.
Source code in toric_spines_sim/report.py
add_image(image_source, *, width=None, height=None, figure_spacer=0.1 * inch)
¶
Embed a raster image, scaled to content width by default.
Source code in toric_spines_sim/report.py
add_figure(fig, *, width=None, height=None, dpi=300, figure_spacer=None)
¶
Embed a matplotlib or Plotly figure as PNG.
Source code in toric_spines_sim/report.py
add_section_figure(fig, *, heading=None, level=3, paragraph=None, page_break_after=False, **figure_kwargs)
¶
Add optional heading/paragraph followed by a figure.
Source code in toric_spines_sim/report.py
add_simulation(name, *, parameters=None, metrics=None, figures=None, page_break_after=False)
¶
Append a named simulation block: parameter table, metrics, figures.
Source code in toric_spines_sim/report.py
figure_size_for_page(fig_width, fig_height, *, width_in, max_height_in)
¶
Return (width, height) in inches that fit the page content area.