Welcome to Formulate’s documentation!
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.
Quickstart
Guide
- Supported Expressions
- Performance Considerations
- Common Issues
%does not mean the same thing in ROOT and numexpr- Constructs with no equivalent raise rather than approximating
^is exponentiation in ROOT and XOR in numexpr- Logical operators bind differently in the two languages
- Named constants do not survive a round trip through numexpr
- Dotted branch names are hex-encoded for numexpr
Contributing
Project