yobx.xexpressions#

Main functions#

yobx.xexpressions.evaluate_expression(expression: str, context: Dict[str, int]) int[source]#

Evaluates an expression handling dimensions.

<<<

from yobx.xexpressions.evaluate_expressions import (
    evaluate_expression,
)

print(evaluate_expression("x+y", dict(x=3, y=5)))

>>>

    8
yobx.xexpressions.rename_expression(expr: str, mapping: Dict[str, str]) str[source]#

Renames variables in a Python expression using AST.

Parameters:
  • expr – Python expression as string

  • mapping – Mapping from old names to new names

Returns:

transformed expression

yobx.xexpressions.simplify_expression(expr: str | int) str | int[source]#

Simplifies an expression.