API Reference

Formulate’s public interface is small: two functions that parse, and one class whose methods and properties do everything else.

>>> import formulate
>>> expression = formulate.from_root("TMath::Sqrt(x**2 + y**2) > 10")
>>> expression.to_numexpr()
'(sqrt(((x ** 2) + (y ** 2))) > 10)'
>>> list(expression.variables)
['x', 'y']

formulate covers the parsing functions, and Abstract Syntax Tree (AST) the expression objects they return. The remaining pages document the internals: the lookup tables that decide how each name is spelled in each language, the parse-tree conversion, and the exceptions.