Skip to content

Commit 88ae68b

Browse files
authored
Replace scipy's romberg with quad. (#412)
* Replace scipy's romberg with quad. Romberg will be removed from scipy in v1.15.0 * Fix keyword argument name. * Don't need error. * Update doctests. * Updat change log.
1 parent 813fe61 commit 88ae68b

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

CHANGES.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ sbpy.names
1212
rates in the LSST survey era [#406]
1313

1414

15+
Other Changes and Additions
16+
---------------------------
17+
18+
sbpy.activity.gas
19+
^^^^^^^^^^^^^^^^^
20+
- Replaced calls to the deprecated function `scipy.integrate.romberg` with
21+
`scipy.integrate.quad`. [#412]
22+
23+
1524
0.5.0 (2024-08-28)
1625
==================
1726

docs/sbpy/activity/gas.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ number of molecules in an aperture. Parent and daughter data is provided via
148148
>>> Q = 1e28 / u.s # water production rate
149149
>>> coma = gas.VectorialModel(Q, water, hydroxyl)
150150
>>> print(coma.column_density(10 * u.km)) # doctest: +FLOAT_CMP
151-
2.8976722840952486e+17 1 / m2
151+
2.8974972922255264e+17 1 / m2
152152
>>> print(coma.total_number(1000 * u.km)) # doctest: +FLOAT_CMP
153-
6.995158827300034e+29
153+
6.995084479934798e+29
154154

155155
Production Rate calculations
156156
----------------------------

sbpy/activity/gas/core.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
try:
2525
import scipy
2626
from scipy import special
27-
from scipy.integrate import quad, dblquad, romberg
27+
from scipy.integrate import quad, dblquad
2828
from scipy.interpolate import CubicSpline, PPoly
2929
except ImportError:
3030
scipy = None
@@ -1635,8 +1635,8 @@ def _column_density_at_rho(self, rho: np.float64) -> np.float64:
16351635
def column_density_integrand(z):
16361636
return self._volume_density(np.sqrt(z**2 + rhosq))
16371637

1638-
c_dens = 2 * romberg(column_density_integrand, 0,
1639-
z_max, rtol=0.0001, divmax=50)
1638+
c_dens = 2 * quad(column_density_integrand, 0,
1639+
z_max, epsrel=0.0001)[0]
16401640

16411641
# result is in 1/m^2
16421642
return c_dens
@@ -1745,14 +1745,13 @@ def _calc_num_fragments_grid(self) -> np.float64:
17451745
def vol_integrand(r, r_func):
17461746
return r_func(r) * r**2
17471747

1748-
r_int = romberg(
1748+
r_int = quad(
17491749
vol_integrand,
17501750
0,
17511751
max_r,
17521752
args=(self.vmr.volume_density_interpolation,),
1753-
rtol=0.0001,
1754-
divmax=20,
1755-
)
1753+
epsrel=0.0001,
1754+
)[0]
17561755
return 4 * np.pi * r_int
17571756

17581757
def _column_density(self, rho) -> np.float64:

0 commit comments

Comments
 (0)