pyCBD.converters.latexify.CBD2Latex module¶
- class pyCBD.converters.latexify.CBD2Latex.CBD2Latex(model, **kwargs)[source]¶
Bases:
objectCreates a corresponding set of LaTeX-equations for a CBD model.
- Parameters
model (pyCBD.Core.CBD) – The model to create the equations for.
- Keyword Arguments
show_steps (bool) – When
True, all intermediary steps will be shown. Defaults toFalse.ignore_path (bool) – When
True, the name of the original model will be removed from all path names. This name is a common prefix over the system. Defaults toTrue.escape_nonlatex (bool) – When
True, non-latex characters (e.g., underscores) are escaped from the rendered result, if rendered as LaTeX. Defaults toTrue.time_variable (str) – The name for the variable that represents the time (i.e., the current iteration). Defaults to
'i'.render_latex (bool) – When
True, therender()method will output a latex-formatted string. Otherwise, simple text formatting is done. Defaults toTrue.time_format (str) – How the time must be formatted when rendered. By default, it will be placed in parentheses at the end. Use
{time}to identify the time constant.delta_t (str) – Representation of the used delta in the render. This will be appended to values that have been computed for a delay block. This is only to be used when the time does not identify the iteration, but the actual simulation time. Defaults to
'i'.replace_par (bool) – When
True, the parentheses will be replaced by the much cleaner\left(and\right), if rendered in LaTeX-format. Defaults toTrue.type_formats (dict) –
A dictionary of
{ operationType -> callable }that allows for the remapping of mathematical descriptions based, whereoperationTypeidentifies the operation to remap andcallablea function that takes the name/symbol and the arguments as input and produces a list of function objects.path_sep (str) – The separator to use for the paths. Defaults to
".".path_prefix (str) – The prefix to use for the paths. Defaults to the empty string.
ignore (iterable) – A list of block classes not to flatten.
- DEFAULT_CONFIG = {'delta_t': 'i', 'escape_nonlatex': True, 'ignore': [], 'ignore_path': True, 'path_prefix': '', 'path_sep': '.', 'render_latex': True, 'replace_par': True, 'show_steps': False, 'time_format': '({time})', 'time_variable': 'i', 'type_formats': {}}¶
Default configuration setup.
- static rename(name, config, model)[source]¶
Makes the name of a path accurate.
- Parameters
name (str) – The name to convert.
config (dict) – Configuration dictionary (see above).
model (CBD) – The parent pyCBD model.
- render(rl=None)[source]¶
Creates the LaTeX string for the model, based on the current level of simplifications.
- Parameters
rl (bool) – Identifies if the rendering must result in a LaTeX-renderable string. This argument basically overwrites the
render_latexconfig attribute. WhenNone, the value from the config is used. Defaults toNone.
- eq(time=<pyCBD.converters.latexify.functions.Time object>)[source]¶
Obtains the current set of equations in a format that can be parsed by the
pyCBD.converters.eq2CBDconverter. This allows model simplifications and optimizations.- Parameters
time (Time) – The time at which to obtain the equations.
- simplify_links()[source]¶
First step to execute is a link simplification. Generally, there are more links than blocks, so this function will take care of the largest simplification.
- substitute()[source]¶
Combines multiple equations into one, based on the requested output, by means of substitution. This function will be called multiple times: once for each “step” in the simplification.
See also
- simplify(steps=- 1)[source]¶
Simplifies the system of equations to become a more optimal solution.
- Parameters
steps (int) – When positive, this indicates the amount of steps that must be taken. When negative, the equations will be simplified until a convergence (i.e. no possible changes) is reached. Defaults to -1.
See also