Repository: Qiskit/qiskit-terra (python)

Issue:
QuantumCircuit.initialize()  no longer accepts single instance of Qubit
### Environment

Used to work in Qiskit v0.34.2, tested to not work in v0.37. Appears to have been broken by commit https://github.com/Qiskit/qiskit-terra/commit/3591fa635db75e3d7f1afea19359acb2fb3a6740

### What is happening?

We used to be able to `circuit.initialize([0,1], qr[0])` but now that raises an error `TypeError: 'Qubit' object is not iterable`

Changing to `circuit.initialize([0,1], [qr[0]])` works as the `qubits` parameter is now a list. Prior to commit https://github.com/Qiskit/qiskit-terra/commit/3591fa635db75e3d7f1afea19359acb2fb3a6740 the `QuantumCircuit._bit_argument_conversion()` function was called on the passed in `qubits` param. Should that still be called?

### How can we reproduce the issue?

```
# Successful with Qiskit v0.34.2, raises error with v0.35.0+
qr = qiskit.QuantumRegister(1)
circuit = qiskit.circuit.QuantumCircuit(qr)
circuit.initialize([0, 1], qr[0])
```

### What should happen?

Unless there is a need to not convert single `Qubit` into a list automatically, I would have expected the `circuit.initialize([0,1], qr[0])` to work.

### Any suggestions?

It appears `QuantumCircuit._bit_argument_conversion()` still exists. Maybe adding the `qubits = self._bit_argument_conversion(qubits, self.qubits)` call back to `initialize()` will restore the expected functionality?

Pull request description:
accept single qubit in initialize to fix #8408
<!--
⚠️ If you do not respect this template, your pull request will be closed.
⚠️ Your pull request title should be short detailed and understandable for all.
⚠️ Also, please add a release note file using reno if the change needs to be
  documented in the release notes.
⚠️ If your pull request fixes an open issue, please link to the issue.

- [ ] I have added the tests to cover my changes.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the CONTRIBUTING document.
-->

### Summary
To fix issue #8408, passes `qubits` through `QuantumCircuit.qbit_argument_conversion()` in the `initialize` function before creating the `Initialize` instruction to make sure they are formatted correctly.


### Details and comments

Fix #8408.


Patch:
diff --git a/qiskit/circuit/library/data_preparation/state_preparation.py b/qiskit/circuit/library/data_preparation/state_preparation.py
index 43592514d..943e74f44 100644
--- a/qiskit/circuit/library/data_preparation/state_preparation.py
+++ b/qiskit/circuit/library/data_preparation/state_preparation.py
@@ -17,7 +17,7 @@ import math
 import numpy as np
 
 from qiskit.exceptions import QiskitError
-from qiskit.circuit import QuantumCircuit, QuantumRegister
+from qiskit.circuit import QuantumCircuit, QuantumRegister, Qubit
 from qiskit.circuit.gate import Gate
 from qiskit.circuit.library.standard_gates.x import CXGate, XGate
 from qiskit.circuit.library.standard_gates.h import HGate
@@ -427,8 +427,9 @@ def prepare_state(self, state, qubits=None, label=None):
               to :math:`|1\rangle`. Example: setting params to 5 would initialize qubit 0 and qubit 2
               to :math:`|1\rangle` and qubit 1 to :math:`|0\rangle`.
 
-        qubits (QuantumRegister or int):
+        qubits (QuantumRegister or Qubit or int):
             * QuantumRegister: A list of qubits to be initialized [Default: None].
+            * Qubit: Single qubit to be initialized [Default: None].
             * int: Index of qubit to be initialized [Default: None].
             * list: Indexes of qubits to be initialized [Default: None].
         label (str): An optional label for the gate
@@ -505,7 +506,7 @@ def prepare_state(self, state, qubits=None, label=None):
 
     if qubits is None:
         qubits = self.qubits
-    elif isinstance(qubits, (int, np.integer, slice)):
+    elif isinstance(qubits, (int, np.integer, slice, Qubit)):
         qubits = [qubits]
 
     num_qubits = len(qubits) if isinstance(state, int) else None
diff --git a/qiskit/extensions/quantum_initializer/initializer.py b/qiskit/extensions/quantum_initializer/initializer.py
index 67b1dfa4b..7d6c65817 100644
--- a/qiskit/extensions/quantum_initializer/initializer.py
+++ b/qiskit/extensions/quantum_initializer/initializer.py
@@ -18,6 +18,7 @@ import numpy as np
 from qiskit.circuit import QuantumCircuit
 from qiskit.circuit import QuantumRegister
 from qiskit.circuit import Instruction
+from qiskit.circuit import Qubit
 from qiskit.circuit.library.data_preparation import StatePreparation
 
 _EPS = 1e-10  # global variable used to chop very small numbers to zero
@@ -106,8 +107,9 @@ def initialize(self, params, qubits=None):
               to :math:`|1\rangle`. Example: setting params to 5 would initialize qubit 0 and qubit 2
               to :math:`|1\rangle` and qubit 1 to :math:`|0\rangle`.
 
-        qubits (QuantumRegister or int):
+        qubits (QuantumRegister or Qubit or int):
             * QuantumRegister: A list of qubits to be initialized [Default: None].
+            * Qubit: Single qubit to be initialized [Default: None].
             * int: Index of qubit to be initialized [Default: None].
             * list: Indexes of qubits to be initialized [Default: None].
 
@@ -182,7 +184,7 @@ def initialize(self, params, qubits=None):
     """
     if qubits is None:
         qubits = self.qubits
-    elif isinstance(qubits, (int, np.integer, slice)):
+    elif isinstance(qubits, (int, np.integer, slice, Qubit)):
         qubits = [qubits]
     num_qubits = len(qubits) if isinstance(params, int) else None
 
diff --git a/releasenotes/notes/circuit-initialize-and-prepare-single-qubit-e25dacc8f873bc01.yaml b/releasenotes/notes/circuit-initialize-and-prepare-single-qubit-e25dacc8f873bc01.yaml
new file mode 100644
index 000000000..0648666c6
--- /dev/null
+++ b/releasenotes/notes/circuit-initialize-and-prepare-single-qubit-e25dacc8f873bc01.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+  - |
+    Fixed a bug in :meth:`.QuantumCircuit.initialize` and :meth:`.QuantumCircuit.prepare_state`
+    that caused them to not accept a single :class:`Qubit` as argument to initialize.


Test patch:
diff --git a/test/python/circuit/library/test_state_preparation.py b/test/python/circuit/library/test_state_preparation.py
index 430d462fa..f34141ce5 100644
--- a/test/python/circuit/library/test_state_preparation.py
+++ b/test/python/circuit/library/test_state_preparation.py
@@ -19,7 +19,7 @@ import math
 import numpy as np
 from ddt import ddt, data
 
-from qiskit import QuantumCircuit
+from qiskit import QuantumCircuit, QuantumRegister
 from qiskit.quantum_info import Statevector, Operator
 from qiskit.test import QiskitTestCase
 from qiskit.exceptions import QiskitError
@@ -54,6 +54,15 @@ class TestStatePreparation(QiskitTestCase):
         actual_sv = Statevector(qc)
         self.assertTrue(desired_sv == actual_sv)
 
+    def test_prepare_single_qubit(self):
+        """Prepare state in single qubit."""
+        qreg = QuantumRegister(2)
+        circuit = QuantumCircuit(qreg)
+        circuit.prepare_state([1 / math.sqrt(2), 1 / math.sqrt(2)], qreg[1])
+        expected = QuantumCircuit(qreg)
+        expected.prepare_state([1 / math.sqrt(2), 1 / math.sqrt(2)], [qreg[1]])
+        self.assertEqual(circuit, expected)
+
     def test_nonzero_state_incorrect(self):
         """Test final state incorrect if initial state not zero"""
         desired_sv = Statevector([1 / math.sqrt(2), 0, 0, 1 / math.sqrt(2)])
diff --git a/test/python/circuit/test_registerless_circuit.py b/test/python/circuit/test_registerless_circuit.py
index 6a4d0a401..865b80e78 100644
--- a/test/python/circuit/test_registerless_circuit.py
+++ b/test/python/circuit/test_registerless_circuit.py
@@ -230,6 +230,18 @@ class TestGatesOnWires(QiskitTestCase):
 
         self.assertEqual(circuit, expected)
 
+    def test_circuit_initialize_single_qubit(self):
+        """Test initialize on single qubit."""
+        init_vector = [numpy.sqrt(0.5), numpy.sqrt(0.5)]
+        qreg = QuantumRegister(2)
+        circuit = QuantumCircuit(qreg)
+        circuit.initialize(init_vector, qreg[0])
+
+        expected = QuantumCircuit(qreg)
+        expected.initialize(init_vector, [qreg[0]])
+
+        self.assertEqual(circuit, expected)
+
     def test_mixed_register_and_registerless_indexing(self):
         """Test indexing if circuit contains bits in and out of registers."""