Skip to content
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

Remove AccuracyWarning and quadrature #266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions flavio/math/integrate.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
import scipy
import numpy as np
import warnings
try:
from scipy.integrate import AccuracyWarning # scipy >= 1.5.0
except ImportError:
from scipy.integrate.quadrature import AccuracyWarning # scipy <= 1.4.1

def nintegrate_quadrature(f, a, b, epsrel=0.005, **kwargs):
with warnings.catch_warnings():
# ignore AccuracyWarning that is issued when an integral is zero
warnings.filterwarnings("ignore", category=AccuracyWarning)
return scipy.integrate.quadrature(f, a, b, rtol=epsrel, tol=0, vec_func=False, **kwargs)[0]

def nintegrate(f, a, b, epsrel=0.005, **kwargs):
with warnings.catch_warnings():
# ignore AccuracyWarning that is issued when an integral is zero
warnings.filterwarnings("ignore", category=AccuracyWarning)
return scipy.integrate.quad(f, a, b, epsabs=0, epsrel=epsrel, **kwargs)[0]
return scipy.integrate.quad(f, a, b, epsabs=0, epsrel=epsrel, **kwargs)[0]

def nintegrate_fast(f, a, b, N=5, **kwargs):
x = np.linspace(a,b,N)
Expand Down
Loading