Repository: Qiskit/qiskit

Issue:
apply_operation_back API in dag should change to be consistent with add_qreg and add_creg 
Recently, the API for `DAGCircuit.add_qreg` and `DAGCircuit.add_creg` changed to be called with an object instead of a tuple (see #1189). `apply_operation_back` should also change in the same direction to be consistent.


Discussion:

Resolving patch:
diff --git a/qiskit/circuit/library/n_local/two_local.py b/qiskit/circuit/library/n_local/two_local.py
--- a/qiskit/circuit/library/n_local/two_local.py
+++ b/qiskit/circuit/library/n_local/two_local.py
@@ -17,35 +17,10 @@
 from collections.abc import Callable, Sequence
 
 from qiskit.circuit.quantumcircuit import QuantumCircuit
-from qiskit.circuit import Gate, Instruction, Parameter
+from qiskit.circuit import Gate, Instruction
 
 from .n_local import NLocal
-from ..standard_gates import (
-    IGate,
-    XGate,
-    YGate,
-    ZGate,
-    RXGate,
-    RYGate,
-    RZGate,
-    HGate,
-    SGate,
-    SdgGate,
-    TGate,
-    TdgGate,
-    RXXGate,
-    RYYGate,
-    RZXGate,
-    RZZGate,
-    SwapGate,
-    CXGate,
-    CYGate,
-    CZGate,
-    CRXGate,
-    CRYGate,
-    CRZGate,
-    CHGate,
-)
+from ..standard_gates import get_standard_gate_name_mapping
 
 if typing.TYPE_CHECKING:
     import qiskit  # pylint: disable=cyclic-import
@@ -269,38 +244,7 @@ def _convert_to_block(self, layer: str | type | Gate | QuantumCircuit) -> Quantu
         if isinstance(layer, QuantumCircuit):
             return layer
 
-        # check the list of valid layers
-        # this could be a lot easier if the standard layers would have ``name`` and ``num_params``
-        # as static types, which might be something they should have anyway
-        theta = Parameter("θ")
-        valid_layers = {
-            "ch": CHGate(),
-            "cx": CXGate(),
-            "cy": CYGate(),
-            "cz": CZGate(),
-            "crx": CRXGate(theta),
-            "cry": CRYGate(theta),
-            "crz": CRZGate(theta),
-            "h": HGate(),
-            "i": IGate(),
-            "id": IGate(),
-            "iden": IGate(),
-            "rx": RXGate(theta),
-            "rxx": RXXGate(theta),
-            "ry": RYGate(theta),
-            "ryy": RYYGate(theta),
-            "rz": RZGate(theta),
-            "rzx": RZXGate(theta),
-            "rzz": RZZGate(theta),
-            "s": SGate(),
-            "sdg": SdgGate(),
-            "swap": SwapGate(),
-            "x": XGate(),
-            "y": YGate(),
-            "z": ZGate(),
-            "t": TGate(),
-            "tdg": TdgGate(),
-        }
+        valid_layers = get_standard_gate_name_mapping()
 
         # try to exchange `layer` from a string to a gate instance
         if isinstance(layer, str):


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
@@ -37,6 +37,7 @@
     RXXGate,
     RYYGate,
     CXGate,
+    SXGate,
 )
 from qiskit.circuit.random.utils import random_circuit
 from qiskit.converters.circuit_to_dag import circuit_to_dag
@@ -697,6 +698,16 @@ def test_ryrz_blocks(self):
             expected = [(-np.pi, np.pi)] * two.num_parameters
             np.testing.assert_almost_equal(two.parameter_bounds, expected)
 
+    def test_rzsx_blocks(self):
+        """Test that the EfficientSU2 circuit is instantiated correctly."""
+        two = EfficientSU2(3, ["rz", "sx", "rz", "sx", "rz"])
+        expected = [[RZGate], [SXGate], [RZGate], [SXGate], [RZGate]]
+        actual = [
+            [instruction.operation.base_class for instruction in block]
+            for block in two.rotation_blocks
+        ]
+        self.assertEqual(actual, expected)
+
     def test_ryrz_circuit(self):
         """Test an EfficientSU2 circuit."""
         num_qubits = 3