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

Issue:
cu3 definition in qiskit/qasm/libs/qelib1.inc is inconsistent
<!-- ⚠️ 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?
have consistent cu3 definition.
The cu3 defintion of the following file is not consistent with recent changes.
https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/qasm/libs/qelib1.inc

https://github.com/Qiskit/qiskit-terra/commit/02e4309104d28765d598e7aee7510d75e5d6467f

### Suggested solutions
update the qelib1.inc to align cu3 definition




Discussion:

Resolving patch:
diff --git a/qiskit/extensions/standard/cu3.py b/qiskit/extensions/standard/cu3.py
--- a/qiskit/extensions/standard/cu3.py
+++ b/qiskit/extensions/standard/cu3.py
@@ -35,8 +35,11 @@ def __init__(self, theta, phi, lam):
     def _define(self):
         """
         gate cu3(theta,phi,lambda) c, t
-        { u1((lambda+phi)/2) c; u1((lambda-phi)/2) t; cx c,t;
-          u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t;
+        { u1((lambda+phi)/2) c;
+          u1((lambda-phi)/2) t;
+          cx c,t;
+          u3(-theta/2,0,-(phi+lambda)/2) t;
+          cx c,t;
           u3(theta/2,phi,0) t;
         }
         """


Test patch:
diff --git a/test/python/test_qasm_parser.py b/test/python/test_qasm_parser.py
--- a/test/python/test_qasm_parser.py
+++ b/test/python/test_qasm_parser.py
@@ -47,10 +47,10 @@ def test_parser(self):
         res = parse(self.qasm_file_path)
         self.log.info(res)
         # TODO: For now only some basic checks.
-        self.assertEqual(len(res), 1563)
+        self.assertEqual(len(res), 1589)
         self.assertEqual(res[:12], "OPENQASM 2.0")
         self.assertEqual(res[14:41], "gate u3(theta,phi,lambda) q")
-        self.assertEqual(res[1547:1562], "measure r -> d;")
+        self.assertEqual(res[1573:1588], "measure r -> d;")
 
     def test_parser_fail(self):
         """should fail a for a  not valid circuit."""
Repository: Qiskit/qiskit

Issue:
QuantumCircuit().depth()  fails unexpected
### Information

- **Qiskit Terra version**: master
- **Python version**: 3.7

### What is the current behavior?

```
>>> QuantumCircuit().depth()                                                                                                             
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-2311736f2964> in <module>
----> 1 QuantumCircuit().depth()

~/repos/qiskit-terra/qiskit/circuit/quantumcircuit.py in depth(self)
    945                 op_stack[ind] = max_level
    946 
--> 947         return max(op_stack)
    948 
    949     def width(self):

ValueError: max() arg is an empty sequence
```

### Steps to reproduce the problem

Create an empty circuit and run `depth()` on it.

### What is the expected behavior?

`depth()` of an empty circuit should be 0

### Suggested solutions

Maybe, `op_stack` should have a default element as `0`. So `max(op_stack)` will return the right value.




Discussion:

Resolving patch:
diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py
--- a/qiskit/circuit/quantumcircuit.py
+++ b/qiskit/circuit/quantumcircuit.py
@@ -901,6 +901,10 @@ def depth(self):
             reg_map[reg.name] = reg_offset
             reg_offset += reg.size
 
+        # If no registers return 0
+        if reg_offset == 0:
+            return 0
+
         # A list that holds the height of each qubit
         # and classical bit.
         op_stack = [0] * reg_offset


Test patch:
diff --git a/test/python/circuit/test_circuit_properties.py b/test/python/circuit/test_circuit_properties.py
--- a/test/python/circuit/test_circuit_properties.py
+++ b/test/python/circuit/test_circuit_properties.py
@@ -33,6 +33,12 @@ def test_circuit_depth_empty(self):
         qc = QuantumCircuit(q)
         self.assertEqual(qc.depth(), 0)
 
+    def test_circuit_depth_no_reg(self):
+        """Test depth of no register circuits
+        """
+        qc = QuantumCircuit()
+        self.assertEqual(qc.depth(), 0)
+
     def test_circuit_depth_meas_only(self):
         """Test depth of measurement only
         """
Repository: Qiskit/qiskit

Issue:
PulseBackendConfiguration cannot return control channels
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### What is the current behavior?
There is no link between qubit index and channel index for ibmq backend, but `PulseBackendConfiguration` forces to put identical index to them and it doesn't return control channel with index larger than maximum qubit number.


### Steps to reproduce the problem
```python
back_config.control(23)
```
raises `BackendConfigurationError` when 20 qubit backends is loaded.

### What is the expected behavior?
It should not raise an error.


### Suggested solutions
Replace argument name by `channel` and remove error.



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
@@ -385,22 +385,18 @@ def acquire(self, qubit: int) -> AcquireChannel:
             raise BackendConfigurationError("This system does not have {} qubits.".format(qubit))
         return AcquireChannel(qubit)
 
-    def control(self, qubit: int) -> ControlChannel:
+    def control(self, channel: int) -> ControlChannel:
         """
         Return the secondary drive channel for the given qubit -- typically utilized for
         controlling multiqubit interactions. This channel is derived from other channels.
 
-        Raises:
-            BackendConfigurationError: If the qubit is not a part of the system.
         Returns:
             Qubit control channel.
         """
         # TODO: Determine this from the hamiltonian.
         warnings.warn("The control channel appropriate for an interaction should be determined "
                       "from the hamiltonian. This will be determined for you in the future.")
-        if qubit > self.n_qubits:
-            raise BackendConfigurationError("This system does not have {} qubits.".format(qubit))
-        return ControlChannel(qubit)
+        return ControlChannel(channel)
 
     def describe(self, channel: ControlChannel) -> Dict[DriveChannel, complex]:
         """


Test patch:
Repository: Qiskit/qiskit

Issue:
Can't invert gate created from QuantumCircuit.to_gate
<!-- ⚠️ 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?
When inverting a gate created from QuantumCircuit.to_gate the following exception is raised:

`ValueError: not enough values to unpack (expected 3, got 2)`


### Steps to reproduce the problem
```
qc = QuantumCircuit(1)
qc.x(0)
gate = qc.to_gate()
gate.inverse()
```

### What is the expected behavior?



### Suggested solutions





Discussion:

Resolving patch:
diff --git a/qiskit/converters/circuit_to_gate.py b/qiskit/converters/circuit_to_gate.py
--- a/qiskit/converters/circuit_to_gate.py
+++ b/qiskit/converters/circuit_to_gate.py
@@ -81,9 +81,14 @@ def find_bit_position(bit):
     if gate.num_qubits > 0:
         q = QuantumRegister(gate.num_qubits, 'q')
 
-    definition = list(map(lambda x:
-                          (x[0], list(map(lambda y: q[find_bit_position(y)], x[1]))),
-                          definition))
+    # The 3rd parameter in the output tuple) is hard coded to [] because
+    # Gate objects do not have cregs set and we've verified that all
+    # instructions are gates
+    definition = list(map(
+        lambda x: (x[0],
+                   list(map(lambda y: q[find_bit_position(y)], x[1])),
+                   []),
+        definition))
     gate.definition = definition
 
     return gate


Test patch:
diff --git a/test/python/converters/test_circuit_to_gate.py b/test/python/converters/test_circuit_to_gate.py
--- a/test/python/converters/test_circuit_to_gate.py
+++ b/test/python/converters/test_circuit_to_gate.py
@@ -56,3 +56,13 @@ def test_raises(self):
 
         with self.assertRaises(QiskitError):  # measure and reset are not valid
             circ2.to_gate()
+
+    def test_generated_gate_inverse(self):
+        """Test inverse of generated gate works."""
+        qr1 = QuantumRegister(2, 'qr1')
+        circ = QuantumCircuit(qr1)
+        circ.cx(qr1[1], qr1[0])
+
+        gate = circ.to_gate()
+        out_gate = gate.inverse()
+        self.assertIsInstance(out_gate, Gate)
Repository: Qiskit/qiskit

Issue:
Add one time warning when calling dt that it has changed from ns to s
<!-- ⚠️ 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?
Recently `dt` in the pulse configuration has changed from `ns` to `s`. A warning that is emitted once per-call should be added.




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
@@ -14,6 +14,7 @@
 
 """Model and schema for backend configuration."""
 from typing import Dict, List
+import warnings
 
 from marshmallow.validate import Length, OneOf, Range, Regexp
 
@@ -266,6 +267,8 @@ class PulseBackendConfiguration(BackendConfiguration):
     about the set up of the device which can be useful for building Pulse programs.
     """
 
+    _dt_warning_done = False
+
     def __init__(self,
                  backend_name: str,
                  backend_version: str,
@@ -329,6 +332,12 @@ def __init__(self,
         self.discriminators = discriminators
         self.hamiltonian = hamiltonian
 
+        # only raise dt/dtm warning once
+        if not PulseBackendConfiguration._dt_warning_done:
+            warnings.warn('`dt` and `dtm` now have units of seconds(s) rather '
+                          'than nanoseconds(ns).')
+            PulseBackendConfiguration._dt_warning_done = True
+
         super().__init__(backend_name=backend_name, backend_version=backend_version,
                          n_qubits=n_qubits, basis_gates=basis_gates, gates=gates,
                          local=local, simulator=simulator, conditional=conditional,


Test patch:
Repository: Qiskit/qiskit

Issue:
drawing `unitary` gates in mpl messed up
There are huge gaps when drawing "unitary" gates. Also the box should say "unitary" (which is the `gate.name`), exactly like what latex and text drawers do. 

The fix should be patched on stable.

```
from qiskit import QuantumCircuit
from qiskit.quantum_info.random import random_unitary
circ = QuantumCircuit(2)
circ.unitary(random_unitary(4), [0,1])
circ.unitary(random_unitary(4), [0,1])
circ.draw(output='mpl')
```
![image](https://user-images.githubusercontent.com/8622381/70767542-bb398980-1d2f-11ea-8aae-b79296aeb2e1.png)



Discussion:
Hi @ajavadia . Do you think this is will do?
![corrected](https://user-images.githubusercontent.com/51048173/71231439-f7fb1700-2313-11ea-9e5d-39efed4bd87d.png)

Yes this looks good

> On Dec 20, 2019, at 12:02 AM, Tharrmashastha SAPV <notifications@github.com> wrote:
> 
> Hi @ajavadia . Do you think this is will do?
> 
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or unsubscribe.


Resolving patch:
diff --git a/qiskit/visualization/matplotlib.py b/qiskit/visualization/matplotlib.py
--- a/qiskit/visualization/matplotlib.py
+++ b/qiskit/visualization/matplotlib.py
@@ -189,9 +189,9 @@ def _custom_multiqubit_gate(self, xy, cxy=None, fc=None, wide=True, text=None,
             ypos = min([y[1] for y in cxy])
         if wide:
             if subtext:
-                boxes_length = round(max([len(text), len(subtext)]) / 6) or 1
+                boxes_length = round(max([len(text), len(subtext)]) / 7) or 1
             else:
-                boxes_length = math.ceil(len(text) / 6) or 1
+                boxes_length = math.ceil(len(text) / 7) or 1
             wid = WID * 2.5 * boxes_length
         else:
             wid = WID
@@ -682,6 +682,8 @@ def _draw_ops(self, verbose=False):
                             len_param = len(param)
                         if len_param > len(op.name):
                             box_width = math.floor(len(param) / 10)
+                            if op.name == 'unitary':
+                                box_width = 2
                             # If more than 4 characters min width is 2
                             if box_width <= 1:
                                 box_width = 2
@@ -836,7 +838,7 @@ def _draw_ops(self, verbose=False):
                     # TODO(mtreinish): Look into adding the unitary to the
                     # subtext
                     self._custom_multiqubit_gate(q_xy, wide=_iswide,
-                                                 text="U")
+                                                 text="Unitary")
                 #
                 # draw single qubit gates
                 #


Test patch:
Repository: Qiskit/qiskit

Issue:
Operator.transpose fails for rectangular operators
<!-- ⚠️ 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?

`Operator.transpose` doesn't swap input and output operator dimensions, which causes a failure for non-square operators.

### Steps to reproduce the problem

```python
op = Operator([[0, 1, 2, 3]])
op.transpose()
``


Discussion:

Resolving patch:
diff --git a/qiskit/quantum_info/operators/operator.py b/qiskit/quantum_info/operators/operator.py
--- a/qiskit/quantum_info/operators/operator.py
+++ b/qiskit/quantum_info/operators/operator.py
@@ -171,13 +171,15 @@ def to_instruction(self):
 
     def conjugate(self):
         """Return the conjugate of the operator."""
-        return Operator(
-            np.conj(self.data), self.input_dims(), self.output_dims())
+        return Operator(np.conj(self.data),
+                        input_dims=self.input_dims(),
+                        output_dims=self.output_dims())
 
     def transpose(self):
         """Return the transpose of the operator."""
-        return Operator(
-            np.transpose(self.data), self.input_dims(), self.output_dims())
+        return Operator(np.transpose(self.data),
+                        input_dims=self.output_dims(),
+                        output_dims=self.input_dims())
 
     def compose(self, other, qargs=None, front=False):
         """Return the composition channel self∘other.


Test patch:
diff --git a/test/python/quantum_info/operators/test_operator.py b/test/python/quantum_info/operators/test_operator.py
--- a/test/python/quantum_info/operators/test_operator.py
+++ b/test/python/quantum_info/operators/test_operator.py
@@ -279,24 +279,24 @@ def test_to_operator(self):
 
     def test_conjugate(self):
         """Test conjugate method."""
-        matr = self.rand_matrix(2, 2, real=True)
-        mati = self.rand_matrix(2, 2, real=True)
+        matr = self.rand_matrix(2, 4, real=True)
+        mati = self.rand_matrix(2, 4, real=True)
         op = Operator(matr + 1j * mati)
         uni_conj = op.conjugate()
         self.assertEqual(uni_conj, Operator(matr - 1j * mati))
 
     def test_transpose(self):
         """Test transpose method."""
-        matr = self.rand_matrix(2, 2, real=True)
-        mati = self.rand_matrix(2, 2, real=True)
+        matr = self.rand_matrix(2, 4, real=True)
+        mati = self.rand_matrix(2, 4, real=True)
         op = Operator(matr + 1j * mati)
         uni_t = op.transpose()
         self.assertEqual(uni_t, Operator(matr.T + 1j * mati.T))
 
     def test_adjoint(self):
         """Test adjoint method."""
-        matr = self.rand_matrix(2, 2, real=True)
-        mati = self.rand_matrix(2, 2, real=True)
+        matr = self.rand_matrix(2, 4, real=True)
+        mati = self.rand_matrix(2, 4, real=True)
         op = Operator(matr + 1j * mati)
         uni_adj = op.adjoint()
         self.assertEqual(uni_adj, Operator(matr.T - 1j * mati.T))
Repository: Qiskit/qiskit

Issue:
Job watcher cancel button shows as '...' in chrome
<!-- ⚠️ 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, ipywidgets-7.4.2
- **Operating system**: mac

### What is the current behavior?

For notebooks run both from IQX and local jupyter instance:

In Chrome:
<img width="741" alt="image" src="https://user-images.githubusercontent.com/2241698/72166111-a552cf00-3396-11ea-9783-a653ae96efb7.png">

In Firefox:
<img width="741" alt="image" src="https://user-images.githubusercontent.com/2241698/72166070-91a76880-3396-11ea-997c-6c1a47dd1448.png">

### Steps to reproduce the problem

### What is the expected behavior?

### Suggested solutions
In the DOM explorer, increasing the button width above 30px restores the 'X' icon.


Discussion:

Resolving patch:
diff --git a/qiskit/tools/jupyter/job_widgets.py b/qiskit/tools/jupyter/job_widgets.py
--- a/qiskit/tools/jupyter/job_widgets.py
+++ b/qiskit/tools/jupyter/job_widgets.py
@@ -67,7 +67,7 @@ def make_labels():
 
     labels = widgets.HBox(children=[labels0, labels1, labels2, labels3, labels4],
                           layout=widgets.Layout(width='600px',
-                                                margin='0px 0px 0px 35px'))
+                                                margin='0px 0px 0px 37px'))
     return labels
 
 
@@ -104,7 +104,7 @@ def create_job_widget(watcher, job, backend, status='', queue_pos=None, msg=''):
                              layout=widgets.Layout(overflow_x='scroll'))
 
     close_button = widgets.Button(button_style='', icon='close',
-                                  layout=widgets.Layout(width='30px',
+                                  layout=widgets.Layout(width='32px',
                                                         margin="0px 5px 0px 0px"))
     close_button.style.button_color = 'white'
 


Test patch:
Repository: Qiskit/qiskit

Issue:
MPL drawer CU1 gate is inconsistent with other drawers
<!-- ⚠️ 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**: Mac OS 10.15.1

### What is the current behavior?
```
circuit = QuantumCircuit(2)
theta = numpy.pi/2
circuit.cu1(theta,0,1)
circuit.draw()
```
Output-
```            
q_0: |0>─■─────
         │pi/2 
q_1: |0>─■─────
```
However, mpl shows fine-
![image](https://user-images.githubusercontent.com/6925028/71787125-8a204200-2fd9-11ea-9a9a-2826e2fafbf4.png)

### Steps to reproduce the problem
Paste the above code in Jupyter notebook and run.


### What is the expected behavior?
The text drawer should show up like this-
```            
q_0: |0>─────■──────
        ┌────┴─────┐
q_1: |0>┤ U1(pi/2) ├
        └──────────┘
```

### Suggested solutions

Fix is provided below in the PR by making changes in qiskit/visualization/text.py



Discussion:

Resolving patch:
diff --git a/qiskit/visualization/matplotlib.py b/qiskit/visualization/matplotlib.py
--- a/qiskit/visualization/matplotlib.py
+++ b/qiskit/visualization/matplotlib.py
@@ -910,7 +910,7 @@ def _draw_ops(self, verbose=False):
                         else:
                             self._line(qreg_b, qreg_t, zorder=PORDER_LINE + 1)
                     # control gate
-                    elif op.name in ['cy', 'ch', 'cu3', 'cu1', 'crz']:
+                    elif op.name in ['cy', 'ch', 'cu3', 'crz']:
                         disp = op.name.replace('c', '')
 
                         color = None
@@ -937,6 +937,16 @@ def _draw_ops(self, verbose=False):
 
                         # add qubit-qubit wiring
                         self._line(qreg_b, qreg_t)
+
+                    # cu1 gate
+                    elif op.name == 'cu1':
+                        self._ctrl_qubit(q_xy[0])
+                        self._ctrl_qubit(q_xy[1])
+                        self._sidetext(qreg_b, text='U1 ({})'.format(param))
+
+                        # add qubit-qubit wiring
+                        self._line(qreg_b, qreg_t)
+
                     # swap gate
                     elif op.name == 'swap':
                         self._swap(q_xy[0])


Test patch:
Repository: Qiskit/qiskit

Issue:
QuantumCircuit.draw() does not draw circuit in terminal
<!-- ⚠️ 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?

Currently returns a `<qiskit.visualization.text.TextDrawing>`.  However, it should print to the terminal because it is an explicit command to draw the circuit.

### Steps to reproduce the problem



### What is the expected behavior?



### Suggested solutions





Discussion:
hi, can you share the code to replicate the problem , i would like to look into it if you are okay with it 
Anything really:
```python
from qiskit import *
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0,1], [0,1])
qc.draw()
```
i just checked in my jupyter lab, its perfectly working

![Untitled](https://user-images.githubusercontent.com/57726155/72561347-0450a080-38cf-11ea-8ade-944c4d060a76.png)



From the terminal, not Jupyter:

<img width="574" alt="Screen Shot 2020-01-16 at 3 51 31 PM" src="https://user-images.githubusercontent.com/1249193/72561870-23701380-3878-11ea-92d0-f468e839721c.png">



Resolving patch:
diff --git a/qiskit/visualization/text.py b/qiskit/visualization/text.py
--- a/qiskit/visualization/text.py
+++ b/qiskit/visualization/text.py
@@ -501,6 +501,9 @@ def _repr_html_(self):
                'font-family: &quot;Courier New&quot;,Courier,monospace">' \
                '%s</pre>' % self.single_string()
 
+    def __repr__(self):
+        return self.single_string()
+
     def single_string(self):
         """Creates a long string with the ascii art.
 


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
@@ -587,6 +587,19 @@ def test_text_measure_html(self):
         circuit.measure(qr, cr)
         self.assertEqual(_text_circuit_drawer(circuit)._repr_html_(), expected)
 
+    def test_text_repr(self):
+        """ The measure operator. repr. """
+        expected = '\n'.join(["        ┌─┐",
+                              "q_0: |0>┤M├",
+                              "        └╥┘",
+                              " c_0: 0 ═╩═",
+                              "           "])
+        qr = QuantumRegister(1, 'q')
+        cr = ClassicalRegister(1, 'c')
+        circuit = QuantumCircuit(qr, cr)
+        circuit.measure(qr, cr)
+        self.assertEqual(_text_circuit_drawer(circuit).__repr__(), expected)
+
     def test_text_justify_left(self):
         """ Drawing with left justify """
         expected = '\n'.join(['         ┌───┐   ',