Open BALOGHBence opened 1 month ago
There is another evaluation style that occurs eg. when using the lambdify
method from SymPy.
from sympy.parsing.sympy_parser import parse_expr
from sympy import lambdify, symbols
import numpy as np
str_expr = "(x-300)**2 + (y-400)**2"
variables = symbols("x y")
expr = parse_expr(str_expr, evaluate=False).simplify()
f0 = lambdify([variables], expr, "numpy")
f0([300, 400])
x = np.array([[300, 400],[300, 400],[300, 400]])
f0(x.T)
This is similar to BATCH, but with the input transposed.
Also, depending on how the lambdify
function is called
f0 = lambdify(variables, expr, "numpy")
f0(300, 400)
x = np.array([[300, 400],[300, 400],[300, 400]])
f0(x[:,0], x[:,1])
This results in the UNIVERSAL style.
When a Function
instance is created from a string or a SymPy expression, there should be an option to specify the evaluation style.
When this is done, the BGA class has to be updated to account for different evaluation styles. Currently it only utilizes BATCH evaluation in the case of symbolic functions.
When creating an instance of
Function
, the user should be able to indicate the evaluation style. The main evaluation styles are the following:An enumeration should be created for these, eg
Mazbe a fourth type could be SYMPY dedicated for symbolic functions generated from SymPy expressions using
sympy.lambdify
.