Repository: qutip/qutip

Issue:
Cannot import qutip after latest scipy release
### Bug Description

I've encountered this bug when creating a clean environment, and installing `qutip` (and IPython as console) through mamba.
Next, I've opened an IPython console and ran `import qutip`, which resulted in the exception printed below - stating that the `format` attribute of the `fast_csr_matrix` cannot be set.

I believe the latest `scipy` [release](https://github.com/scipy/scipy/releases) is the culprit (released 14 hrs ago at the time of writing) - reducing from `scipy==1.11.0` to `scipy==1.10.1` resolves the issue for me.

### Code to Reproduce the Bug

```shell
import qutip
```


### Code Output

```shell
Cell In[1], line 1
----> 1 import qutip

File ~\mambaforge\envs\test-env-scipy-qutip\Lib\site-packages\qutip\__init__.py:106
     98     del matplotlib
    101 # -----------------------------------------------------------------------------
    102 # Load modules
    103 #
    104
    105 # core
--> 106 from qutip.qobj import *
    107 from qutip.qobjevo import *
    108 from qutip.states import *

File ~\mambaforge\envs\test-env-scipy-qutip\Lib\site-packages\qutip\qobj.py:2526
   2523 # TRAILING IMPORTS
   2524 # We do a few imports here to avoid circular dependencies.
   2525 from qutip.eseries import eseries
-> 2526 import qutip.superop_reps as sr
   2527 import qutip.tensor as tensor
   2528 import qutip.operators as ops

File ~\mambaforge\envs\test-env-scipy-qutip\Lib\site-packages\qutip\superop_reps.py:74
     61     return Qobj(dims=[[[2], [2]], [[2], [2]]],
     62                 inpt=array([[1. - pe / 2., 0., 0., 1. - pe],
     63                             [0., pe / 2., 0., 0.],
     64                             [0., 0., pe / 2., 0.],
     65                             [1. - pe, 0., 0., 1. - pe / 2.]]),
     66                 superrep='choi')
     69 # CHANGE OF BASIS FUNCTIONS ---------------------------------------------------
     70 # These functions find change of basis matrices, and are useful in converting
     71 # between (for instance) Choi and chi matrices. At some point, these should
     72 # probably be moved out to another module.
---> 74 _SINGLE_QUBIT_PAULI_BASIS = (identity(2), sigmax(), sigmay(), sigmaz())
     77 def _pauli_basis(nq=1):
     78     # NOTE: This is slow as can be.
     79     # TODO: Make this sparse. CSR format was causing problems for the [idx, :]
     80     #       slicing below.
     81     B = zeros((4 ** nq, 4 ** nq), dtype=complex)

File ~\mambaforge\envs\test-env-scipy-qutip\Lib\site-packages\qutip\operators.py:508, in identity(dims)
    492 def identity(dims):
    493     """Identity operator. Alternative name to :func:`qeye`.
    494
    495     Parameters
   (...)
    506         Identity operator Qobj.
    507     """
--> 508     return qeye(dims)

File ~\mambaforge\envs\test-env-scipy-qutip\Lib\site-packages\qutip\operators.py:488, in qeye(dimensions)
    452 """
    453 Identity operator.
    454
   (...)
    485
    486 """
    487 size, dimensions = _implicit_tensor_dimensions(dimensions)
--> 488 return Qobj(fast_identity(size),
    489             dims=dimensions, isherm=True, isunitary=True)

File ~\mambaforge\envs\test-env-scipy-qutip\Lib\site-packages\qutip\fastsparse.py:389, in fast_identity(N)
    387 ptr = np.arange(N+1, dtype=np.int32)
    388 ptr[-1] = N
--> 389 return fast_csr_matrix((data,ind,ptr),shape=(N,N))

File ~\mambaforge\envs\test-env-scipy-qutip\Lib\site-packages\qutip\fastsparse.py:55, in fast_csr_matrix.__init__(self, args, shape, dtype, copy)
     53 self.dtype = complex
     54 self.maxprint = 50
---> 55 self.format = 'csr'

AttributeError: property 'format' of 'fast_csr_matrix' object has no setter
```


### Expected Behaviour

I expected to be able to import qutip :) 

### Your Environment

```shell
QuTiP Version:      4.7.1
Numpy Version:      1.25.0
Scipy Version:      1.11.0
Cython Version:     None
Matplotlib Version: None
Python Version:     3.11.4
Number of CPUs:     8
BLAS Info:          Generic
OPENMP Installed:   False
INTEL MKL Ext:      False
Platform Info:      Windows (AMD64)
```


### Additional Context

The environment above was generated with `scipy==1.10.1` (which still worked); I've changed the Scipy version to `1.11.0` manually in that list.

Forcing `scipy==1.10.1`, resolves the problem. Hence, I'm under the impression that the recent bump of `scipy` to `1.11.0` is causing the issue.


Discussion:
Reducing to `scipy==1.10.1` gave me a different error, `AttributeError: partially initialized module 'qutip' has no attribute 'settings' (most likely due to a circular import)`

using:
```
qutip                   4.7.1
scipy                   1.10.1
```

Resolving patch:
diff --git a/qutip/fastsparse.py b/qutip/fastsparse.py
--- a/qutip/fastsparse.py
+++ b/qutip/fastsparse.py
@@ -52,7 +52,11 @@ def __init__(self, args=None, shape=None, dtype=None, copy=False):
                 self._shape = tuple(int(s) for s in shape)
         self.dtype = complex
         self.maxprint = 50
-        self.format = 'csr'
+        if hasattr(self, "_format"):
+            # format is readonly since 1.11
+            self._format = 'csr'
+        else:
+            self.format = 'csr'
 
     def _binopt(self, other, op):
         """


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -90,6 +90,7 @@ jobs:
             os: ubuntu-latest
             python-version: "3.10"
             condaforge: 1
+            nocvxopt: 1
             pytest-extra-options: "-W ignore::ImportWarning -W ignore::DeprecationWarning:cvxpy.interface.scipy_wrapper -W ignore:Absolute:DeprecationWarning"
 
           # Python 3.11 and latest numpy
@@ -135,10 +136,13 @@ jobs:
         # rather than in the GitHub Actions file directly, because bash gives us
         # a proper programming language to use.
         run: |
-          QUTIP_TARGET="tests,graphics,semidefinite,ipython"
+          QUTIP_TARGET="tests,graphics,ipython"
           if [[ -z "${{ matrix.nocython }}" ]]; then
             QUTIP_TARGET="$QUTIP_TARGET,runtime_compilation"
           fi
+          if [[ -z "${{ matrix.nocvxopt }}" ]]; then
+            QUTIP_TARGET="$QUTIP_TARGET,semidefinite"
+          fi
           export CI_QUTIP_WITH_OPENMP=${{ matrix.openmp }}
           if [[ -z "${{ matrix.nomkl }}" ]]; then
             conda install blas=*=mkl "numpy${{ matrix.numpy-requirement }}" "scipy${{ matrix.scipy-requirement }}"