biogeme.expressions.visitor module

Function to visit the tree of Expressions

Michel Bierlaire 15.04.2025 12:55

class biogeme.expressions.visitor.ExpressionVisitor[source]

Bases: object

Walks the tree and executes side-effect handlers with no return values.

register(expr_type)[source]

Register a handler function for a specific expression type. The handler must return None and perform side effects only.

Parameters:

expr_type (type[Expression]) – the type of Expression for which the handler should be used

Returns:

decorator that registers the handler

visit(expr, context=None)[source]

Traverse the expression tree and apply handlers for side effects.

Parameters:
  • expr (Expression) – the root expression to visit

  • context (Any) – optional context object passed to handlers

Return type:

None