Skip to content

Commit

Permalink
Remove AccuracyWarning and quadrature (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
alekssmolkovic authored Feb 12, 2025
1 parent 570620f commit 70a8a44
Showing 1 changed file with 1 addition and 15 deletions.
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

0 comments on commit 70a8a44

Please sign in to comment.