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:
expressionstr

The mathematical expression as a string.

variablesdict of str: float

The variables in the expression.

Returns:
sanitized_expressionstr

The same mathematical expression that can be executed in Python.

sanitized_variablesdict of str: float

The updated variable names with their values.