Utilities Module#
Utility functions for the MacroStat model.
The macrostat.util module consists of the following classes
Utility functions for extracting and formatting docstring information from Behavior classes. |
|
Batch processing functionionality |
- macrostat.util.generate_latex_documentation(behavior_class: Type[Behavior], output_file: str = None, title: str = None, subsec: bool = True, preamble: str = None) str[source]#
Make a LaTeX model description from a Behavior class.
This function takes a Behavior class and returns a LaTeX model description by parsing the docstrings of the initialize() and the step() methods. It then copies the docstrings of those methods and all of the methods that they call. From each, it extracts the description and the equations section, and then formats them for LaTeX. It then saves the LaTeX code to a file if an output file is provided.
- Parameters:
behavior_class (Type[Behavior]) – The Behavior class to make a LaTeX model description from.
output_file (str, optional) – The file to save the LaTeX model description to.
title (str, optional) – The title of the LaTeX model description.
subsec (bool, optional) – If True, add a subsection for each method. If False, just append the description and equations.
preamble (str, optional) – A string of LaTeX code to add to the preamble of the document, i.e. before the begin{document} command.
- Returns:
The LaTeX model description.
- Return type:
Examples
>>> from macrostat.models import get_model >>> GL06SIM = get_model("GL06SIM") >>> tex = generate_documentation(GL06SIM().behavior) >>> print(tex)