-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: scipy.integrate: vectorize quad
#3325
Comments
For |
@Kai-Striega Here's another one that seems really simple - just vectorize for array |
@mdhaber I'm not really sure how to do this, could you expand on it a little more? |
By "grids", it sounds like the user is referring to intervals of integration, as defined by import numpy as np
import scipy.integrate
def new_quad(f, a, b):
def g(a, b):
return scipy.integrate.quad(f, a, b)
h = np.vectorize(g)
res = h(a, b)
# np.asarray ensures that we don't return 0d arrays
# tuple is in case we care about returning a tuple
return tuple(np.asarray(res))
def f(x):
return x
a = 0
b = [1, 2, 3]
new_quad(f, a, b) # (array([0.5, 2. , 4.5]), array([5.55111512e-15, 2.22044605e-14, 4.99600361e-14])) |
I missed that |
quad
The
scipy.interpolate
functions can be evaluated on grids of points.In contrast, the
scipy.integrate
functions currently can only be evaluated for a single bin.Would it be possible to change the
scipy.integrate
functions to accepts grids of bins as input and return grids of bins as output?This is commonly needed when discretising models onto a grid (see e.g. here or here).
Assuming this is desired functionality for
scipy.integrate
, is it possible to extend the current functions in a backwards-compatible way?The text was updated successfully, but these errors were encountered: