mrpt.expr

mrpt-expr: Runtime Compiled Expressions

Package Contents

class mrpt.expr.CRuntimeCompiledExpression

C++ API: class mrpt::expr::CRuntimeCompiledExpression

A wrapper of exprtk runtime expression compiler: it takes a string representing an expression (from a simple mathematical formula to a complete program), compiles it and evaluates its result as many times as required.

compile(expression: str, variables: dict[str, float] = {}) → None

Compiles a string expression with optional variable and constant maps.

eval() → float

Evaluates the compiled expression and returns the result.

get_original_expression() → str

Returns the original formula string.

is_compiled() → bool

Returns true if the expression has been successfully compiled.

register_function(name: str, func: Callable) → None

Registers a Python function taking 0 to 3 float arguments, for use in expressions compiled afterwards. The number of arguments is taken from its signature.