reno.viz.ModelLatex#
- class reno.viz.ModelLatex(model, show_docs=False, start_name=None, stop_name=None, t=None, sample=0, debug=False)#
Bases:
objectAn interactive widget that displays all of the latex equations of a model.
Use with debug=True to display all of the values in the equation at a particular timestep and sample.
NOTE: start_name is exclusive, stop_name is inclusive.
- Parameters:
model (Model) – The system dynamics model to get the equations for.
show_docs (bool) – Whether to display docstrings below each relevant equation.
start_name (str) – Don’t display any equations before the one specified (in order of their definition.) This is mostly unused for now, intended to eventually allow displaying sets of graphs “between” equations.
stop_name (str) – Don’t display any equations after the one specified (in order of their definition.) This is mostly unused for now, intended to eventually allow displaying sets of graphs “between” equations.
t (int) – Only used when debug is True, refers to the timestep to use for displaying the current values within each equation.
sample (int) – Only used when debug is True, refers to which sample to use for displaying the current values within each equation.
debug (bool) – If true, display the value of every reference at the specified t and sample.
Example
>>> ModelLatex(my_model).widget
>>> ModelLatex(my_model, t=3, sample=0, debug=True).widget
Methods
__init__(model[, show_docs, start_name, ...])Get the name of the reference/equation for the clicked index.
fire_on_name_clicked(name)Trigger the event to notify that a reference/eq was clicked on.
latex_data_with_highlight([hl_name])Construct the latex string with highlighting for the specified name.
on_name_clicked(callback)Register an event handler for when an equation is clicked.
Attributes
This is the actual displayable object, use this to "view" the equations.
- __annotations__ = {}#
- __dict__ = mappingproxy({'__module__': 'reno.viz', '__doc__': 'An interactive widget that displays all of the latex equations of a model.\n\n Use with `debug=True` to display all of the values in the equation at a particular\n timestep and sample.\n\n NOTE: start_name is exclusive, stop_name is inclusive.\n\n Args:\n model (Model): The system dynamics model to get the equations for.\n show_docs (bool): Whether to display docstrings below each relevant equation.\n start_name (str): Don\'t display any equations before the one specified (in order\n of their definition.) This is mostly unused for now, intended to eventually\n allow displaying sets of graphs "between" equations.\n stop_name (str): Don\'t display any equations after the one specified (in order\n of their definition.) This is mostly unused for now, intended to eventually\n allow displaying sets of graphs "between" equations.\n t (int): Only used when `debug` is `True`, refers to the timestep to use for\n displaying the current values within each equation.\n sample (int): Only used when `debug` is `True`, refers to which sample to use\n for displaying the current values within each equation.\n debug (bool): If true, display the value of every reference at the specified `t`\n and `sample`.\n\n Example:\n >>> ModelLatex(my_model).widget\n\n >>> ModelLatex(my_model, t=3, sample=0, debug=True).widget\n ', '__init__': <function ModelLatex.__init__>, 'on_name_clicked': <function ModelLatex.on_name_clicked>, 'fire_on_name_clicked': <function ModelLatex.fire_on_name_clicked>, '_handle_ilatex_click': <function ModelLatex._handle_ilatex_click>, 'find_equation_name_from_index': <function ModelLatex.find_equation_name_from_index>, '_equation_lines_refname_reference': <function ModelLatex._equation_lines_refname_reference>, 'latex_data_with_highlight': <function ModelLatex.latex_data_with_highlight>, '__dict__': <attribute '__dict__' of 'ModelLatex' objects>, '__weakref__': <attribute '__weakref__' of 'ModelLatex' objects>, '__annotations__': {'_name_clicked_callbacks': 'list[Callable[[str], None]]'}})#
- __module__ = 'reno.viz'#
- __weakref__#
list of weak references to the object
- find_equation_name_from_index(i)#
Get the name of the reference/equation for the clicked index.
Returns
Noneif not found or outside the start/stop bounds.- Parameters:
i (int)
- Return type:
str
- fire_on_name_clicked(name)#
Trigger the event to notify that a reference/eq was clicked on.
- Parameters:
name (str)
- latex_data_with_highlight(hl_name=None)#
Construct the latex string with highlighting for the specified name.
- Parameters:
hl_name (str)
- Return type:
str
- on_name_clicked(callback)#
Register an event handler for when an equation is clicked.
Callbacks should take a single parameter which is the string name of the equation/ref that was clicked.
- Parameters:
callback (Callable[[str], None])
- widget#
This is the actual displayable object, use this to “view” the equations.