modelspec.utils.evaluate
- modelspec.utils.evaluate(expr: int | float | str | list | dict, parameters: dict = {}, rng: Random | None = None, array_format: str = 'numpy', verbose: bool = False, cast_to_int: bool = False)[source]
Evaluate a general string like expression (e.g. “2 * weight”) using a dict of parameters (e.g. {‘weight’:10}). Returns floats, ints, etc. if that’s what’s given in expr
- Parameters:
expr – The expression to convert
parameters – A dict of the parameters which can be substituted in to the expression
rng – The random number generator to use
array_format – numpy or tensorflow
verbose – Print the calculations
cast_to_int – return an int for float/string values if castable