|
Build and return a function to evaluate all parameter expressions in
the proper order.
- Inputs:
- pars is a list of parameters
context is a dictionary of additional symbols for the expressions
- Output:
- updater function
- Raises:
- AssertionError - model, parameter or function is missing
SyntaxError - improper expression syntax
ValueError - expressions have circular dependencies
This function is not terribly sophisticated, and it would be easy to
trick. However it handles the common cases cleanly and generates
reasonable messages for the common errors.
This code has not been fully audited for security. While we have
removed the builtins and the ability to import modules, there may
be other vectors for users to perform more than simple function
evaluations. Unauthenticated users should not be running this code.
Parameter names are assumed to contain only _.a-zA-Z0-9#[]
The list of parameters is probably something like:
parset.setprefix()
pars = parset.flatten()
Note that math uses acos while numpy uses arccos. To avoid confusion
we allow both.
Should try running the function to identify syntax errors before
running it in a fit.
Use help(fn) to see the code generated for the returned function fn.
dis.dis(fn) will show the corresponding python vm instructions.
|