CamDavidsonPilon / lifelines

Survival analysis in Python
lifelines.readthedocs.org
MIT License
2.32k stars 551 forks source link

Changing `trapz` to `trapezoid` for scipy 1.14.0. #1620

Closed asarigun closed 5 days ago

asarigun commented 6 days ago

Changing trapz to trapezoid for scipy 1.14.0.

Solution for Issue #1618

CamDavidsonPilon commented 6 days ago

:+1: look good - was scipy.trapezoid available in earlier versions too (just thinking how far back we need to pin scipy)

fkiraly commented 6 days ago

Exists since 1.7.0, I think.

One option to avoid a lower bound bump is a pattern like this:

trapezoid_available = check_scipy_ge_17()

if trapezoid_available:
    from scipy.integrate import trapezoid
else:
    from scipy.integrate import trapz as trapezoid
fkiraly commented 6 days ago

question, what is rough ETA on this being in a release? Depending on lifelines in skpro, so I'm asking whether we need to add a scipy<1.14 modifier to lifelines estimators, or whether the release will fix the issue in timely manner.

pskip-unlearn commented 5 days ago

My CI pipeline is broken due to this issue as well, wondering if I need to downgrade scipy?

CamDavidsonPilon commented 5 days ago

I can get this in today. I just want to review the rest of scipy 1.14 first.

fkiraly commented 5 days ago

My CI pipeline is broken due to this issue as well, wondering if I need to downgrade scipy?

for me, pandas has been behaving like this for a while (mostly around index freq), I really hope it's not the start of a similar saga with scipy...

fkiraly commented 5 days ago

for the conditional checking, code snippet that uses packaging in case it's useful:

def check_scipy_ge_17():
    import importlib.metadaa
    import importlib.util

    from packaging.version import InvalidVersion, Version

    package_name = "scipy"
    required_version = "1.7.0"

    package_spec = importlib.util.find_spec(package_name)
    if package_spec is not None:
        installed_version = importlib.metadata.version(package_name)
        try:
            return Version(installed_version) >= Version(required_version)
        except InvalidVersion:
            pass
    return False
CamDavidsonPilon commented 5 days ago

for me, pandas has been behaving like this for a while (mostly around index freq), I really hope it's not the start of a similar saga with scipy...

that is, does lifelines need updates to pandas code too?