thaler-lab / Wasserstein

Python/C++ library for computing Wasserstein distances efficiently.
https://thaler-lab.github.io/Wasserstein
Other
21 stars 8 forks source link

SciPy v1.14.0 breaks POT's use of scipy.optimize.scalar_search_armijo #36

Closed matthewfeickert closed 3 weeks ago

matthewfeickert commented 3 weeks ago

With the release of scipy v1.14.0 there's an issue with with POT's use of

from scipy.optimize import scalar_search_armijo
==================================== ERRORS ====================================
______________________ ERROR collecting tests/test_emd.py ______________________
ImportError while importing test module '/home/runner/work/Wasserstein/Wasserstein/tests/test_emd.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/ot/optim.py:21: in <module>
    from scipy.optimize import scalar_search_armijo
E   ImportError: cannot import name 'scalar_search_armijo' from 'scipy.optimize' (/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/scipy/optimize/__init__.py)

During handling of the above exception, another exception occurred:
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_emd.py:2: in <module>
    import ot
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/ot/__init__.py:23: in <module>
    from . import optim
/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/ot/optim.py:23: in <module>
    from scipy.optimize.linesearch import scalar_search_armijo
E   ImportError: cannot import name 'scalar_search_armijo' from 'scipy.optimize.linesearch' (/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/scipy/optimize/linesearch.py)

This needs to get fixed upstream, so for the time being we can ignore scipy v1.14.0.

matthewfeickert commented 3 weeks ago

Yeah, this is just POT using old APIs given this was changed in https://github.com/scipy/scipy/pull/14966 for scipy v1.8.0.

-from scipy.optimize import scalar_search_armijo
+from scipy.optimize._linesearch import scalar_search_armijo
-from scipy.optimize.linesearch import scalar_search_armijo
+from scipy.optimize._linesearch import scalar_search_armijo
matthewfeickert commented 3 weeks ago

This was fixed already today in https://github.com/PythonOT/POT/pull/642, so when the next POT release comes out we can revert both PR https://github.com/thaler-lab/Wasserstein/pull/23 and PR https://github.com/thaler-lab/Wasserstein/pull/38.