expression

parse.expression

Classes

Name Description
Mean Mean over indexed expression: Mean(f(x[i]), (i, 0, N-1)).

Mean

parse.expression.Mean()

Mean over indexed expression: Mean(f(x[i]), (i, 0, N-1)).

Mathematical notation for averaging over a dimension. Translates to jnp.mean(jax.vmap(…)) or jnp.mean(…) depending on the inner function.

Example

Mean(1 - correlation(x[i], y[i]), (i, 0, N-1)) -> jnp.mean(jax.vmap(lambda x, y: 1 - correlation(x, y))(x, y))

Functions

Name Description
parse_eq Parse the right-hand side of an equation or a raw expression string.

parse_eq

parse.expression.parse_eq(equation, parameters=None, **kwargs)

Parse the right-hand side of an equation or a raw expression string.

Extends parsing with the ability to pass parameters, functions, symbols, and arbitrary SymPy objects commonly used in nonlinear systems dynamics.

Parameters

equation : Equation | str An Equation from tvbo’s datamodel or a raw expression string. If an Equation with latex=True is provided, LaTeX parsing is used. parameters : Iterable[str] | Mapping[str, object] | None Names or a mapping of parameter names to SymPy objects or numbers. If an iterable of strings is provided, they are created as SymPy Symbols and injected into the parsing context. If a mapping is provided, the values are injected as-is (Symbols, Functions, Expressions, numbers, etc.).

Keyword-only enhancements (optional)

local_dict : dict Additional local names to inject into the parser (merged on top of defaults). functions : Iterable[str] | Mapping[str, object] Names or mapping for functions. String names are created as undefined SymPy functions, e.g., Function(‘f’). Mapping values are used as-is. symbols : Iterable[str] | Mapping[str, Symbol] Extra symbol names or mapping for state variables, etc. String names are created as SymPy Symbols. Mapping values are used as-is. objects : Mapping[str, object] Arbitrary additional objects (e.g., Heaviside, MatrixSymbol, IndexedBase, Derivative alias, etc.) to inject into the local namespace. extra_transformations : Iterable[callable] Extra SymPy parser transformations to augment the defaults. transformations : Iterable[callable] Full control over the transformation pipeline (overrides defaults if provided).

Returns

sympy.Expr Parsed SymPy expression.