clwainwright / CosmoTransitions

A package for analyzing finite or zero-temperature cosmological phase transitions driven by single or multiple scalar fields.
MIT License
25 stars 19 forks source link

Fix SciPy deprecation warnings #35

Closed og113 closed 1 month ago

og113 commented 3 months ago

In SciPy v1.6 the names of two functions used in CosmoTransitions were renamed: scipy.integrate.simps was renamed scipy.integrate.simpson and scipy.integrate.cumtrapz was renamed scipy.integrate.cumulative_trapezoid. Until now, the old names of these two functions have been kept around for backwards compatability.

In SciPy v1.14 the old names will be removed; see here and here. Also in SciPy v1.14, the simpson function must have the keyword argument x=... passed with the keyword explicit. In v1.12 there is a deprecation warning for this.

To avoid CosmoTransitions breaking when SciPy v1.14 comes around, in this PR two lines of source code have been changed. Note however, this PR would break CosmoTransitions for SciPy versions older than 1.6.0 (and hence NumPy versions older than 1.16.5 and Python versions older than 3.7, see here). So, the version requirements in the setup.py file have been changed in this PR to reflect this. As a consequence, this PR also bumps the minor version number.

clwainwright commented 3 months ago

Thanks for doing this! I'm a little wary of killing support for Python 2 just because of a name change in scipy though. Any reason not to do

try:
    from scipy.integrate import cumulative_trapezoid, simpson
except ImportError:
    # scipy.version < 1.6
    from scipy.integrate import cumtrapz as cumulative_trapezoid
    from scipy.integrate import simps as simpson    

instead?

og113 commented 3 months ago

Yeah, your suggestion seems a good one to me.

og113 commented 2 months ago

I've updated the PR with your suggestion @clwainwright , and undone the changes to setup.py.

og113 commented 1 month ago

Hey @clwainwright, I just wanted to check in and ask if you had any further suggestions re this PR?

clwainwright commented 1 month ago

Sorry for taking so long to merge this in! It's been kind of a crazy few weeks.

Yes, this looks good. I'll get it out on PyPI shortly.