Welcome to Formulate’s documentation!

https://scikit-hep.org/assets/images/Scikit--HEP-Project-blue.svg

Formulate is a Python library for easy conversions between different styles of expressions. It converts in either direction between ROOT (TTreeFormula) and numexpr syntax, and can also render any parsed expression as plain Python using NumPy functions.

>>> import formulate
>>> formulate.from_root("TMath::Sqrt(px**2 + py**2) > 10").to_numexpr()
'(sqrt(((px ** 2) + (py ** 2))) > 10)'

Install it with pip install formulate or conda install -c conda-forge formulate, then start with the Introduction.

Indices and tables