Evaluates the tiny arithmetic dialect Monty's configs use.
Monty has an OmegaConf resolver, np.list_eval, that runs Python's eval over
each item of a list, and its configs rely on it for things like
${np.list_eval:[np.pi / 8, np.pi * 2, np.pi * 2]}. Running Python is not an
option, so this module parses exactly the language those entries use:
- number literals (
8,0.7,1e-3) np.pi+,-,*,/with the usual precedence, and parentheses- a list of expressions in brackets
Anything outside that grammar is an error, which is the point: an evaluator that quietly accepts more would be an evaluator we cannot reason about.
Summary
Functions
Evaluates a bare expression.