Repository: qutip/qutip

Issue:
Update QuTiP to used scipy.sparse instead of scipy.sparse.X.
### Bug Description

SciPy 1.8 deprecated importing functions from many submodules of scipy.sparse. For example, `scipy.sparse.sputils`. QuTiP fastsparse implementation accessing many of these functions because it extends scipy's sparse matrix support. It would be good to avoid as many of these deprecated imports as we can.

Note that SciPy 1.8 is the first SciPy to support Python 3.10.

### Code to Reproduce the Bug

```shell
python -X dev -c "import qutip"
```


### Code Output

```shell
<frozen importlib._bootstrap>:914: ImportWarning: PyxImporter.find_spec() not found; falling back to find_module()
/home/simon/repos/github/qutip/qutip/fastsparse.py:5: DeprecationWarning: Please use `upcast` from the `scipy.sparse` namespace, the `scipy.sparse.sputils` namespace is deprecated.
  from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
/home/simon/repos/github/qutip/qutip/fastsparse.py:5: DeprecationWarning: Please use `upcast_char` from the `scipy.sparse` namespace, the `scipy.sparse.sputils` namespace is deprecated.
  from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
/home/simon/repos/github/qutip/qutip/fastsparse.py:5: DeprecationWarning: Please use `to_native` from the `scipy.sparse` namespace, the `scipy.sparse.sputils` namespace is deprecated.
  from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
/home/simon/repos/github/qutip/qutip/fastsparse.py:5: DeprecationWarning: Please use `isdense` from the `scipy.sparse` namespace, the `scipy.sparse.sputils` namespace is deprecated.
  from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
/home/simon/repos/github/qutip/qutip/fastsparse.py:5: DeprecationWarning: Please use `isshape` from the `scipy.sparse` namespace, the `scipy.sparse.sputils` namespace is deprecated.
  from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
/home/simon/repos/github/qutip/qutip/fastsparse.py:5: DeprecationWarning: Please use `getdtype` from the `scipy.sparse` namespace, the `scipy.sparse.sputils` namespace is deprecated.
  from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
/home/simon/repos/github/qutip/qutip/fastsparse.py:5: DeprecationWarning: Please use `isscalarlike` from the `scipy.sparse` namespace, the `scipy.sparse.sputils` namespace is deprecated.
  from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
/home/simon/repos/github/qutip/qutip/fastsparse.py:5: DeprecationWarning: Please use `get_index_dtype` from the `scipy.sparse` namespace, the `scipy.sparse.sputils` namespace is deprecated.
  from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
/home/simon/repos/github/qutip/qutip/fastsparse.py:7: DeprecationWarning: Please use `spmatrix` from the `scipy.sparse` namespace, the `scipy.sparse.base` namespace is deprecated.
  from scipy.sparse.base import spmatrix, isspmatrix, SparseEfficiencyWarning
/home/simon/repos/github/qutip/qutip/fastsparse.py:7: DeprecationWarning: Please use `isspmatrix` from the `scipy.sparse` namespace, the `scipy.sparse.base` namespace is deprecated.
  from scipy.sparse.base import spmatrix, isspmatrix, SparseEfficiencyWarning
/home/simon/repos/github/qutip/qutip/fastsparse.py:7: DeprecationWarning: Please use `SparseEfficiencyWarning` from the `scipy.sparse` namespace, the `scipy.sparse.base` namespace is deprecated.
  from scipy.sparse.base import spmatrix, isspmatrix, SparseEfficiencyWarning
<frozen importlib._bootstrap>:914: ImportWarning: PyxImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: PyxImporter.find_spec() not found; falling back to find_module()
/home/simon/miniconda3/envs/qutip/lib/python3.10/site-packages/cvxpy/interface/scipy_wrapper.py:17: DeprecationWarning: Please use `spmatrix` from the `scipy.sparse` namespace, the `scipy.sparse.base` namespace is deprecated.
  from scipy.sparse.base import spmatrix
<frozen importlib._bootstrap>:914: ImportWarning: PyxImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: PyxImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: PyxImporter.find_spec() not found; falling back to find_module()
<frozen importlib._bootstrap>:914: ImportWarning: PyxImporter.find_spec() not found; falling back to find_module()
```


### Expected Behaviour

DeprecationWarnings should not be raised.

### Your Environment

```shell
QuTiP Version:      4.7.0.dev0+eaf053d
Numpy Version:      1.22.2
Scipy Version:      1.8.0
Cython Version:     0.29.26
Matplotlib Version: 3.5.1
Python Version:     3.10.2
Number of CPUs:     8
BLAS Info:          Generic
OPENMP Installed:   False
INTEL MKL Ext:      False
Platform Info:      Linux (x86_64
```


### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/qutip/fastsparse.py b/qutip/fastsparse.py
--- a/qutip/fastsparse.py
+++ b/qutip/fastsparse.py
@@ -1,11 +1,26 @@
-import numpy as np
-import operator
-from scipy.sparse import (_sparsetools, isspmatrix, isspmatrix_csr,
-                          csr_matrix, coo_matrix, csc_matrix, dia_matrix)
-from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
-                      getdtype, isscalarlike, get_index_dtype)
-from scipy.sparse.base import spmatrix, isspmatrix, SparseEfficiencyWarning
 from warnings import warn
+import operator
+
+import numpy as np
+from scipy.sparse import (
+    csr_matrix, dia_matrix, isspmatrix, SparseEfficiencyWarning,
+)
+
+# fast_csr_matrix extends the internals of csr_matrix, and we need to
+# import parts of the internals of scipy.sparse to do that:
+import scipy.sparse
+import scipy.sparse._sparsetools as _sparsetools
+if hasattr(scipy.sparse, "_sputils"):
+    # SciPy 1.8.0 deprecated the public scipy.sparse.sputils interface and
+    # moved it to _sputils
+    from scipy.sparse._sputils import (
+        isdense, isscalarlike, upcast, get_index_dtype,
+    )
+else:
+    from scipy.sparse.sputils import (
+        isdense, isscalarlike, upcast, get_index_dtype,
+    )
+
 
 class fast_csr_matrix(csr_matrix):
     """


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -69,13 +69,13 @@ jobs:
           # Ignore ImportWarning because pyximport registered an importer
           # PyxImporter that does not have a find_spec method and this raises
           # a warning on Python 3.10
-          # Ignore DeprecationWarnings raised by importing scipy.sparse.X
+          # Ignore DeprecationWarnings raised by cvxpy importing scipy.sparse.X
           # under SciPy 1.8.0+.
           - case-name: Python 3.10
             os: ubuntu-latest
             python-version: "3.10"
             condaforge: 1
-            pytest-extra-options: "-W ignore::ImportWarning -W ignore::DeprecationWarning:qutip.fastsparse -W ignore::DeprecationWarning:cvxpy.interface.scipy_wrapper"
+            pytest-extra-options: "-W ignore::ImportWarning -W ignore::DeprecationWarning:cvxpy.interface.scipy_wrapper"
 
     steps:
       - uses: actions/checkout@v2