check_expression

check_expression(expr)[source]

Check if the given expression is a valid MAD-X expression that is safe to pass to cpymad.madx.Madx.eval().

Parameters:

expr (str)

Returns:

True

Raises:

ValueError – if the expression is ill-formed

Note that this function only recognizes a sane subset of the expressions accepted by MAD-X and rejects valid but strange ones such as a number formatting ‘.’ representing zero.