Skip to content

Commit

Permalink
DOC: integrate.quad_vec: Add example when using workers (scipy#20915
Browse files Browse the repository at this point in the history
)


Co-authored-by: Jake Bowhay <[email protected]>
  • Loading branch information
m-maggi and j-bowhay authored Jun 19, 2024
1 parent 7f0b0a1 commit 1d59ab9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scipy/integrate/_quad_vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,23 @@ def quad_vec(f, a, b, epsabs=1e-200, epsrel=1e-8, norm='2', cache_size=100e6,
>>> plt.ylabel(r"$\int_{0}^{2} x^\alpha dx$")
>>> plt.show()
When using the argument `workers`, one should ensure
that the main module is import-safe, for instance
by rewriting the example above as:
.. code-block:: python
from scipy.integrate import quad_vec
import numpy as np
import matplotlib.pyplot as plt
alpha = np.linspace(0.0, 2.0, num=30)
x0, x1 = 0, 2
def f(x):
return x**alpha
if __name__ == "__main__":
y, err = quad_vec(f, x0, x1, workers=2)
"""
a = float(a)
b = float(b)
Expand Down

0 comments on commit 1d59ab9

Please sign in to comment.