-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The issue in #117 points out an failure to parse an expression as the parser tries to sum an Integer() with a FunctionClass when the expresion is 1+beta. This was traced in #118 to be because beta exists in the sympy namespace as sp.beta and the current expression parser (parse_expr) imports this whole namespace unless restricted by the global_dict argument passed form parse_expression. The rough fix in #118 restricts the functions imported from the sympy namespace. This is too restrictive, since users may want to use one of these functions (e.g. sp.min) in their expressions. One solution is enforcing a heirarchy where local variable names are prioritised over using the sympy variables with the same name, and another is to restrict users from using variable names that are in the sympy namespace.
A few examples that fail parsing for the above reason:
config = {
"type": "generic_function",
"name": "myfunc",
"expression": "min + 1"
}
func = GenericFunction(**config)
config = {
"type": "generic_function",
"name": "myfunc",
"expression": "beta + 1"
}
func = GenericFunction(**config)
config = {
"type": "generic_function",
"name": "myfunc",
"expression": "gamma + 1"
}
func = GenericFunction(**config)