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

Issue:
commutative_cancellation removes repeated CX even though one is classically controlled
```
>> qc = qk.QuantumCircuit(3,2)
>>> qc.h(0)
<qiskit.circuit.instructionset.InstructionSet object at 0x12a19cc18>
>>> qc.measure(0,0)
<qiskit.circuit.instructionset.InstructionSet object at 0x12a19ccc0>
>>> qc.cx(1,2)
<qiskit.circuit.instructionset.InstructionSet object at 0x12a19ccf8>
>>> qc.cx(1,2).c_if(qc.cregs[0], 0)
<qiskit.circuit.instructionset.InstructionSet object at 0x12a19ccc0>
>>> qc.measure([1,2],[0,1])
<qiskit.circuit.instructionset.InstructionSet object at 0x12a19ccf8>
>>> print(qc)
        ┌───┐┌─┐
q_0: |0>┤ H ├┤M├─────────────
        └───┘└╥┘       ┌─┐
q_1: |0>──■───╫────■───┤M├───
        ┌─┴─┐ ║  ┌─┴─┐ └╥┘┌─┐
q_2: |0>┤ X ├─╫──┤ X ├──╫─┤M├
        └───┘ ║  └─┬─┘  ║ └╥┘
              ║ ┌──┴──┐ ║  ║
 c_0: 0 ══════╩═╡     ╞═╩══╬═
                │ = 0 │    ║
 c_1: 0 ════════╡     ╞════╩═
                └─────┘
>>> print(qk.transpile(qc, optimization_level=2))
        ┌───┐┌─┐
q_0: |0>┤ H ├┤M├───
        └───┘└╥┘┌─┐
q_1: |0>──────╫─┤M├
         ┌─┐  ║ └╥┘
q_2: |0>─┤M├──╫──╫─
         └╥┘  ║  ║
 c_0: 0 ══╬═══╩══╩═
          ║
 c_1: 0 ══╩════════
```


Discussion:

Resolving patch:
diff --git a/qiskit/transpiler/passes/commutation_analysis.py b/qiskit/transpiler/passes/commutation_analysis.py
--- a/qiskit/transpiler/passes/commutation_analysis.py
+++ b/qiskit/transpiler/passes/commutation_analysis.py
@@ -101,6 +101,9 @@ def _commute(node1, node2):
             for nd in [node1, node2]]):
         return False
 
+    if node1.condition or node2.condition:
+        return False
+
     qarg = list(set(node1.qargs + node2.qargs))
     qbit_num = len(qarg)
 


Test patch:
diff --git a/test/python/transpiler/test_commutative_cancellation.py b/test/python/transpiler/test_commutative_cancellation.py
--- a/test/python/transpiler/test_commutative_cancellation.py
+++ b/test/python/transpiler/test_commutative_cancellation.py
@@ -515,6 +515,20 @@ def test_cnot_cascade1(self):
 
         self.assertEqual(expected, new_circuit)
 
+    def test_conditional_gates_dont_commute(self):
+        """Conditional gates do not commute and do not cancel"""
+        circuit = QuantumCircuit(3, 2)
+        circuit.h(0)
+        circuit.measure(0, 0)
+        circuit.cx(1, 2)
+        circuit.cx(1, 2).c_if(circuit.cregs[0], 0)
+        circuit.measure([1, 2], [0, 1])
+
+        new_pm = PassManager(CommutativeCancellation())
+        new_circuit = transpile(circuit, pass_manager=new_pm)
+
+        self.assertEqual(circuit, new_circuit)
+
 
 if __name__ == '__main__':
     unittest.main()
Repository: Qiskit/qiskit

Issue:
Pulse drawer omits to plot specified channels when it is empty
<!-- ⚠️ 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?
Pulse drawer omits to plot specified channels when it is empty.


### Steps to reproduce the problem

```
from qiskit.test.mock import FakeProvider
import qiskit.pulse as pulse

provider = FakeProvider()
backend = provider.get_backend('fake_openpulse_2q')
device = pulse.DeviceSpecification.create_from(backend)

meas_pulse = pulse_lib.gaussian_square(duration=2000, amp=0.02,
                                       sigma=4, risefall=25, 
                                       name='meas_pulse')
acq_cmd=pulse.Acquire(duration=2000)

sched = pulse.Schedule(name='gnd_q12')
sched |= meas_pulse(device.q[0].measure) | acq_cmd(device.q, device.mem) << 100

sched.draw(channels_to_plot=[device.q[0].drive, device.q[0].measure],
           scaling=20.0, plot_range=(0, 200), plot_all=True)
```
The result omits to plot `d0` channel although it is specified in `channels_to_plot`.

### What is the expected behavior?
All channels specified in `channels_to_plot` should be visualized.


### Suggested solutions
qiskit.visualization.pulse.matplotlib.ScheduleDrawer._build_channels should receive `channels_to_plot`.




Discussion:

Resolving patch:
diff --git a/qiskit/visualization/pulse/matplotlib.py b/qiskit/visualization/pulse/matplotlib.py
--- a/qiskit/visualization/pulse/matplotlib.py
+++ b/qiskit/visualization/pulse/matplotlib.py
@@ -279,7 +279,7 @@ def __init__(self, style):
         """
         self.style = style or SchedStyle()
 
-    def _build_channels(self, schedule, t0, tf):
+    def _build_channels(self, schedule, channels_to_plot, t0, tf):
         # prepare waveform channels
         drive_channels = collections.OrderedDict()
         measure_channels = collections.OrderedDict()
@@ -287,7 +287,10 @@ def _build_channels(self, schedule, t0, tf):
         acquire_channels = collections.OrderedDict()
         snapshot_channels = collections.OrderedDict()
 
-        for chan in schedule.channels:
+        _channels = list(schedule.channels) + channels_to_plot
+        _channels = list(set(_channels))
+
+        for chan in _channels:
             if isinstance(chan, DriveChannel):
                 try:
                     drive_channels[chan] = EventsOutputChannels(t0, tf)
@@ -560,7 +563,7 @@ def draw(self, schedule, dt, interp_method, plot_range,
             tf = schedule.stop_time
         # prepare waveform channels
         (channels, output_channels,
-         snapshot_channels) = self._build_channels(schedule, t0, tf)
+         snapshot_channels) = self._build_channels(schedule, channels_to_plot, t0, tf)
 
         # count numbers of valid waveform
         n_valid_waveform, v_max = self._count_valid_waveforms(output_channels, scaling=scaling,


Test patch:
Repository: Qiskit/qiskit

Issue:
CmdDef from_defaults does not add buffer to channels.
<!-- ⚠️ 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?
Command definition is built with a buffer of 0 for channels.


### Steps to reproduce the problem



### What is the expected behavior?



### Suggested solutions
Add the defaults buffer to the channels when building the CmdDef.




Discussion:

Resolving patch:
diff --git a/qiskit/providers/models/pulsedefaults.py b/qiskit/providers/models/pulsedefaults.py
--- a/qiskit/providers/models/pulsedefaults.py
+++ b/qiskit/providers/models/pulsedefaults.py
@@ -134,4 +134,4 @@ def build_cmd_def(self):
         Returns:
             CmdDef: `CmdDef` instance generated from defaults
         """
-        return CmdDef.from_defaults(self.cmd_def, self.pulse_library)
+        return CmdDef.from_defaults(self.cmd_def, self.pulse_library, buffer=self.buffer)
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
@@ -65,13 +65,15 @@ def __init__(self, schedules: Optional[Dict] = None):
 
     @classmethod
     def from_defaults(cls, flat_cmd_def: List[PulseQobjInstruction],
-                      pulse_library: Dict[str, SamplePulse]) -> 'CmdDef':
+                      pulse_library: Dict[str, SamplePulse],
+                      buffer: int = 0) -> 'CmdDef':
         """Create command definition from backend defaults output.
         Args:
             flat_cmd_def: Command definition list returned by backend
             pulse_library: Dictionary of `SamplePulse`s
+            buffer: Buffer between instructions on channel
         """
-        converter = QobjToInstructionConverter(pulse_library, buffer=0)
+        converter = QobjToInstructionConverter(pulse_library, buffer=buffer)
         cmd_def = cls()
 
         for cmd in flat_cmd_def:


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
@@ -282,3 +282,6 @@ def test_build_cmd_def(self):
         u1_minus_pi = cmd_def.get('u1', 0, P1=1)
         fc_cmd = u1_minus_pi.instructions[0][-1].command
         self.assertEqual(fc_cmd.phase, np.pi)
+
+        for chan in u1_minus_pi.channels:
+            self.assertEqual(chan.buffer, defaults.buffer)
Repository: Qiskit/qiskit

Issue:
text drawer in jupyter notebook is not using a fully-monospaced font
It seems that the text drawer is not using a monospaced font when in jupyter notebooks (at least, for the black square character).
<img width="510" alt="Screen Shot 2019-07-07 at 3 52 32 PM" src="https://user-images.githubusercontent.com/766693/60773161-4f435d00-a0cf-11e9-9e68-3ccfd64ffd5c.png">
vs
```
        ┌───┐                                        ┌───┐
q_0: |0>┤ H ├──■────■────■────■────■─────────■───────┤ H ├
        ├───┤  │    │  ┌─┴─┐┌─┴─┐  │  ┌───┐  │       └───┘
q_1: |0>┤ H ├──┼────┼──┤ X ├┤ X ├──┼──┤ H ├──┼────────────
        ├───┤  │  ┌─┴─┐└───┘└───┘┌─┴─┐└───┘  │  ┌───┐     
q_2: |0>┤ H ├──┼──┤ X ├──────────┤ X ├───────┼──┤ H ├─────
        ├───┤┌─┴─┐└───┘          └───┘     ┌─┴─┐└───┘┌───┐
q_3: |0>┤ H ├┤ X ├─────────────────────────┤ X ├─────┤ H ├
        └───┘└───┘                         └───┘     └───┘
```


Discussion:

Resolving patch:
diff --git a/qiskit/visualization/text.py b/qiskit/visualization/text.py
--- a/qiskit/visualization/text.py
+++ b/qiskit/visualization/text.py
@@ -459,7 +459,9 @@ def __str__(self):
     def _repr_html_(self):
         return '<pre style="word-wrap: normal;' \
                'white-space: pre;' \
-               'line-height: 15px;">%s</pre>' % self.single_string()
+               'line-height: 15px;' \
+               'font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace">' \
+               '%s</pre>' % self.single_string()
 
     def _get_qubit_labels(self):
         qubits = []


Test patch:
diff --git a/test/python/visualization/test_circuit_text_drawer.py b/test/python/visualization/test_circuit_text_drawer.py
--- a/test/python/visualization/test_circuit_text_drawer.py
+++ b/test/python/visualization/test_circuit_text_drawer.py
@@ -539,7 +539,11 @@ def test_text_no_barriers(self):
     def test_text_measure_html(self):
         """ The measure operator. HTML representation. """
         expected = '\n'.join(["<pre style=\"word-wrap: normal;"
-                              "white-space: pre;line-height: 15px;\">        ┌─┐",
+                              "white-space: pre;"
+                              "line-height: 15px;"
+                              "font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,"
+                              "Courier,monospace\">"
+                              "        ┌─┐",
                               "q_0: |0>┤M├",
                               "        └╥┘",
                               " c_0: 0 ═╩═",
Repository: Qiskit/qiskit

Issue:
Text circuits in Jupyter misaligned
<!-- ⚠️ 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?
Following #2769 my text circuits are not aligned in Jupyter:

<img width="400" alt="Screen Shot 2019-07-18 at 9 17 11 AM" src="https://user-images.githubusercontent.com/1249193/61460581-02684d80-a93d-11e9-843b-a6ea0a344ac8.png">

verses the old way:

<img width="395" alt="Screen Shot 2019-07-18 at 9 16 59 AM" src="https://user-images.githubusercontent.com/1249193/61460604-0a27f200-a93d-11e9-86c4-761b4b73012b.png">



### Steps to reproduce the problem



### What is the expected behavior?



### Suggested solutions





Discussion:

Resolving patch:
diff --git a/qiskit/visualization/text.py b/qiskit/visualization/text.py
--- a/qiskit/visualization/text.py
+++ b/qiskit/visualization/text.py
@@ -459,8 +459,9 @@ def __str__(self):
     def _repr_html_(self):
         return '<pre style="word-wrap: normal;' \
                'white-space: pre;' \
-               'line-height: 15px;' \
-               'font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace">' \
+               'background: #fff0;' \
+               'line-height: 1.1;' \
+               'font-family: &quot;Courier New&quot;,Courier,monospace">' \
                '%s</pre>' % self.single_string()
 
     def _get_qubit_labels(self):


Test patch:
diff --git a/test/python/visualization/test_circuit_text_drawer.py b/test/python/visualization/test_circuit_text_drawer.py
--- a/test/python/visualization/test_circuit_text_drawer.py
+++ b/test/python/visualization/test_circuit_text_drawer.py
@@ -540,9 +540,9 @@ def test_text_measure_html(self):
         """ The measure operator. HTML representation. """
         expected = '\n'.join(["<pre style=\"word-wrap: normal;"
                               "white-space: pre;"
-                              "line-height: 15px;"
-                              "font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,"
-                              "Courier,monospace\">"
+                              "background: #fff0;"
+                              "line-height: 1.1;"
+                              "font-family: &quot;Courier New&quot;,Courier,monospace\">"
                               "        ┌─┐",
                               "q_0: |0>┤M├",
                               "        └╥┘",
Repository: Qiskit/qiskit

Issue:
backend_overview() returns deprecation warning
<!-- ⚠️ 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**: 0.11.0
- **Python version**: 3.7
- **Operating system**: macOS 10.14.5

### What is the current behavior?
The following code returns a deprecation warning before listing a backend overview:

```
from qiskit.tools.monitor import backend_overview
backend_overview()
```

```
DeprecationWarning: IBMQ.backends() is being deprecated. Please use IBMQ.get_provider() to retrieve a provider and AccountProvider.backends() to find its backends.
  DeprecationWarning)
```


### Steps to reproduce the problem
Run `backend_overview()`


### What is the expected behavior?
A backend overview with no deprecation warning because I didn't call `IBMQ.backends()` explicitly. The issue arises because `tools/monitor/backend_monitor.py` uses `IBMQ.backends()` in the function `get_unique_backends()` to get all the backends for which to show the overview.


### Suggested solutions
Update `tools/monitor/backend_monitor.py` to account for providers.




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
@@ -35,7 +35,10 @@ def get_unique_backends():
     Raises:
         QiskitError: No backends available.
     """
-    backends = IBMQ.backends()
+    backends = []
+    for provider in IBMQ.providers():
+        for backend in provider.backends():
+            backends.append(backend)
     unique_hardware_backends = []
     unique_names = []
     for back in backends:


Test patch:
Repository: Qiskit/qiskit

Issue:
[Requires Aer 0.2] BackendSchema list coupling_map as optional
<!-- ⚠️ 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?
The schemas in `qiskit.providers.model` list `coupling_map` as an optional field in the `backend.configuration` when it is in fact required.


### Steps to reproduce the problem



### What is the expected behavior?



### Suggested solutions





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
@@ -80,13 +80,12 @@ class BackendConfigurationSchema(BaseSchema):
     open_pulse = Boolean(required=True)
     memory = Boolean(required=True)
     max_shots = Integer(required=True, validate=Range(min=1))
+    coupling_map = List(List(Integer(), validate=Length(min=1)),
+                        validate=Length(min=1), allow_none=True, required=True)
 
     # Optional properties.
     max_experiments = Integer(validate=Range(min=1))
     sample_name = String()
-    coupling_map = List(List(Integer(),
-                             validate=Length(min=1)),
-                        validate=Length(min=1), allow_none=True)
     n_registers = Integer(validate=Range(min=1))
     register_map = List(List(Integer(validate=OneOf([0, 1])),
                              validate=Length(min=1)),


Test patch:
diff --git a/qiskit/test/mock.py b/qiskit/test/mock.py
--- a/qiskit/test/mock.py
+++ b/qiskit/test/mock.py
@@ -170,6 +170,7 @@ def __init__(self):
             basis_gates=['u1', 'u2', 'u3', 'cx', 'cz', 'id', 'x', 'y', 'z',
                          'h', 's', 'sdg', 't', 'tdg', 'ccx', 'swap',
                          'snapshot', 'unitary'],
+            coupling_map=None,
             simulator=True,
             local=True,
             conditional=True,
Repository: Qiskit/qiskit

Issue:
Long qubit name is not visible in latex drawer
<!-- ⚠️ 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**: 3.5
- **Operating system**: MacOS

### What is the current behavior?

In a Jupyter notebook:

```python
from qiskit import QuantumRegister, QuantumCircuit
qr = QuantumRegister(4, 'looongname')
circuit = QuantumCircuit(qr)
circuit.h(qr)
circuit.draw(output='latex')
```
<img width="537" alt="Screen Shot 2019-07-12 at 3 13 11 PM" src="https://user-images.githubusercontent.com/766693/61152884-95c1fe80-a4b7-11e9-8900-ab5307100741.png">





Discussion:

Resolving patch:
diff --git a/qiskit/visualization/latex.py b/qiskit/visualization/latex.py
--- a/qiskit/visualization/latex.py
+++ b/qiskit/visualization/latex.py
@@ -276,8 +276,14 @@ def _get_image_depth(self):
         # the wires poking out at the ends is 2 more
         sum_column_widths = sum(1 + v / 3 for v in max_column_widths)
 
+        max_reg_name = 3
+        for reg in self.ordered_regs:
+            max_reg_name = max(max_reg_name,
+                               len(reg.register.name))
+        sum_column_widths += 5 + max_reg_name / 3
+
         # could be a fraction so ceil
-        return columns, math.ceil(sum_column_widths) + 4
+        return columns, math.ceil(sum_column_widths)
 
     def _get_beamer_page(self):
         """Get height, width & scale attributes for the beamer page.


Test patch:
Repository: Qiskit/qiskit

Issue:
MPL drawer does not handle unitaries well
<!-- ⚠️ 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?
<img width="1003" alt="Screen Shot 2019-06-25 at 12 51 45 PM" src="https://user-images.githubusercontent.com/1249193/60117470-1eb30900-9748-11e9-9d12-1451d8cea41d.png">

vs

<img width="368" alt="Screen Shot 2019-06-25 at 12 52 13 PM" src="https://user-images.githubusercontent.com/1249193/60117475-21156300-9748-11e9-98d2-f6f80a89f0fe.png">



### Steps to reproduce the problem



### What is the expected behavior?



### Suggested solutions





Discussion:
I've got a fix for this, I'll push up a PR shortly.

Resolving patch:
diff --git a/qiskit/visualization/matplotlib.py b/qiskit/visualization/matplotlib.py
--- a/qiskit/visualization/matplotlib.py
+++ b/qiskit/visualization/matplotlib.py
@@ -555,7 +555,7 @@ def _draw_regs_sub(self, n_fold, feedline_l=False, feedline_r=False):
                                  - n_fold * (self._cond['n_lines'] + 1)))
 
     def _draw_ops(self, verbose=False):
-        _wide_gate = ['u2', 'u3', 'cu2', 'cu3']
+        _wide_gate = ['u2', 'u3', 'cu2', 'cu3', 'unitary']
         _barriers = {'coord': [], 'group': []}
 
         #


Test patch:
Repository: Qiskit/qiskit

Issue:
Remove the ability to set timeslots explicitly for an Instruction
<!-- ⚠️ 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?
 Remove the ability to explicitly set Timeslot's for of instruction, these should solely be derived fro the underlying `Command`. If it is truly necessary to set a non-standard Timeslot representation, this can be done by overriding the behaviour of the respective instruction.



Discussion:

Resolving patch:
diff --git a/qiskit/pulse/commands/instruction.py b/qiskit/pulse/commands/instruction.py
--- a/qiskit/pulse/commands/instruction.py
+++ b/qiskit/pulse/commands/instruction.py
@@ -21,7 +21,6 @@
 from qiskit.pulse.interfaces import ScheduleComponent
 from qiskit.pulse.schedule import Schedule
 from qiskit.pulse.timeslots import Interval, Timeslot, TimeslotCollection
-from qiskit.pulse.exceptions import PulseError
 
 # pylint: disable=missing-return-doc,missing-type-doc
 
@@ -30,31 +29,20 @@ class Instruction(ScheduleComponent):
     """An abstract class for leaf nodes of schedule."""
 
     def __init__(self, command, *channels: List[Channel],
-                 timeslots: Optional[TimeslotCollection] = None,
                  name: Optional[str] = None):
         """
         Args:
             command: Pulse command to schedule
             *channels: List of pulse channels to schedule with command
-            timeslots: Optional list of timeslots. If channels are supplied timeslots
-                cannot also be given
             name: Name of Instruction
-
-        Raises:
-            PulseError: If both channels and timeslots are supplied
         """
         self._command = command
         self._name = name if name else self._command.name
 
-        if timeslots and channels:
-            raise PulseError('Channels and timeslots may not both be supplied.')
+        duration = command.duration
 
-        if not timeslots:
-            duration = command.duration
-            self._timeslots = TimeslotCollection(*(Timeslot(Interval(0, duration), channel)
-                                                   for channel in channels))
-        else:
-            self._timeslots = timeslots
+        self._timeslots = TimeslotCollection(*(Timeslot(Interval(0, duration), channel)
+                                               for channel in channels))
 
         channels = self.channels
 


Test patch: