internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: Qiskit/qiskit

Issue:
optimization_level=3 triggers error in unrolling
_Originally posted by @itoko in https://github.com/Qiskit/qiskit-terra/issues/2339#issuecomment-490103445_

The follow input triggers and an issue in the unroller. 
```python
from qiskit import QuantumCircuit, QuantumRegister, QiskitError
from qiskit.compiler import transpile
from qiskit.transpiler import CouplingMap
q = QuantumRegister(2)
qc = QuantumCircuit(q)
qc.cx(q[0], q[1])
qc.cx(q[0], q[1])
coupling = CouplingMap([[0, 1]])
compiled = transpile(qc, coupling_map=CouplingMap([[0, 1]]), optimization_level=3)
print(compiled)
```
```
QiskitError: "Cannot unroll the circuit to the given basis, ['cx', 'cx']. No rule to expand instruction U."
```


Discussion:

Resolving patch:
diff --git a/qiskit/compiler/transpile.py b/qiskit/compiler/transpile.py
--- a/qiskit/compiler/transpile.py
+++ b/qiskit/compiler/transpile.py
@@ -225,10 +225,14 @@ def _parse_basis_gates(basis_gates, backend, circuits):
     if basis_gates is None or (isinstance(basis_gates, list) and
                                all(isinstance(i, str) for i in basis_gates)):
         basis_gates = [basis_gates] * len(circuits)
-    # no basis means don't unroll (all circuit gates are valid basis)
-    basis_gates = [[inst.name for inst, _, _ in circuit.data] if basis is None
-                   else basis for basis, circuit in zip(basis_gates, circuits)]
 
+    # no basis means don't unroll (all circuit gates are valid basis)
+    for index, circuit in enumerate(circuits):
+        basis = basis_gates[index]
+        if basis is None:
+            gates_in_circuit = set(inst.name for inst, _, _ in circuit.data)
+            # Other passes might add new gates that need to be supported
+            basis_gates[index] = list(gates_in_circuit.union(['u3', 'cx']))
     return basis_gates
 
 


Test patch:
Repository: Qiskit/qiskit

Issue:
execute/transpile with optimization_level=0 runs default_pass_manager
`optimization_level=0` does not work in `execute()` and `transpile()`, and runs `default_pass_manager` (if `coupling_map` is specified) instead of `level_0_pass_manager`.

### Steps to reproduce the problem
```
from qiskit import QuantumCircuit, QuantumRegister, QiskitError
from qiskit.compiler import transpile
from qiskit.transpiler import CouplingMap
q = QuantumRegister(2)
qc = QuantumCircuit(q)
qc.cx(q[0], q[1])
qc.cx(q[0], q[1])
coupling = CouplingMap([[0, 1]])
compiled = transpile(qc,
                     coupling_map=CouplingMap([[0, 1]]),
                     optimization_level=0)
print(compiled)
```
results in no gates, i.e. two CNOTs are cancelled out.
```
q_0: |0>
        
q_1: |0>
```

### What is the expected behavior?
It should return
```
q0_0: |0>──■────■──
         ┌─┴─┐┌─┴─┐
q0_1: |0>┤ X ├┤ X ├
         └───┘└───┘
```
(No optimization for level 0)


### Suggested solutions
In `transpile_circuit.py`,
```
    elif transpile_config.optimization_level:
```
->
```
    elif transpile_config.optimization_level is not None:
```




Discussion:
thanks for noticing this, will fix.
I found the same example with `optimization_level=3` causes another issue (some error in unrolling)...

Resolving patch:
diff --git a/qiskit/transpiler/transpile_circuit.py b/qiskit/transpiler/transpile_circuit.py
--- a/qiskit/transpiler/transpile_circuit.py
+++ b/qiskit/transpiler/transpile_circuit.py
@@ -40,7 +40,7 @@ def transpile_circuit(circuit, transpile_config):
     if transpile_config.pass_manager:
         pass_manager = transpile_config.pass_manager
 
-    elif transpile_config.optimization_level:
+    elif transpile_config.optimization_level is not None:
         level = transpile_config.optimization_level
         if level == 0:
             pass_manager = level_0_pass_manager(transpile_config)


Test patch:
Repository: Qiskit/qiskit

Issue:
optimization_level=3 triggers error in unrolling
_Originally posted by @itoko in https://github.com/Qiskit/qiskit-terra/issues/2339#issuecomment-490103445_

The follow input triggers and an issue in the unroller. 
```python
from qiskit import QuantumCircuit, QuantumRegister, QiskitError
from qiskit.compiler import transpile
from qiskit.transpiler import CouplingMap
q = QuantumRegister(2)
qc = QuantumCircuit(q)
qc.cx(q[0], q[1])
qc.cx(q[0], q[1])
coupling = CouplingMap([[0, 1]])
compiled = transpile(qc, coupling_map=CouplingMap([[0, 1]]), optimization_level=3)
print(compiled)
```
```
QiskitError: "Cannot unroll the circuit to the given basis, ['cx', 'cx']. No rule to expand instruction U."
```


Discussion:

Resolving patch:
diff --git a/qiskit/compiler/transpile.py b/qiskit/compiler/transpile.py
--- a/qiskit/compiler/transpile.py
+++ b/qiskit/compiler/transpile.py
@@ -234,10 +234,14 @@ def _parse_basis_gates(basis_gates, backend, circuits):
     if basis_gates is None or (isinstance(basis_gates, list) and
                                all(isinstance(i, str) for i in basis_gates)):
         basis_gates = [basis_gates] * len(circuits)
-    # no basis means don't unroll (all circuit gates are valid basis)
-    basis_gates = [[inst.name for inst, _, _ in circuit.data] if basis is None
-                   else basis for basis, circuit in zip(basis_gates, circuits)]
 
+    # no basis means don't unroll (all circuit gates are valid basis)
+    for index, circuit in enumerate(circuits):
+        basis = basis_gates[index]
+        if basis is None:
+            gates_in_circuit = set(inst.name for inst, _, _ in circuit.data)
+            # Other passes might add new gates that need to be supported
+            basis_gates[index] = list(gates_in_circuit.union(['u3', 'cx']))
     return basis_gates
 
 


Test patch:
Repository: Qiskit/qiskit

Issue:
Improve error message for type mismatch
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### What is the expected enhancement?

In `qiskit/validation/base.py`, function `check_types`: if type does not match, the error message currently prints the expected type. It would help if it also prints the actual type.



Discussion:
Can you write a small snippet as a minimal way to reproduce the issue? thanks!
```
>>> import qiskit as qk
>>> import numpy as np
>>> n = np.int64(5)
>>> qr = qk.QuantumRegister(n)
>>> qc = qk.QuantumCircuit(qr)
>>> qobj = qk.assemble_circuits(qc)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/compiler/assembler.py", line 72, in assemble_circuits
    experimentconfig = QasmQobjExperimentConfig(n_qubits=n_qubits, memory_slots=memory_slots)
  File "/Users/kevin.krsulichibm.com/q/qiskit-terra/qiskit/validation/base.py", line 245, in _decorated
    ex.messages, ex.field_names, ex.fields, ex.data, **ex.kwargs) from None
qiskit.validation.exceptions.ModelValidationError: {'n_qubits': ["Value '5' is not the expected type <class 'int'>"]}
```
This should actually not give a warning at all. Either the internals should work with np ints, or they should be cast to standard python ints. 
Correct, for this particular example. But in the general case, where a warning should really be given, it is useful to know which wrong type is encountered.
After #2291, the way to force the error is:
```python
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.compiler.assemble import assemble
import numpy as np

n = np.int64(2)
qr = QuantumRegister(n, name='q')
cr = ClassicalRegister(2, name='c')
circ = QuantumCircuit(qr, cr, name='circ')
circ.h(qr[0])
circ.cx(qr[0], qr[1])
circ.measure(qr, cr)
qr.size = n

qobj = assemble(circ, shots=2000, memory=True)
```


Resolving patch:
diff --git a/qiskit/validation/base.py b/qiskit/validation/base.py
--- a/qiskit/validation/base.py
+++ b/qiskit/validation/base.py
@@ -84,7 +84,7 @@ def _not_expected_type(value, type_, **kwargs):
         else:
             body = 'is not the expected type {}'.format(type_)
 
-        message = 'Value \'{}\' {}'.format(value, body)
+        message = 'Value \'{}\' {}: {}'.format(value, type(value), body)
         return ValidationError(message, **kwargs)
 
 


Test patch:
Repository: Qiskit/qiskit

Issue:
rep_times should be integer and not float in provider models
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**:
- **Python version**:
- **Operating system**:

### What is the current behavior?
Marshmallow provider models expect float as rep_time.




Discussion:

Resolving patch:
diff --git a/qiskit/providers/models/backendconfiguration.py b/qiskit/providers/models/backendconfiguration.py
--- a/qiskit/providers/models/backendconfiguration.py
+++ b/qiskit/providers/models/backendconfiguration.py
@@ -120,7 +120,7 @@ class PulseBackendConfigurationSchema(QasmBackendConfigurationSchema):
                               validate=Length(equal=2)), required=True)
     dt = Float(required=True, validate=Range(min=0))  # pylint: disable=invalid-name
     dtm = Float(required=True, validate=Range(min=0))
-    rep_times = List(Float(validate=Range(min=0)), required=True)
+    rep_times = List(Integer(validate=Range(min=0)), required=True)
     meas_kernels = List(String(), required=True)
     discriminators = List(String(), required=True)
 


Test patch:
diff --git a/qiskit/test/mock.py b/qiskit/test/mock.py
--- a/qiskit/test/mock.py
+++ b/qiskit/test/mock.py
@@ -173,7 +173,7 @@ def __init__(self):
             meas_lo_range=[[6.0, 7.0], [6.0, 7.0]],
             dt=1.3333,
             dtm=10.5,
-            rep_times=[100., 250., 500., 1000.],
+            rep_times=[100, 250, 500, 1000],
             meas_map=[[0], [1, 2]],
             channel_bandwidth=[
                 [-0.2, 0.4], [-0.3, 0.3], [-0.3, 0.3],
Repository: Qiskit/qiskit

Issue:
Matplotlib drawer fails with style dict
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: master

### What is the current behavior?
If you don't provide a config to the matplotlib drawer, but you provide a style dict an error is raised `AttributeError: 'MatplotlibDrawer' object has no attribute '_style'` . I think this is because of the logic introduced in #2344, which results in the `self._style` variable never being initialised.

### Steps to reproduce the problem
Provide a style dict but no config

### Suggested solutions
Set the style to be the one provided by the user.




Discussion:
yes, this is my fault as I did not even know that was an option at the time. The use of a dict here also does not match the other plotting routines like text where things like line_length are kwargs not a single dict 

Resolving patch:
diff --git a/qiskit/visualization/matplotlib.py b/qiskit/visualization/matplotlib.py
--- a/qiskit/visualization/matplotlib.py
+++ b/qiskit/visualization/matplotlib.py
@@ -135,10 +135,10 @@ def __init__(self, qregs, cregs, ops,
                 self._style = DefaultStyle()
             elif config_style == 'bw':
                 self._style = BWStyle()
-        if not config and style is None:
-            self._style = DefaultStyle()
         elif style is False:
             self._style = BWStyle()
+        else:
+            self._style = DefaultStyle()
 
         self.plot_barriers = plot_barriers
         self.reverse_bits = reverse_bits


Test patch:
Repository: Qiskit/qiskit

Issue:
gate dimension mismatch not detected
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: master
- **Python version**:
- **Operating system**:

### What is the current behavior?
The following code should throw an error, because it's trying to append a 3 qubit initializer to 2 qubits. But it does not raise.

```python
random_state = [
    1 / math.sqrt(4) * complex(0, 1),
    1 / math.sqrt(8) * complex(1, 0),
    0,
    1 / math.sqrt(8) * complex(1, 0),
    1 / math.sqrt(8) * complex(0, 1),
    0,
    1 / math.sqrt(4) * complex(1, 0),
    1 / math.sqrt(8) * complex(1, 0)]

qc = QuantumCircuit(qr)
qc.initialize(random_state, qr[0:2])
```

In stable this works as expected, so probably an issue with the recent append PR.





Discussion:

Resolving patch:
diff --git a/qiskit/extensions/initializer.py b/qiskit/extensions/initializer.py
--- a/qiskit/extensions/initializer.py
+++ b/qiskit/extensions/initializer.py
@@ -240,6 +240,11 @@ def _multiplex(self, target_gate, list_of_angles):
 
     def broadcast_arguments(self, qargs, cargs):
         flat_qargs = [qarg for sublist in qargs for qarg in sublist]
+
+        if self.num_qubits != len(flat_qargs):
+            raise QiskitError("Initialize parameter vector has %d elements, therefore expects %s "
+                              "qubits. However, %s were provided." %
+                              (2**self.num_qubits, self.num_qubits, len(flat_qargs)))
         yield flat_qargs, []
 
 


Test patch:
diff --git a/test/python/circuit/test_initializer.py b/test/python/circuit/test_initializer.py
--- a/test/python/circuit/test_initializer.py
+++ b/test/python/circuit/test_initializer.py
@@ -210,6 +210,25 @@ def test_non_unit_probability(self):
             QiskitError,
             qc.initialize, desired_vector, [qr[0], qr[1]])
 
+    def test_wrong_vector_size(self):
+        """Initializing to a vector with a size different to the qubit parameter length.
+        See https://github.com/Qiskit/qiskit-terra/issues/2372 """
+        qr = QuantumRegister(2)
+
+        random_state = [
+            1 / math.sqrt(4) * complex(0, 1),
+            1 / math.sqrt(8) * complex(1, 0),
+            0,
+            1 / math.sqrt(8) * complex(1, 0),
+            1 / math.sqrt(8) * complex(0, 1),
+            0,
+            1 / math.sqrt(4) * complex(1, 0),
+            1 / math.sqrt(8) * complex(1, 0)]
+
+        qc = QuantumCircuit(qr)
+
+        self.assertRaises(QiskitError, qc.initialize, random_state, qr[0:2])
+
     def test_initialize_middle_circuit(self):
         """Reset + initialize gives the correct statevector."""
         desired_vector = [0.5, 0.5, 0.5, 0.5]
Repository: Qiskit/qiskit

Issue:
CmdDef unittest has wrong argument
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**:
- **Python version**:
- **Operating system**:

### What is the current behavior?
cmd_def test specifies a string value `'0'` instead of int/float/complex value for a parameter.
https://github.com/Qiskit/qiskit-terra/blob/7f01b8bae8fa05de47e9eb4dcaa5a0154df2bd72/test/python/pulse/test_cmd_def.py#L86


### Steps to reproduce the problem



### What is the expected behavior?
argument should be int, float or complex.


### Suggested solutions





Discussion:

Resolving patch:
diff --git a/qiskit/pulse/cmd_def.py b/qiskit/pulse/cmd_def.py
--- a/qiskit/pulse/cmd_def.py
+++ b/qiskit/pulse/cmd_def.py
@@ -116,8 +116,8 @@ def has(self, cmd_name: str, qubits: Union[int, Iterable[int]]) -> bool:
         return False
 
     def get(self, cmd_name: str, qubits: Union[int, Iterable[int]],
-            *params: List[Union[float, complex]],
-            **kwparams: Dict[str, Union[float, complex]]) -> Schedule:
+            *params: List[Union[int, float, complex]],
+            **kwparams: Dict[str, Union[int, float, complex]]) -> Schedule:
         """Get command from command definition.
         Args:
             cmd_name: Name of the command
@@ -160,8 +160,8 @@ def get_parameters(self, cmd_name: str, qubits: Union[int, Iterable[int]]) -> Tu
                              'in CmdDef'.format(cmd_name, qubits))
 
     def pop(self, cmd_name: str, qubits: Union[int, Iterable[int]],
-            *params: List[Union[float, complex]],
-            **kwparams: Dict[str, Union[float, complex]]) -> Schedule:
+            *params: List[Union[int, float, complex]],
+            **kwparams: Dict[str, Union[int, float, complex]]) -> Schedule:
         """Pop command from command definition.
 
         Args:


Test patch:
diff --git a/test/python/pulse/test_cmd_def.py b/test/python/pulse/test_cmd_def.py
--- a/test/python/pulse/test_cmd_def.py
+++ b/test/python/pulse/test_cmd_def.py
@@ -83,13 +83,13 @@ def test_parameterized_schedule(self):
         cmd_def.add('pv_test', 0, converted_instruction)
         self.assertEqual(cmd_def.get_parameters('pv_test', 0), ('P1', 'P2'))
 
-        sched = cmd_def.get('pv_test', 0, '0', P2=-1)
+        sched = cmd_def.get('pv_test', 0, 0, P2=-1)
         self.assertEqual(sched.instructions[0][-1].command.value, -1)
 
         with self.assertRaises(PulseError):
-            cmd_def.get('pv_test', 0, '0', P1=-1)
+            cmd_def.get('pv_test', 0, 0, P1=-1)
 
-        sched = cmd_def.pop('pv_test', 0, '0', P2=-1)
+        sched = cmd_def.pop('pv_test', 0, 0, P2=-1)
         self.assertEqual(sched.instructions[0][-1].command.value, -1)
 
         self.assertFalse(cmd_def.has('pv_test', 0))
Repository: Qiskit/qiskit

Issue:
The if clause inside _make_np_bool does not protect against tuple
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: latest
- **Python version**: 3.6
- **Operating system**: Linux

### What is the current behavior?

The Pauli class's constructor does not treat `Pauli(x=(0,1),z=(0,1))` well.

### Steps to reproduce the problem

```
str(Pauli(x=(1,0), z=(1,0)))
```
Gives ValueError.

```
str(Pauli(x=[1,0], z=[1,0]))
```
Works.

### What is the expected behavior?

```
"IY"
```

### Suggested solutions

Adds a last `else` to the `_make_np_bool` [here](https://github.com/Qiskit/qiskit-terra/blob/315ba5465fc2769a2a9bcc66998058bc95f37524/qiskit/quantum_info/operators/pauli.py#L29).

Or we should simply do `np.asarray(arr)` and catch the error, instead of `isinstance(arr, list)`.



Discussion:

Resolving patch:
diff --git a/qiskit/quantum_info/operators/pauli.py b/qiskit/quantum_info/operators/pauli.py
--- a/qiskit/quantum_info/operators/pauli.py
+++ b/qiskit/quantum_info/operators/pauli.py
@@ -27,13 +27,9 @@
 
 
 def _make_np_bool(arr):
-
-    if not isinstance(arr, list) and not isinstance(arr, np.ndarray):
-        arr = np.asarray([arr]).astype(np.bool)
-    elif isinstance(arr, list):
-        arr = np.asarray(arr).astype(np.bool)
-    elif arr.dtype != np.bool:
-        arr = arr.astype(np.bool)
+    if not isinstance(arr, (list, np.ndarray, tuple)):
+        arr = [arr]
+    arr = np.asarray(arr).astype(np.bool)
     return arr
 
 


Test patch:
diff --git a/test/python/quantum_info/test_pauli.py b/test/python/quantum_info/test_pauli.py
--- a/test/python/quantum_info/test_pauli.py
+++ b/test/python/quantum_info/test_pauli.py
@@ -24,6 +24,45 @@
 from qiskit.test import QiskitTestCase
 
 
+class TestPauliAPI(QiskitTestCase):
+    """Tests for Pauli class API."""
+
+    def check(self, result):
+        """checks for result to be a Pauli 'IY' """
+        self.assertIsInstance(result, Pauli)
+        self.assertEqual(result.numberofqubits, 2)
+        self.assertEqual(result.to_label(), 'IY')
+
+    def test_ndarray_bool(self):
+        """Test creation from np.bool."""
+        x = np.asarray([1, 0]).astype(np.bool)
+        z = np.asarray([1, 0]).astype(np.bool)
+        pauli = Pauli(x=x, z=z)
+        self.check(pauli)
+
+    def test_ndarray_int(self):
+        """Test creation from np.int."""
+        x = np.asarray([2, 0]).astype(np.int)
+        z = np.asarray([2, 0]).astype(np.int)
+        pauli = Pauli(x=x, z=z)
+        self.check(pauli)
+
+    def test_list(self):
+        """Test creation from lists."""
+        pauli = Pauli(x=[1, 0], z=[1, 0])
+        self.check(pauli)
+
+    def test_tuple(self):
+        """Test creation from tuples."""
+        pauli = Pauli(x=(1, 0), z=(1, 0))
+        self.check(pauli)
+
+    def test_mix(self):
+        """Test creation from tuples and list."""
+        pauli = Pauli(x=(1, 0), z=[1, 0])
+        self.check(pauli)
+
+
 class TestPauli(QiskitTestCase):
     """Tests for Pauli class."""
Repository: Qiskit/qiskit

Issue:
Branch `master` is failing
<!-- commit 9ad54e15ddf7a689b639d0984a41867b84aef4b3@master -->
Trying to build `master` at commit 9ad54e15ddf7a689b639d0984a41867b84aef4b3 failed.
More info at: https://travis-ci.com/Qiskit/qiskit-terra/jobs/206584074
Branch `master` is failing
<!-- commit 8f406d5a15c6aedd19d829541691a79489aa77bb@master -->
Trying to build `master` at commit 8f406d5a15c6aedd19d829541691a79489aa77bb failed.
More info at: https://travis-ci.com/Qiskit/qiskit-terra/jobs/206513297


Discussion:

Resolving patch:
diff --git a/qiskit/tools/monitor/backend_overview.py b/qiskit/tools/monitor/backend_overview.py
--- a/qiskit/tools/monitor/backend_overview.py
+++ b/qiskit/tools/monitor/backend_overview.py
@@ -115,7 +115,7 @@ def backend_monitor(backend):
         print(offset+qstr)
 
     print()
-    multi_qubit_gates = props['gates'][3*config['n_qubits']:]
+    multi_qubit_gates = [g for g in props['gates'] if len(g['qubits']) > 1]
     multi_header = 'Multi-Qubit Gates [Name / Type / Gate Error]'
     print(multi_header)
     print('-'*len(multi_header))


Test patch:
Repository: Qiskit/qiskit

Issue:
BackendConfiguration should allow None for gates and basis_gates
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### What is the expected enhancement?
`BackendConfiguration` needs to allow for `gates = None` and `basis_gates =  None` in the model validation in order to allow a pulse-based simulator




Discussion:

Resolving patch:
diff --git a/qiskit/providers/models/backendconfiguration.py b/qiskit/providers/models/backendconfiguration.py
--- a/qiskit/providers/models/backendconfiguration.py
+++ b/qiskit/providers/models/backendconfiguration.py
@@ -72,10 +72,8 @@ class BackendConfigurationSchema(BaseSchema):
     backend_version = String(required=True,
                              validate=Regexp("[0-9]+.[0-9]+.[0-9]+$"))
     n_qubits = Integer(required=True, validate=Range(min=1))
-    basis_gates = List(String(), required=True,
-                       validate=Length(min=1))
-    gates = Nested(GateConfigSchema, required=True, many=True,
-                   validate=Length(min=1))
+    basis_gates = List(String(), required=True)
+    gates = Nested(GateConfigSchema, required=True, many=True)
     local = Boolean(required=True)
     simulator = Boolean(required=True)
     conditional = Boolean(required=True)


Test patch: