Repository: Qiskit/qiskit

Issue:
NLocal initial state still looking for construct_circuit
NLocal library circuit says this for initial_state https://github.com/Qiskit/qiskit-terra/blob/ab1539c8179b40b05ff6c921cec84815540c0e06/qiskit/circuit/library/n_local/n_local.py#L101-L102

However passing in a QuantumCircuit as an initial state fails as in the setter its still unconditionally calling construct_circuit https://github.com/Qiskit/qiskit-terra/blob/ab1539c8179b40b05ff6c921cec84815540c0e06/qiskit/circuit/library/n_local/n_local.py#L614-L617

Now maybe we need to keep the construct_circuit option until Aqua is no longer supported. But I think the logic needs altering to allow a QuantumCircuit to be directly passed to still define an initial state.

There are also some references to Aqua in the text and in Raises that idealy need addressing too


Discussion:
I would like to work on this. @woodsp-ibm @Cryoris 
Great, I just assigned you @ishworii 👍🏼
Can I just add an instance check and do something like this? @Cryoris @woodsp-ibm 
```
if isinstance(initial_state,QuantumCircuit):
    self._initial_state_circuit = initial_state
    else:    
        self._initial_state_circuit = initial_state.construct_circuit(mode="circuit")
```
Yes 👍🏻 Though you probably have to copy the circuit to avoid it being used via reference.

Resolving patch:
diff --git a/qiskit/circuit/library/n_local/n_local.py b/qiskit/circuit/library/n_local/n_local.py
--- a/qiskit/circuit/library/n_local/n_local.py
+++ b/qiskit/circuit/library/n_local/n_local.py
@@ -14,6 +14,7 @@
 
 from typing import Union, Optional, List, Any, Tuple, Sequence, Set, Callable
 from itertools import combinations
+import warnings
 
 import numpy
 from qiskit.circuit.quantumcircuit import QuantumCircuit
@@ -677,7 +678,20 @@ def initial_state(self, initial_state: Any) -> None:
         self._initial_state = initial_state
 
         # construct the circuit of the initial state
-        self._initial_state_circuit = initial_state.construct_circuit(mode="circuit")
+        # if initial state is an instance of QuantumCircuit do not call construct circuit
+        if isinstance(self._initial_state, QuantumCircuit):
+            self._initial_state_circuit = self._initial_state.copy()
+        else:
+            warnings.warn(
+                "The initial_state argument of the NLocal class "
+                "should be a QuantumCircuit. Passing any other type is "
+                "deprecated as of Qiskit Terra 0.18.0, and "
+                "will be removed no earlier than 3 months after that "
+                "release date.",
+                DeprecationWarning,
+                stacklevel=2,
+            )
+            self._initial_state_circuit = initial_state.construct_circuit(mode="circuit")
 
         # the initial state dictates the number of qubits since we do not have information
         # about on which qubits the initial state acts
@@ -933,9 +947,12 @@ def _build(self) -> None:
         if self.num_qubits == 0:
             return
 
-        # use the initial state circuit if it is not None
+        # use the initial state as starting circuit, if it is set
         if self._initial_state:
-            circuit = self._initial_state.construct_circuit("circuit", register=self.qregs[0])
+            if isinstance(self._initial_state, QuantumCircuit):
+                circuit = self._initial_state.copy()
+            else:
+                circuit = self._initial_state.construct_circuit("circuit", register=self.qregs[0])
             self.compose(circuit, inplace=True)
 
         param_iter = iter(self.ordered_parameters)


Test patch:
diff --git a/test/python/circuit/library/test_nlocal.py b/test/python/circuit/library/test_nlocal.py
--- a/test/python/circuit/library/test_nlocal.py
+++ b/test/python/circuit/library/test_nlocal.py
@@ -415,6 +415,31 @@ def test_entanglement_by_list(self):
 
         self.assertCircuitEqual(nlocal, circuit)
 
+    def test_initial_state_as_circuit_object(self):
+        """Test setting `initial_state` to `QuantumCircuit` object"""
+        ref = QuantumCircuit(2)
+        ref.cx(0, 1)
+        ref.x(0)
+        ref.h(1)
+        ref.x(1)
+        ref.cx(0, 1)
+        ref.x(0)
+        ref.x(1)
+
+        qc = QuantumCircuit(2)
+        qc.cx(0, 1)
+        qc.h(1)
+
+        expected = NLocal(
+            num_qubits=2,
+            rotation_blocks=XGate(),
+            entanglement_blocks=CXGate(),
+            initial_state=qc,
+            reps=1,
+        )
+
+        self.assertCircuitEqual(ref, expected)
+
 
 @ddt
 class TestTwoLocal(QiskitTestCase):