Hi all,
The function sparse.linalg.use_solver sets a global variable useUmfpack that determines whether sparse.linalg.spsolve and sparse.linalg.factorized will use the external library scikit-umfpack as a backend. I propose to deprecate the use_solver function in favor of an explicit use_umfpack keyword argument to spsolve and factorized.
I have already merged the scikit-umfpack functionality into scikit-sparse v0.5.0, and opened PR #24101 to update the scipy interface.
The PR obviates the outdated style of the global variable and implements the kwarg in spsolve and factorized.
Let me know if we should leave a shell of use_solver with a DeprecationWarning, or just remove it entirely (current state of the PR).
-Bernie
Thanks @broesler for working on this. I agree that use_solver is an API we no longer want. We should use a DeprecationWarning here, because otherwise the next release would be a hard break for anyone using that function.
Currently, in one of our projects, we employ use_solver() only to ensure that the built-in SuperLU is always used, avoiding that SciPy automatically and silently switches to scikit-umfpack if it is present. See: PyFVTool/src/pyfvtool/pdesolver.py at main · FiniteVolumeTransportPhenomena/PyFVTool · GitHub In the past, we have encountered some strange errors with the default automatic switching after installing scikit-umfpack.
I agree that use_solver() should take the DeprecationWarning road. I think that, from that point on, it should also change its default to use_solver(useUmfpack=False), so that it can easily be removed from code (our code, at least) without side-effects. Changing this default is not expected to be a breaking change.
The changes proposed by @broesler will enable to use external solvers more flexibly and more transparently. Thanks, also for scikit-sparse, which helps structure the diverse sparse solver infrastructure in the scientific Python ecosystem.