Repository: Qiskit/qiskit

Issue:
using the preset pass managers
### What should we add?

First the pass manager is awesome I have not used it for a while and it is really powerful and improved a lot. I personally don't see why we need to use the transpile function anymore (we should seriously consider depreciating it). This being said the generate_preset_pass_manager passes I think we should make a bit more user friendly.  

I would make it so that  

```
pm =  generate_preset_pass_manager(basis_gates = ['cz', 'sx', 'rz'],  coupling_map =[[0,1], [1,2]], optimization_level=3)
```
should work and not need me to make an object CouplingMap to pass into the generate_preset_pass_manager function. 


Discussion:
I would like to take this issue
Thanks, I've assigned you!

Resolving patch:
diff --git a/qiskit/transpiler/preset_passmanagers/__init__.py b/qiskit/transpiler/preset_passmanagers/__init__.py
--- a/qiskit/transpiler/preset_passmanagers/__init__.py
+++ b/qiskit/transpiler/preset_passmanagers/__init__.py
@@ -61,6 +61,7 @@
 
 from qiskit.transpiler.passmanager_config import PassManagerConfig
 from qiskit.transpiler.target import target_to_backend_properties
+from qiskit.transpiler import CouplingMap
 
 from .level0 import level_0_pass_manager
 from .level1 import level_1_pass_manager
@@ -130,7 +131,7 @@ def generate_preset_pass_manager(
             circuit, transpiler attaches the custom gate definition to the circuit.
             This enables one to flexibly override the low-level instruction
             implementation.
-        coupling_map (CouplingMap): Directed graph represented a coupling
+        coupling_map (CouplingMap or list): Directed graph represented a coupling
             map.
         instruction_durations (InstructionDurations): Dictionary of duration
             (in dt) for each instruction.
@@ -213,6 +214,9 @@ def generate_preset_pass_manager(
             stacklevel=2,
         )
 
+    if coupling_map is not None and not isinstance(coupling_map, CouplingMap):
+        coupling_map = CouplingMap(coupling_map)
+
     if target is not None:
         if coupling_map is None:
             coupling_map = target.build_coupling_map()


Test patch:
diff --git a/test/python/transpiler/test_preset_passmanagers.py b/test/python/transpiler/test_preset_passmanagers.py
--- a/test/python/transpiler/test_preset_passmanagers.py
+++ b/test/python/transpiler/test_preset_passmanagers.py
@@ -1272,7 +1272,7 @@ def test_size_optimization(self, level):
 
 
 @ddt
-class TestGeenratePresetPassManagers(QiskitTestCase):
+class TestGeneratePresetPassManagers(QiskitTestCase):
     """Test generate_preset_pass_manager function."""
 
     @data(0, 1, 2, 3)
@@ -1445,6 +1445,37 @@ def get_translation_stage_plugin(self):
         ]
         self.assertIn("RemoveResetInZeroState", post_translation_pass_list)
 
+    def test_generate_preset_pass_manager_with_list_coupling_map(self):
+        """Test that generate_preset_pass_manager can handle list-based coupling_map."""
+
+        # Define the coupling map as a list
+        coupling_map_list = [[0, 1]]
+        coupling_map_object = CouplingMap(coupling_map_list)
+
+        # Circuit that doesn't fit in the coupling map
+        qc = QuantumCircuit(2)
+        qc.h(0)
+        qc.cx(0, 1)
+        qc.cx(1, 0)
+        qc.measure_all()
+
+        pm_list = generate_preset_pass_manager(
+            optimization_level=0, coupling_map=coupling_map_list, seed_transpiler=42
+        )
+        pm_object = generate_preset_pass_manager(
+            optimization_level=0, coupling_map=coupling_map_object, seed_transpiler=42
+        )
+
+        transpiled_circuit_list = pm_list.run(qc)
+        transpiled_circuit_object = pm_object.run(qc)
+
+        # Check if both are instances of PassManager
+        self.assertIsInstance(pm_list, PassManager)
+        self.assertIsInstance(pm_object, PassManager)
+
+        # Ensure the DAGs from both methods are identical
+        self.assertEqual(transpiled_circuit_list, transpiled_circuit_object)
+
 
 @ddt
 class TestIntegrationControlFlow(QiskitTestCase):