sas.qtgui.Utilities.Reports package

Subpackages

Submodules

sas.qtgui.Utilities.Reports.ReportDialog module

class sas.qtgui.Utilities.Reports.ReportDialog.ReportDialog(report_data: ReportData, parent: QObject | None = None)

Bases: QDialog, Ui_ReportDialogUI

Class for stateless grid-like printout of model parameters for mutiple models

__annotate_func__ = None
__annotations_cache__ = {}
__doc__ = '\nClass for stateless grid-like printout of model parameters for mutiple models\n'
__firstlineno__ = 15
__init__(report_data: ReportData, parent: QObject | None = None)
__module__ = 'sas.qtgui.Utilities.Reports.ReportDialog'
__static_attributes__ = ('report_data', 'save_location')
onPrint()

Display the print dialog and send the report to printer

onSave()

Display the Save As… prompt and save the report if instructed so

static save_pdf(data, filename)

Create a PDF file from html source string. Returns True is the file creation was successful. : data: html string : filename: name of file to be saved

setupDialog(output=None)

Display the HTML content in the browser.

staticMetaObject = PySide6.QtCore.QMetaObject("ReportDialog" inherits "QDialog": )
static write_string(string, filename)

Write string to file

sas.qtgui.Utilities.Reports.reportdata module

class sas.qtgui.Utilities.Reports.reportdata.ReportData(html: str = '<html><body>No Data</body></html>', text: str = 'No data')

Bases: object

__annotate_func__()
__annotations_cache__ = {'html': <class 'str'>, 'text': <class 'str'>}
__dataclass_fields__ = {'html': Field(name='html',type=<class 'str'>,default='<html><body>No Data</body></html>',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'text': Field(name='text',type=<class 'str'>,default='No data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD)}
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)
__dict__ = mappingproxy({'__module__': 'sas.qtgui.Utilities.Reports.reportdata', '__firstlineno__': 4, 'html': '<html><body>No Data</body></html>', 'text': 'No data', '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'ReportData' objects>, '__weakref__': <attribute '__weakref__' of 'ReportData' objects>, '__doc__': "ReportData(html: str = '<html><body>No Data</body></html>', text: str = 'No data')", '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False), '__annotations_cache__': {'html': <class 'str'>, 'text': <class 'str'>}, '__dataclass_fields__': {'html': Field(name='html',type=<class 'str'>,default='<html><body>No Data</body></html>',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD), 'text': Field(name='text',type=<class 'str'>,default='No data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,doc=None,_field_type=_FIELD)}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function ReportData.__init__>, '__repr__': <function ReportData.__repr__>, '__eq__': <function ReportData.__eq__>, '__match_args__': ('html', 'text'), '__annotate_func__': None})
__doc__ = "ReportData(html: str = '<html><body>No Data</body></html>', text: str = 'No data')"
__eq__(other)

Return self==value.

__firstlineno__ = 4
__hash__ = None
__init__(html: str = '<html><body>No Data</body></html>', text: str = 'No data') None
__match_args__ = ('html', 'text')
__module__ = 'sas.qtgui.Utilities.Reports.reportdata'
__replace__(**changes)
__repr__()

Return repr(self).

__static_attributes__ = ()
__weakref__

list of weak references to the object

html: str = '<html><body>No Data</body></html>'
text: str = 'No data'

sas.qtgui.Utilities.Reports.reports module

class sas.qtgui.Utilities.Reports.reports.ReportBase(title: str, style_link: str | None = None, show_figure_section_title=True, show_param_section_title=True)

Bases: object

__annotate_func__ = None
__annotations_cache__ = {}
__dict__ = mappingproxy({'__module__': 'sas.qtgui.Utilities.Reports.reports', '__firstlineno__': 69, '__init__': <function ReportBase.__init__>, 'add_data_details': <function ReportBase.add_data_details>, 'add_plot': <function ReportBase.add_plot>, '_add_plot_svg': <function ReportBase._add_plot_svg>, '_add_plot_png': <function ReportBase._add_plot_png>, 'add_image_from_file': <function ReportBase.add_image_from_file>, 'add_image_from_bytes': <function ReportBase.add_image_from_bytes>, 'add_table_dict': <function ReportBase.add_table_dict>, 'add_table': <function ReportBase.add_table>, 'text': <property object>, 'html': <property object>, 'report_data': <property object>, 'save_html': <function ReportBase.save_html>, 'save_text': <function ReportBase.save_text>, 'save_pdf': <function ReportBase.save_pdf>, '__static_attributes__': ('_html_doc', 'plots'), '__dict__': <attribute '__dict__' of 'ReportBase' objects>, '__weakref__': <attribute '__weakref__' of 'ReportBase' objects>, '__doc__': None, '__annotations_cache__': {}})
__doc__ = None
__firstlineno__ = 69
__init__(title: str, style_link: str | None = None, show_figure_section_title=True, show_param_section_title=True)

Holds a (DOM) representation of a report, the details that need to go into the report can be added with reasonably simple calls, e.g. add_table, add_plot

Parameters:
  • title – Report title

  • style_link – If provided will set style in the html to the specified URL, rather than embedding contents from local report_style.css

Show_figure_section_title:

Add h2 tag for figure section

Show_figure_section_title:

Add h2 tag for parameters section

__module__ = 'sas.qtgui.Utilities.Reports.reports'
__static_attributes__ = ('_html_doc', 'plots')
__weakref__

list of weak references to the object

_add_plot_png(fig)
_add_plot_svg(fig)
add_data_details(data: Data1D)

Add details of input data to the report

add_image_from_bytes(bytes: BytesIO, file_type='png')

Add an image from a BytesIO object

add_image_from_file(filename: str)

Add image to report from a source file

add_plot(fig, image_type='png', figure_title: str | None = None)

Add a plot to the report

Parameters:
  • fig – matplotlib.figure.Figure, Matplotlib figure object to add

  • image_type – str, type of embedded image - ‘svg’ or ‘png’, defaults to ‘svg’

  • figure_title – Optional[str] - Optionally add an html header tag, defaults to None

Raises:

ValueError – if image_type is bad

add_table(data: list[list[Any]], titles: Iterable[str] | None = None, target_tag='model-parameters', column_prefix='column')

Add a table of parameters to the report

add_table_dict(d: dict[str, Any], titles: tuple[str, str] | None = None)
property html: str

A string containing the html of the document

property report_data: ReportData
save_html(filename: str)
save_pdf(filename: str)
save_text(filename: str)
property text: str

Text version of the document (actually RST)

sas.qtgui.Utilities.Reports.reports.main()

This can be run locally without sasview to make it easy to adjust the report layout/styling, it will generate a report with some arbitrary data

class sas.qtgui.Utilities.Reports.reports.pretty_units(*args, **kwargs)

Bases: span

HTML tag for units, prettifies angstroms, inverse angstroms and inverse cm TODO: Should be replaced when there is a better way of handling units

__annotate_func__ = None
__annotations_cache__ = {}
__doc__ = 'HTML tag for units, prettifies angstroms, inverse angstroms and inverse cm\nTODO: Should be replaced when there is a better way of handling units'
__firstlineno__ = 31
__init__(unit_string: str, *args, **kwargs)

Creates a new html tag instance.

__module__ = 'sas.qtgui.Utilities.Reports.reports'
__static_attributes__ = ()
tagname = 'span'

Module contents