CBD.converters.latexify.CBD2Latex module

class CBD.converters.latexify.CBD2Latex.CBD2Latex(model, **kwargs)[source]

Bases: object

Creates a corresponding set of LaTeX-equations for a CBD model.

Parameters

model (CBD.Core.CBD) – The model to create the equations for.

Keyword Arguments
  • show_steps (bool) – When True, all intermediary steps will be shown. Defaults to False.

  • 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 to True.

  • escape_nonlatex (bool) – When True, non-latex characters (e.g., underscores) are escaped from the rendered result, if rendered as LaTeX. Defaults to True.

  • 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, the render() method will output a latex-formatted string. Otherwise, simple text formatting is done. Defaults to True.

  • 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 to True.

  • type_formats (dict) –

    A dictionary of { operationType -> callable } that allows for the remapping of mathematical descriptions based, where operationType identifies the operation to remap and callable a 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 strig.

DEFAULT_CONFIG = {'delta_t': 'i', 'escape_nonlatex': True, '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 CBD model.

get_block_equation(block)[source]
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_latex config attribute. When None, the value from the config is used. Defaults to None.

eq(time=<CBD.converters.latexify.functions.Time object>)[source]

Obtains the current set of equations in a format that can be parsed by the CBD.converters.eq2CBD converter. This allows model simplifications and optimizations.

Parameters

time (Time) – The time at which to obtain the equations.

latex()[source]

Obtains the current set of equations in LaTeX format.

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()

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.