Skip to main content

FormulaEvaluator

Evaluate Excel formulas over a DependencyGraph.

Usage

Source

FormulaEvaluator()

Holds a shared reference to graph (no deep copy). Cell-value and parsed-AST caches are per-evaluator.

Formula-shape helpers (_shape_fns) are compiled in __post_init__ from graph.formula_shapes at construction. That compile is a snapshot: reassigning or rewarming graph.formula_shapes later does not refresh _shape_fns. Construct a new FormulaEvaluator after rewarming if you want compiled shape helpers. Missing shapes fall back to Node.formula_ast; correctness does not require the overlay to be warm.

With auto_detect_changes and eager_invalidation (the defaults), evaluate polls leaf values only after DependencyGraph.set_node_value since the previous scan (or construction). Repeated evaluate(cell) calls against an unchanged leaf set do not walk unused leaves.

Parameter Attributes

graph: DependencyGraph
auto_detect_changes: bool = True
eager_invalidation: bool = True
on_cell_evaluated: Callable[[str, FormulaValue], None] | None = None
iterate_enabled: bool = False
iterate_count: int = 100
iterate_delta: float = 0.001
blank_ranges: tuple[str, …] | None = None
ast_cache_maxsize: int = DEFAULT_AST_CACHE_MAXSIZE