Symbolic constraints¶
Symbols¶
symbol(name, unit=..., quantity_kind=...) creates a typed symbolic variable. Expressions built from symbols, quantities, and units form trees you can inspect and evaluate.
Equations and inequalities¶
==between expressions yields anEquation.Comparisons yield strict or non-strict inequality nodes.
Combine constraints with
&(conjunction),|(disjunction), and~(negation).
Constraints are not plain Python bool; they evaluate only when you call .evaluate(...).
free_symbols¶
Expressions and constraints expose free_symbols for dependency analysis—useful when wiring executable models or solvers.
Evaluation¶
Pass a mapping from symbols to Quantity values. Optional tolerance arguments control numeric comparison for constraints.
Numeric compilation¶
unitflow.expr.compile.compile_numeric and compile_residual lower expression trees to plain Python callables over floats, with units baked in at compile time—suited for tight loops inside optimizers or root finders.
API: unitflow.expr.