Equation
- class gpype.backend.transform.equation.Equation[source]
Bases:
IONodeMathematical expression evaluation node for data transformation.
Applies custom mathematical expressions to input data using SymPy. Automatically creates input ports from expression variables and compiles to optimized NumPy functions. Handles ‘in’ keyword via internal aliasing.
The output records no unit unless
unitnames one: an expression can square, divide or mix its inputs, and nothing here can tell which.- INPUT_PORTS_FROM = 'expression'
The input ports are the free variables of the expression, so there is no port list to declare:
a+bhas two inputs andeeg1*2 - eeg2has two differently named ones. Naming the parameter that decides them is the whole truth. Publishing one expression’s answer as the class’s port set – which is what building an instance to find out did – is correct for exactly one expression out of infinitely many.
- class Configuration[source]
Bases:
ConfigurationConfiguration class for Equation parameters.
- __init__(expression, unit=None, **kwargs)[source]
Initialize Equation node with mathematical expression.
Parses expression using SymPy, extracts variables to create input ports, and compiles to optimized NumPy function.
- Parameters:
expression (
str) – Mathematical expression string. Must be valid SymPy expression. Variables become input port names. ‘in’ keyword handled via internal aliasing.unit (
Optional[str]) – Physical unit of every output channel, e.g."uV". None records no unit.**kwargs – Additional configuration parameters for IONode.
- Raises:
ValueError – If expression is None or empty, or unit is not a non-empty string.
SymPy parsing errors – If expression cannot be parsed.
- setup(data, port_context_in)[source]
Setup Equation node and determine output dimensionality.
Creates pseudo input data based on input context, runs the computation to determine output shape, and builds output context with correct channel count. This handles dimensionality changes from matrix operations.
- Parameters:
- Return type:
- Returns:
Output port context with validated configuration and computed channel count based on expression output shape.