I am implementing the code in python which has the variables stored in numpy vectors. I need to perform simple operation: something like (vec1+vec2^2)/vec3. Each element of each
Pass the dictionary to python eval function:
>>> var = {'a':np.array([1,2,2]),'b':np.array([2,1,3]),'c':np.array([3])} >>> formula = '2*a*(b/c)**2' >>> eval(formula, var) array([ 0.8889, 0.4444, 4. ])