osl_dynamics.utils.model
#
Utility classes and functions related to the models.
Module Contents#
Classes#
A simple table class that stores data in rows and columns. |
|
Class for creating HTML tables. |
|
Class for creating LaTeX tables. |
Functions#
|
Escape characters which require control sequences in text for use |
- osl_dynamics.utils.model.tex_escape(text)[source]#
Escape characters which require control sequences in text for use in LaTeX.
- Parameters:
text (str) – Text to be escaped.
- Returns:
escaped_text – Escaped text.
- Return type:
str
- class osl_dynamics.utils.model.Table(headers)[source]#
A simple table class that stores data in rows and columns.
- Parameters:
headers (list) – List of strings for the table headers.
- class osl_dynamics.utils.model.HTMLTable(headers)[source]#
Bases:
Table
Class for creating HTML tables.
- headers#
The table headers.
- Type:
list of str
- rows#
The table rows.
- Type:
list of list of str
- append_last(item)[source]#
Append an item to the last cell in the last row.
- Parameters:
item (str) – The string to append to the cell.
- html_row(items)[source]#
Format a list of strings as an HTML table row.
- Parameters:
items (list of str) – A list of
str
to be added to the HTML table.- Returns:
html – The HTML table row.
- Return type:
str
- html_headers()[source]#
Generate HTML table headers from self.headers
- Returns:
headers – HTML table headers
- Return type:
str
- class osl_dynamics.utils.model.LatexTable(headers, *, vertical_lines=True, horizontal_lines=True, header_lines=True)[source]#
Bases:
Table
Class for creating LaTeX tables.
- headers#
The table headers.
- Type:
list of str
- rows#
The table rows.
- Type:
list of list of str
- vertical_lines#
Whether to draw vertical lines, by default
True
.- Type:
bool, optional
- horizontal_lines#
Whether to draw horizontal lines, by default
True
.- Type:
bool, optional
- header_lines#
Whether to draw horizontal lines above the header, by default
True
.- Type:
bool, optional
- append_last(item)[source]#
Append an item on the last row of the table.
- Parameters:
item (any) – Item to append.
- static latex_row(items)[source]#
Create a latex row from a list of strings.
- Parameters:
items (list of strings) – The list of strings to be turned into a row.
- Returns:
latex_row – The latex row.
- Return type:
string