Skip to content

Commit 0e55236

Browse files
author
fabioferreira
committed
Actions CI
1 parent ea1fe27 commit 0e55236

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

cde/utils/integration.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import numpy as np
66
import numbers
7-
from numpy import trapz as np_trapz
87

98
try:
109
from scipy import integrate
@@ -31,8 +30,10 @@ def numeric_integation(func, n_samples=10 ** 5, bound_lower=-10**3, bound_upper=
3130
values = func(y_samples)
3231
trapz = getattr(integrate, "trapz", None)
3332
if trapz is None:
34-
trapz = np_trapz
35-
integral = trapz(values, y_samples)
33+
dx = np.diff(y_samples)
34+
integral = np.sum((values[:-1] + values[1:]) * dx / 2)
35+
else:
36+
integral = trapz(values, y_samples)
3637
return integral
3738

3839

0 commit comments

Comments
 (0)