Repository: qutip/qutip

Issue:
Adding number to ket unexpectedly modifies ket data
### Bug Description

Adding (or subtracting) a number from a ket modifies the data of the ket even without an assignment. In the code below, I would expect that `a` is not modified when the expression `a+1` is run, but it is. That is to say, `a+1` has the same effect as `a+=1`. In contrast, the data of the QObj does not change when adding a number to an operator or when multiplying a ket by a number.

### Code to Reproduce the Bug

```shell
from qutip import basis
a = basis(2)
print(a)
print()
print(a+1)
print()
print(a)
```


### Code Output

```shell
Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket
Qobj data =
[[1.]
 [0.]]

Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket
Qobj data =
[[2.]
 [0.]]

Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket
Qobj data =
[[2.]
 [0.]]
```


### Expected Behaviour

First of all, adding a number to a ket is not a well-defined operation, so perhaps it should throw an error. However, I think that the value of `a+1` is not entirely unexpected, so it could be kept. The real issue is that the data of `a` is modified without the code ever explicitly reassigning `a`. This is definitely unexpected. I would expect the output to be:

`Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket
Qobj data =
[[1.]
 [0.]]

Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket
Qobj data =
[[2.]
 [0.]]

Quantum object: dims = [[2], [1]], shape = (2, 1), type = ket
Qobj data =
[[1.]
 [0.]]
`

### Your Environment

```shell
QuTiP Version:      4.7.2
Numpy Version:      1.23.5
Scipy Version:      1.10.0
Cython Version:     0.29.33
Matplotlib Version: 3.6.2
Python Version:     3.10.9
Number of CPUs:     4
BLAS Info:          OPENBLAS
OPENMP Installed:   False
```


### Additional Context

_No response_


Discussion:
Thank you for reporting.

I will fix by having ket + scalar raising an error.
 

Resolving patch:
diff --git a/qutip/qobj.py b/qutip/qobj.py
--- a/qutip/qobj.py
+++ b/qutip/qobj.py
@@ -386,8 +386,7 @@ def __add__(self, other):
                 out.data = self.data + dat * fast_identity(
                     self.shape[0])
             else:
-                out.data = self.data
-                out.data.data = out.data.data + dat
+                raise TypeError("Only operators can be added to a scalar.")
 
             out.dims = self.dims
 
@@ -415,8 +414,7 @@ def __add__(self, other):
             if other.type in ['oper', 'super']:
                 out.data = dat * fast_identity(other.shape[0]) + other.data
             else:
-                out.data = other.data
-                out.data.data = out.data.data + dat
+                raise TypeError("Only operators can be added to a scalar.")
             out.dims = other.dims
 
             if settings.auto_tidyup:


Test patch:
diff --git a/qutip/tests/test_qobj.py b/qutip/tests/test_qobj.py
--- a/qutip/tests/test_qobj.py
+++ b/qutip/tests/test_qobj.py
@@ -259,6 +259,13 @@ def test_QobjAddition():
     assert np.all(x3.full() == data)
     assert np.all(x4.full() == data)
 
+    ket = Qobj([[1j],[0.]])
+    with pytest.raises(TypeError):
+        out = ket + 1.
+
+    with pytest.raises(TypeError):
+        out = 1. + ket
+
 
 def test_QobjSubtraction():
     "Qobj subtraction"