math_eval

sisl.utils.math_eval(expr)[source]

Evaluate a mathematical expression using a safe evaluation method

Parameters:
expr : str

the string to be evaluated using math

Examples

>>> math_eval('2^6')
4
>>> math_eval('2**6')
64
>>> math_eval('1 + 2*3**(4^5) / (6 + -7)')
-5.0