openmmtools.utils.sanitize_expression

openmmtools.utils.sanitize_expression(expression, variables)[source]

Sanitize variables with an illegal Python name.

Transform variable names in the string expression that are illegal in Python so that the expression can be evaluated in pure Python. Currently this just handle variables called with the reserved word ‘lambda’.

Parameters:
expression : str

The mathematical expression as a string.

variables : dict of str: float

The variables in the expression.

Returns:
sanitized_expression : str

The same mathematical expression that can be executed in Python.

sanitized_variables : dict of str: float

The updated variable names with their values.