CBD.converters.latexify.functions module

New and improved LaTeX-generation module.

class CBD.converters.latexify.functions.Time(value, relative=False)[source]

Bases: object

Represents the time variable to be used in the equations.

Parameters
  • value (numeric) – The value of the time.

  • relative (bool) – When True, the time is relative to some time variable. When False, the time is meant to be an absolute time.

is_absolute()[source]
is_relative()[source]
static now()[source]
class CBD.converters.latexify.functions.Eq(lhs, rhs, time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: object

Represents an equation in the form of \(y = f(x)\) .

Parameters
  • lhs (str) – The lefthandside of the equation, i.e., a variable name.

  • rhs (Fnc) – The righthandside of the equation, i.e., a function call.

  • time (Time) – A time constraint for the full equation.

at(time)[source]

Some equations have multiple solutions for a specific time. This function will obtain all corresponding equations for solving the current one at time time.

Parameters

time (Time) – The current time to solve the equation at.

Returns

A list of new equations, solved at a specific time.

get_dependencies()[source]
eq()[source]
latex()[source]
apply(other)[source]
simplify()[source]

Simplifies the rhs.

class CBD.converters.latexify.functions.Fnc(name, time=<CBD.converters.latexify.functions.Time object>, eq_time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: object

Representation of a righthandside of an equation. This is an superclass for all specific function types.

Parameters

name (str) – The name for the function.

Keyword Arguments
  • time (Time) – The current time for this function.

  • eq_time (Time) – The current equation time for this function.

simplify()[source]

Simplifies the function in-line, based on its arguments.

latex()[source]

Returns the LaTeX-representation of the function.

eq()[source]

Returns the textual equation-based representation of the function.

get_dependencies()[source]

Recursively obtains the dependencies of the current function.

at(time)[source]

Computes the function at a specific point in time.

Parameters

time (Time) – The time when to evaluate the function.

Returns

A list of new functions.

create(time, eq_time)[source]
apply(eq)[source]
contains(other)[source]

Checks if the function relies on another value.

Parameters

other (str) – The name that must be checked.

class CBD.converters.latexify.functions.MultiFnc(name, symbol, time=<CBD.converters.latexify.functions.Time object>, eq_time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: CBD.converters.latexify.functions.Fnc

Collection function for both the adder and the product blocks

create(time, eq_time)[source]
eq()[source]

Returns the textual equation-based representation of the function.

latex()[source]

Returns the LaTeX-representation of the function.

simplify()[source]

Simplifies the function in-line, based on its arguments.

class CBD.converters.latexify.functions.UnaryFnc(name, symbol, time=<CBD.converters.latexify.functions.Time object>, eq_time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: CBD.converters.latexify.functions.Fnc

Collection function for unary input functions

create(time, eq_time)[source]
eq()[source]

Returns the textual equation-based representation of the function.

latex()[source]

Returns the LaTeX-representation of the function.

simplify()[source]

Simplifies the function in-line, based on its arguments.

class CBD.converters.latexify.functions.BinaryFnc(name, symbol, time=<CBD.converters.latexify.functions.Time object>, eq_time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: CBD.converters.latexify.functions.Fnc

Collection function for binary input functions

create(time, eq_time)[source]
eq()[source]

Returns the textual equation-based representation of the function.

latex()[source]

Returns the LaTeX-representation of the function.

simplify()[source]

Simplifies the function in-line, based on its arguments.

class CBD.converters.latexify.functions.ConstantFnc(name, val, time=<CBD.converters.latexify.functions.Time object>, eq_time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: CBD.converters.latexify.functions.Fnc

Function that represents a constant value

create(time, eq_time)[source]
eq()[source]

Returns the textual equation-based representation of the function.

latex()[source]

Returns the LaTeX-representation of the function.

at(time)[source]

Computes the function at a specific point in time.

Parameters

time (Time) – The time when to evaluate the function.

Returns

A list of new functions.

class CBD.converters.latexify.functions.VarFnc(name, time=<CBD.converters.latexify.functions.Time object>, eq_time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: CBD.converters.latexify.functions.Fnc

Function that represents a variable name

eq()[source]

Returns the textual equation-based representation of the function.

latex()[source]

Returns the LaTeX-representation of the function.

at(time)[source]

Computes the function at a specific point in time.

Parameters

time (Time) – The time when to evaluate the function.

Returns

A list of new functions.

apply(eq)[source]
contains(other)[source]

Checks if the function relies on another value.

Parameters

other (str) – The name that must be checked.

class CBD.converters.latexify.functions.DelayFnc(name, time=<CBD.converters.latexify.functions.Time object>, eq_time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: CBD.converters.latexify.functions.Fnc

at(time)[source]

Computes the function at a specific point in time.

Parameters

time (Time) – The time when to evaluate the function.

Returns

A list of new functions.

class CBD.converters.latexify.functions.DerivatorFnc(name, time=<CBD.converters.latexify.functions.Time object>, eq_time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: CBD.converters.latexify.functions.Fnc

Function that represents a derivative

eq()[source]

Returns the textual equation-based representation of the function.

latex()[source]

Returns the LaTeX-representation of the function.

at(time)[source]

Computes the function at a specific point in time.

Parameters

time (Time) – The time when to evaluate the function.

Returns

A list of new functions.

class CBD.converters.latexify.functions.IntegratorFnc(name, time=<CBD.converters.latexify.functions.Time object>, eq_time=<CBD.converters.latexify.functions.Time object>)[source]

Bases: CBD.converters.latexify.functions.Fnc

Function that represents an integral

eq()[source]

Returns the textual equation-based representation of the function.

latex()[source]

Returns the LaTeX-representation of the function.

at(time)[source]

Computes the function at a specific point in time.

Parameters

time (Time) – The time when to evaluate the function.

Returns

A list of new functions.

CBD.converters.latexify.functions.BLOCK_MAP = {'AdderBlock': <function <lambda>>, 'AndBlock': <function <lambda>>, 'ConstantBlock': <function <lambda>>, 'DelayBlock': <function <lambda>>, 'DeltaTBlock': <function <lambda>>, 'DerivatorBlock': <function <lambda>>, 'EqualsBlock': <function <lambda>>, 'GenericBlock': <function <lambda>>, 'IntegratorBlock': <function <lambda>>, 'InverterBlock': <function <lambda>>, 'LessThanBlock': <function <lambda>>, 'LessThanOrEqualsBlock': <function <lambda>>, 'ModuloBlock': <function <lambda>>, 'NegatorBlock': <function <lambda>>, 'NotBlock': <function <lambda>>, 'OrBlock': <function <lambda>>, 'PowerBlock': <function <lambda>>, 'ProductBlock': <function <lambda>>, 'RootBlock': <function <lambda>>, 'TimeBlock': <function <lambda>>}

The mapping for all known blocks in CBDs. If you created your own block with its own representation, you need to set it in the type_formats of the CBD.converters.latexify.CBD2Latex class.