Repository: Qiskit/qiskit

Issue:
Layout.get_registers() does not return registers
### Information
- **Qiskit Terra version**: 0.8.0
- **Python version**: 3.6
- **Operating system**: Mac

### What is the current behavior?
Layout.get_registers() returns (virtual) qubits:
```
return list(self.get_virtual_bits().keys())
```

### What is the expected behavior?
Layout.get_registers() returns (virtual quantum) registers:
```
return set([reg for reg, idx in self.get_virtual_bits().keys()])
```

### Suggested solutions
Change the implementation of Layout.get_registers() to:
```
return set([reg for reg, idx in self.get_virtual_bits().keys()])
```

Change the line in BasicSwap.run()
```
                        for qreg in current_layout.get_registers():
                            if qreg[0] not in swap_layer.qregs.values():
                                swap_layer.add_qreg(qreg[0])
```
to
```
                        for qreg in current_layout.get_registers():
                            if qreg not in swap_layer.qregs.values():
                                swap_layer.add_qreg(qreg)
```
Layout.get_registers() does not return registers
### Information
- **Qiskit Terra version**: 0.8.0
- **Python version**: 3.6
- **Operating system**: Mac

### What is the current behavior?
Layout.get_registers() returns (virtual) qubits:
```
return list(self.get_virtual_bits().keys())
```

### What is the expected behavior?
Layout.get_registers() returns (virtual quantum) registers:
```
return set([reg for reg, idx in self.get_virtual_bits().keys()])
```

### Suggested solutions
Change the implementation of Layout.get_registers() to:
```
return set([reg for reg, idx in self.get_virtual_bits().keys()])
```

Change the line in BasicSwap.run()
```
                        for qreg in current_layout.get_registers():
                            if qreg[0] not in swap_layer.qregs.values():
                                swap_layer.add_qreg(qreg[0])
```
to
```
                        for qreg in current_layout.get_registers():
                            if qreg not in swap_layer.qregs.values():
                                swap_layer.add_qreg(qreg)
```


Discussion:

Resolving patch:
diff --git a/qiskit/mapper/_layout.py b/qiskit/mapper/_layout.py
--- a/qiskit/mapper/_layout.py
+++ b/qiskit/mapper/_layout.py
@@ -189,7 +189,7 @@ def get_registers(self):
         Returns:
             List: A list of Register in the layout
         """
-        return list(self.get_virtual_bits().keys())
+        return {reg for reg, _ in self.get_virtual_bits()}
 
     def idle_physical_bits(self):
         """
diff --git a/qiskit/transpiler/passes/mapping/basic_swap.py b/qiskit/transpiler/passes/mapping/basic_swap.py
--- a/qiskit/transpiler/passes/mapping/basic_swap.py
+++ b/qiskit/transpiler/passes/mapping/basic_swap.py
@@ -91,8 +91,8 @@ def run(self, dag):
 
                         # create qregs
                         for qreg in current_layout.get_registers():
-                            if qreg[0] not in swap_layer.qregs.values():
-                                swap_layer.add_qreg(qreg[0])
+                            if qreg not in swap_layer.qregs.values():
+                                swap_layer.add_qreg(qreg)
 
                         # create the swap operation
                         swap_layer.apply_operation_back(self.swap_gate(qubit_1, qubit_2),


Test patch: