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

Issue:
Registers copied by reference
<!-- ⚠️ 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.13.0
- **Python version**: 3.7.5
- **Operating system**: MacOS Catalina

### What is the current behavior?

The registers in the circuit are copied via reference. Modifying the registers in the copied circuit changes the original circuit.

Note that this causes Aqua algorithms such as the VQE to fail, if passed a quantum circuit and run on the QASM simulator. This happens because the Algorithm may add a classical register called `'c'` to a copy of the Ansatz wavefunction multiple times, but since the original circuit is modified, the adding fails as a register called `'c'` already exists.

### Steps to reproduce the problem

```python
circuit = QuantumCircuit(1)
circuit.x(0)
copied = circuit.copy()
copied.add_register(ClassicalRegister(1, name='c'))
print(circuit.cregs)
```
produces
```
[ClassicalRegister(1, 'c')]
```

### What is the expected behavior?

Copy `qregs` and `cregs`.

### Suggested solutions

```python
        # L1176 in quantumcircuit.py
        cpy = copy.copy(self)
        cpy.qregs = self.qregs.copy()
        cpy.cregs = self.cregs.copy()
```



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
@@ -1154,6 +1154,9 @@ def copy(self, name=None):
         """
 
         cpy = copy.copy(self)
+        # copy registers correctly, in copy.copy they are only copied via reference
+        cpy.qregs = self.qregs.copy()
+        cpy.cregs = self.cregs.copy()
 
         instr_instances = {id(instr): instr
                            for instr, _, __ in self.data}


Test patch:
diff --git a/test/python/circuit/test_circuit_operations.py b/test/python/circuit/test_circuit_operations.py
--- a/test/python/circuit/test_circuit_operations.py
+++ b/test/python/circuit/test_circuit_operations.py
@@ -174,6 +174,20 @@ def test_copy_circuit(self):
 
         self.assertEqual(qc, qc.copy())
 
+    def test_copy_copies_registers(self):
+        """Test copy copies the registers not via reference."""
+        qc = QuantumCircuit(1, 1)
+        copied = qc.copy()
+
+        copied.add_register(QuantumRegister(1, 'additional_q'))
+        copied.add_register(ClassicalRegister(1, 'additional_c'))
+
+        self.assertEqual(len(qc.qregs), 1)
+        self.assertEqual(len(copied.qregs), 2)
+
+        self.assertEqual(len(qc.cregs), 1)
+        self.assertEqual(len(copied.cregs), 2)
+
     def test_measure_active(self):
         """Test measure_active
         Applies measurements only to non-idle qubits. Creates a ClassicalRegister of size equal to
Repository: Qiskit/qiskit

Issue:
random_clifford(n) fails to sample the whole Clifford group
<!-- ⚠️ 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.13.0
- **Python version**: 3.8.2
- **Operating system**: Windows 10

### What is the current behavior?
`random_clifford` fails to generate some elements from the whole Clifford group. For example, `random_clifford(1)` only generates Cliffords with stabilizer `+Z`, `-Z`, `+Y`, or `-Y`, and `random_clifford(2)` never samples Clifford with stabilizer `[+XI, +IX]`, etc.   

### Steps to reproduce the problem
```
from qiskit.quantum_info import Clifford, random_clifford
for r in range(100):
    cliff = random_clifford(1)
    print(cliff)
```
The output is
```
Clifford: Stabilizer = ['-Z'], Destabilizer = ['-X']
Clifford: Stabilizer = ['+Y'], Destabilizer = ['+X']
Clifford: Stabilizer = ['-Y'], Destabilizer = ['+X']
Clifford: Stabilizer = ['-Z'], Destabilizer = ['-X']
Clifford: Stabilizer = ['+Z'], Destabilizer = ['-X']
Clifford: Stabilizer = ['+Z'], Destabilizer = ['-X']
Clifford: Stabilizer = ['+Y'], Destabilizer = ['+X']
Clifford: Stabilizer = ['-Y'], Destabilizer = ['+X']
Clifford: Stabilizer = ['+Y'], Destabilizer = ['+X']
...
```
The case `Stabilizer = ['+X']` never happens. In other words, the **Hadamard gate** is never sampled.

Similarly, `random_clifford(2)` never generates the case `Stabilizer = [+IX, +XI] `. This bug also exists for larger number of qubits. 

### What is the expected behavior?

`random_clifford` should uniformly sample the whole Clifford group. Otherwise, some protocols based on random circuits would fail, e.g. quantum compressed sensing, randomized benchmarking.

### Suggested solutions

Maybe to check whether the algorithm in arXiv:2003.09412 is correctly implemented.




Discussion:

Resolving patch:
diff --git a/qiskit/quantum_info/operators/symplectic/random.py b/qiskit/quantum_info/operators/symplectic/random.py
--- a/qiskit/quantum_info/operators/symplectic/random.py
+++ b/qiskit/quantum_info/operators/symplectic/random.py
@@ -151,7 +151,7 @@ def _sample_qmallows(n, rng=None):
         m = n - i
         eps = 4 ** (-m)
         r = rng.uniform(0, 1)
-        index = int(np.ceil(np.log2(1 + (1 - r) * eps)))
+        index = -int(np.ceil(np.log2(r + (1 - r) * eps)))
         had[i] = index < m
         if index < m:
             k = index


Test patch:
Repository: Qiskit/qiskit

Issue:
Typo in Ry Class Doc
## Did you find a doc bug or broken link that needs to be fixed?
Yes.
- What is the file name(s) where you found the bug?
qiskit-terra/qiskit/extensions/standard/ry.py 
- What is the current text that needs to be fixed or removed? (You can copy and paste)
RX(\theta) = exp(-i \th Y)
- What should the documentation say instead?
RY(\theta) = exp(-i \th Y)
- Are there other related issues or pull requests about this bug?

## Does existing documentation need to be updated with new content?

- Which files need to be updated?

- What content needs to be updated or replaced? (You can copy and paste)

- What new content needs to be added?



Discussion:

Resolving patch:
diff --git a/qiskit/extensions/standard/ry.py b/qiskit/extensions/standard/ry.py
--- a/qiskit/extensions/standard/ry.py
+++ b/qiskit/extensions/standard/ry.py
@@ -42,7 +42,7 @@ class RYGate(Gate):
 
         \newcommand{\th}{\frac{\theta}{2}}
 
-        RX(\theta) = exp(-i \th Y) =
+        RY(\theta) = exp(-i \th Y) =
             \begin{pmatrix}
                 \cos{\th} & -\sin{\th} \\
                 \sin{\th} & \cos{\th}


Test patch:
Repository: Qiskit/qiskit

Issue:
initial_state=False is not honored by latex drawer in the classical wires
When latex drawer is called with `initial_state=False` the initial state of the classical wires is still there at it should be removed, as the other drawers.
```python
from qiskit import *
qr = QuantumRegister(3, 'q')
cr = ClassicalRegister(3, 'c')
circuit = QuantumCircuit(qr, cr)
circuit.measure(qr, cr)
circuit.draw('latex', initial_state=False)
```
![image](https://user-images.githubusercontent.com/766693/80411417-2e383c80-889a-11ea-97a2-f0ae8edd6dd7.png)

The expected result would be
<img width="427" alt="Screen Shot 2020-04-27 at 3 10 31 PM" src="https://user-images.githubusercontent.com/766693/80411454-3abc9500-889a-11ea-9e9b-b445c96dda01.png">



Discussion:
I'll try and take a shot at this (this is my first issue)

Resolving patch:
diff --git a/qiskit/visualization/latex.py b/qiskit/visualization/latex.py
--- a/qiskit/visualization/latex.py
+++ b/qiskit/visualization/latex.py
@@ -211,8 +211,10 @@ def _initialize_latex_array(self, aliases=None):
         for i in range(self.img_width):
             if self.wire_type[self.ordered_regs[i]]:
                 self._latex[i][0] = "\\lstick{" + self.ordered_regs[i].register.name + \
-                                    "_{" + str(self.ordered_regs[i].index) + "}" + \
-                                    ": 0}"
+                                    "_{" + str(self.ordered_regs[i].index) + "}" + ": "
+                if self.initial_state:
+                    self._latex[i][0] += "0"
+                self._latex[i][0] += "}"
             else:
                 if self.layout is None:
                     label = "\\lstick{{ {{{}}}_{{{}}} : ".format(


Test patch:
Repository: Qiskit/qiskit

Issue:
pass_manager_drawer requires filename to render
<!-- ⚠️ 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 `pass_manager_drawer` requires a filename in order to run.  However this is not really a requirement of the code itself.  Indeed, this works fine:
```python
pass_manager_drawer(pm, '')
```


### Steps to reproduce the problem



### What is the expected behavior?



### Suggested solutions





Discussion:

Resolving patch:
diff --git a/qiskit/visualization/pass_manager_visualization.py b/qiskit/visualization/pass_manager_visualization.py
--- a/qiskit/visualization/pass_manager_visualization.py
+++ b/qiskit/visualization/pass_manager_visualization.py
@@ -35,7 +35,7 @@
                  TransformationPass: 'blue'}
 
 
-def pass_manager_drawer(pass_manager, filename, style=None, raw=False):
+def pass_manager_drawer(pass_manager, filename=None, style=None, raw=False):
     """
     Draws the pass manager.
 


Test patch:
Repository: Qiskit/qiskit

Issue:
Manual for TGate is missing
## Did you find a doc bug or broken link that needs to be fixed?

- What is the file name(s) where you found the bug?

https://qiskit.org/documentation/apidoc/circuit_library.html#standard-gates

- What is the current text that needs to be fixed or removed? (You can copy and paste)

There is no page for TGate, while SGate and TdgGate are available.

- What should the documentation say instead?

TGate should be included in the page.

- Are there other related issues or pull requests about this bug?

No.

## Does existing documentation need to be updated with new content?

- Which files need to be updated?

https://qiskit.org/documentation/apidoc/circuit_library.html#standard-gates

- What content needs to be updated or replaced? (You can copy and paste)

- What new content needs to be added?

Page for TGate.



Discussion:

Resolving patch:
diff --git a/qiskit/circuit/library/__init__.py b/qiskit/circuit/library/__init__.py
--- a/qiskit/circuit/library/__init__.py
+++ b/qiskit/circuit/library/__init__.py
@@ -29,6 +29,7 @@
    C3XGate
    C4XGate
    CCXGate
+   DCXGate
    CHGate
    CRXGate
    CRYGate
@@ -57,7 +58,7 @@
    SdgGate
    SwapGate
    iSwapGate
-   DCXGate
+   TGate
    TdgGate
    U1Gate
    U2Gate
diff --git a/qiskit/circuit/library/standard_gates/__init__.py b/qiskit/circuit/library/standard_gates/__init__.py
--- a/qiskit/circuit/library/standard_gates/__init__.py
+++ b/qiskit/circuit/library/standard_gates/__init__.py
@@ -23,6 +23,7 @@
    C3XGate
    C4XGate
    CCXGate
+   DCXGate
    CHGate
    CRXGate
    CRYGate
@@ -49,7 +50,7 @@
    SdgGate
    SwapGate
    iSwapGate
-   DCXGate
+   TGate
    TdgGate
    U1Gate
    U2Gate


Test patch:
Repository: Qiskit/qiskit

Issue:
Bug in scheduler if circuit 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?
A bug was found in the scheduler if the circuit is empty. The fix is here in my pulse builder PR. This should be fixed, and tests in master and a backport made.

https://github.com/Qiskit/qiskit-terra/blob/40fe25df33f89432e2829a8fdb37f968c602106f/qiskit/scheduler/methods/basic.py#L121


### Steps to reproduce the problem



### What is the expected behavior?



### Suggested solutions





Discussion:

Resolving patch:
diff --git a/qiskit/scheduler/methods/basic.py b/qiskit/scheduler/methods/basic.py
--- a/qiskit/scheduler/methods/basic.py
+++ b/qiskit/scheduler/methods/basic.py
@@ -118,7 +118,7 @@ def update_times(inst_qubits: List[int], time: int = 0) -> None:
         rev_stop_times.append(stop_time)
         update_times(circ_pulse_def.qubits, stop_time)
 
-    last_stop = max(t for t in qubit_time_available.values())
+    last_stop = max(t for t in qubit_time_available.values()) if qubit_time_available else 0
     start_times = [last_stop - t for t in reversed(rev_stop_times)]
     timed_schedules = [(time, cpd.schedule) for time, cpd in zip(start_times, circ_pulse_defs)
                        if not isinstance(cpd.schedule, Barrier)]


Test patch:
diff --git a/test/python/scheduler/test_basic_scheduler.py b/test/python/scheduler/test_basic_scheduler.py
--- a/test/python/scheduler/test_basic_scheduler.py
+++ b/test/python/scheduler/test_basic_scheduler.py
@@ -72,6 +72,15 @@ def test_alap_with_barriers(self):
             self.assertEqual(actual[1].command, expected[1].command)
             self.assertEqual(actual[1].channels, expected[1].channels)
 
+    def test_empty_circuit_schedule(self):
+        """Test empty circuit being scheduled."""
+        q = QuantumRegister(2)
+        c = ClassicalRegister(2)
+        qc = QuantumCircuit(q, c)
+        sched = schedule(qc, self.backend, method='alap')
+        expected = Schedule()
+        self.assertEqual(sched.instructions, expected.instructions)
+
     def test_alap_aligns_end(self):
         """Test that ALAP always acts as though there is a final global barrier."""
         q = QuantumRegister(2)
Repository: Qiskit/qiskit

Issue:
Check for symmetry needed in hidden_linear_function.py for input matrix A
<!-- ⚠️ 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?
The input adjacency matrix A for `HiddenLinearFunction` should be required to be a symmetric matrix. A check for the same seems to be missing in `qiskit/circuit/library/hidden_linear_function.py`

Please let me know if I'm missing something here. 


Discussion:

Resolving patch:
diff --git a/qiskit/circuit/library/hidden_linear_function.py b/qiskit/circuit/library/hidden_linear_function.py
--- a/qiskit/circuit/library/hidden_linear_function.py
+++ b/qiskit/circuit/library/hidden_linear_function.py
@@ -20,6 +20,7 @@
 
 import numpy as np
 from qiskit import QuantumCircuit
+from qiskit.circuit.exceptions import CircuitError
 
 
 class HiddenLinearFunction(QuantumCircuit):
@@ -79,7 +80,14 @@ def __init__(self,
         Args:
             adjacency_matrix: a symmetric n-by-n list of 0-1 lists.
                 n will be the number of qubits.
+
+        Raises:
+            CircuitError: If A is not symmetric.
         """
+        adjacency_matrix = np.asarray(adjacency_matrix)
+        if not np.allclose(adjacency_matrix, adjacency_matrix.transpose()):
+            raise CircuitError("The adjacency matrix must be symmetric.")
+
         num_qubits = len(adjacency_matrix)
         super().__init__(num_qubits,
                          name="hlf: %s" % adjacency_matrix)


Test patch:
Repository: Qiskit/qiskit

Issue:
compare QuantumCircuit with open controlled gate raises RecursionError
<!-- ⚠️ 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 and 0.14.1
- **Python version**: 3.7
- **Operating system**: MacOS

### What is the current behavior?

```python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import XGate

circuit1 = QuantumCircuit(2)
circuit1.append(XGate().control(1, ctrl_state='0'), [0, 1])

circuit2 = QuantumCircuit(2)
circuit2.append(XGate().control(1, ctrl_state='0'), [0, 1])

circuit1 == circuit2
```
```
RecursionError: maximum recursion depth exceeded while calling a Python object
```

### What is the expected behavior?

These circuits should comparable and equal.





Discussion:

Resolving patch:
diff --git a/qiskit/circuit/controlledgate.py b/qiskit/circuit/controlledgate.py
--- a/qiskit/circuit/controlledgate.py
+++ b/qiskit/circuit/controlledgate.py
@@ -14,6 +14,7 @@
 
 """Controlled unitary gate."""
 
+import copy
 from typing import Tuple, List, Optional, Union
 from qiskit.circuit.exceptions import CircuitError
 
@@ -125,7 +126,7 @@ def definition(self) -> List:
             if val == '0':
                 open_rules.append([XGate(), [qreg[qind]], []])
         if open_rules:
-            return open_rules + definition + open_rules
+            return open_rules + copy.copy(definition) + open_rules
         else:
             return self._definition
 


Test patch:
diff --git a/test/python/circuit/test_controlled_gate.py b/test/python/circuit/test_controlled_gate.py
--- a/test/python/circuit/test_controlled_gate.py
+++ b/test/python/circuit/test_controlled_gate.py
@@ -781,6 +781,14 @@ def test_open_controlled_gate_raises(self):
         with self.assertRaises(CircuitError):
             base_gate.control(num_ctrl_qubits, ctrl_state='201')
 
+    def test_open_controlled_x_gate_eq(self):
+        """Test open control x gate equality."""
+        circuit1 = QuantumCircuit(2)
+        circuit1.append(XGate().control(1, ctrl_state='1'), [0, 1])
+        circuit2 = QuantumCircuit(2)
+        circuit2.append(XGate().control(1, ctrl_state='1'), [0, 1])
+        self.assertEqual(circuit1, circuit2)
+
 
 @ddt
 class TestSingleControlledRotationGates(QiskitTestCase):
Repository: Qiskit/qiskit

Issue:
barrier counted as non-local 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**: 14.1
- **Python version**:
- **Operating system**:

### What is the current behavior?

The `num_nonlocal_gates` method of the `QuantumCircuit` object counts mult-qubit barriers as non-local gates (since the `num_qubits` of the instruction is >1). I don't think users would expect this.


### Steps to reproduce the problem

```
qc = QuantumCircuit(n)
qc.h(range(n))
qc.measure_all()

qc.num_nonlocal_gates()
```

### What is the expected behavior?



### Suggested solutions





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
@@ -1365,7 +1365,7 @@ def num_nonlocal_gates(self):
         """
         multi_qubit_gates = 0
         for instr, _, _ in self._data:
-            if instr.num_qubits > 1:
+            if instr.num_qubits > 1 and instr.name not in ['barrier', 'snapshot']:
                 multi_qubit_gates += 1
         return multi_qubit_gates
 


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
@@ -433,6 +433,18 @@ def test_circuit_nonlocal_gates(self):
         expected = 3
         self.assertEqual(expected, result)
 
+    def test_circuit_nonlocal_gates_no_instruction(self):
+        """Verify num_nunlocal_gates does not include barriers.
+        """
+        # ref: https://github.com/Qiskit/qiskit-terra/issues/4500
+        n = 3
+        qc = QuantumCircuit(n)
+        qc.h(range(n))
+
+        qc.barrier()
+
+        self.assertEqual(qc.num_nonlocal_gates(), 0)
+
     def test_circuit_connected_components_empty(self):
         """Verify num_connected_components is width for empty
         """
Repository: Qiskit/qiskit

Issue:
A hundred or more pulse doc warnings being raised
This are getting raised about a hundred or more times in the docs build:

```
<partial node>:: WARNING: toctree contains reference to document 'stubs/qiskit.pulse.pulse_lib.discrete' that doesn't have a title: no link will be generated
<partial node>:: WARNING: toctree contains reference to document 'stubs/qiskit.pulse.channels' that doesn't have a title: no link will be generated
```


Discussion:

Resolving patch:
diff --git a/qiskit/pulse/__init__.py b/qiskit/pulse/__init__.py
--- a/qiskit/pulse/__init__.py
+++ b/qiskit/pulse/__init__.py
@@ -35,7 +35,7 @@
 
 .. _pulse-insts:
 
-Instructions (:mod:`~qiskit.pulse.instructions`)
+Instructions (:mod:`qiskit.pulse.instructions`)
 ================================================
 
 .. autosummary::
@@ -52,15 +52,15 @@
    ShiftPhase
    Snapshot
 
-Pulse Library (waveforms :mod:`~qiskit.pulse.pulse_lib`)
+Pulse Library (waveforms :mod:`qiskit.pulse.pulse_lib`)
 ========================================================
 
 .. autosummary::
    :toctree: ../stubs/
 
-   ~qiskit.pulse.pulse_lib
+   pulse_lib
+   pulse_lib.discrete
 
-   ~qiskit.pulse.pulse_lib.discrete
    SamplePulse
    Constant
    Drag
@@ -69,7 +69,7 @@
 
 .. _pulse-channels:
 
-Channels (:mod:`~qiskit.pulse.channels`)
+Channels (:mod:`qiskit.pulse.channels`)
 ========================================
 
 Pulse is meant to be agnostic to the underlying hardware implementation, while still allowing
@@ -82,7 +82,7 @@
 .. autosummary::
    :toctree: ../stubs/
 
-   ~qiskit.pulse.channels
+   channels
 
    DriveChannel
    MeasureChannel
@@ -113,15 +113,15 @@
 Schedule Transforms
 ===================
 
-These functions take :class:`~qiskit.pulse.Schedule` s as input and return modified
-:class:`~qiskit.pulse.Schedule` s.
+These functions take :class:`Schedule` s as input and return modified
+:class:`Schedule` s.
 
 .. autosummary::
    :toctree: ../stubs/
 
-   ~transforms.align_measures
-   ~transforms.add_implicit_acquires
-   ~transforms.pad
+   transforms.align_measures
+   transforms.add_implicit_acquires
+   transforms.pad
 
 Exceptions
 ==========
diff --git a/qiskit/pulse/channels.py b/qiskit/pulse/channels.py
--- a/qiskit/pulse/channels.py
+++ b/qiskit/pulse/channels.py
@@ -12,8 +12,7 @@
 # copyright notice, and modified files need to carry a notice indicating
 # that they have been altered from the originals.
 
-"""
-This module defines Pulse Channels. Channels include:
+"""This module defines Pulse Channels. Channels include:
 
   - transmit channels, which should subclass ``PulseChannel``
   - receive channels, such as ``AcquireChannel``


Test patch:
Repository: Qiskit/qiskit

Issue:
numpy>=1.17,<=1.18
Some tests are failing recently:
<img width="1035" alt="Screen Shot 2020-06-22 at 12 46 22 PM" src="https://user-images.githubusercontent.com/766693/85316568-f4934480-b48a-11ea-8fc1-5624c8d16d18.png">
<img width="1024" alt="Screen Shot 2020-06-22 at 12 46 46 PM" src="https://user-images.githubusercontent.com/766693/85316571-f5c47180-b48a-11ea-958b-c164b55250ca.png">

@mtreinish suggested that it could be numpy 0.19, released on June 20th. While investigating the issue, pinning the version.


Discussion:
I opened an issue for tracking this here: https://github.com/Qiskit/qiskit-terra/issues/4606 we'll need to get this sorted before the next release.

Resolving patch:
diff --git a/qiskit/pulse/pulse_lib/sample_pulse.py b/qiskit/pulse/pulse_lib/sample_pulse.py
--- a/qiskit/pulse/pulse_lib/sample_pulse.py
+++ b/qiskit/pulse/pulse_lib/sample_pulse.py
@@ -84,8 +84,8 @@ def _clip(self, samples: np.ndarray, epsilon: float = 1e-7) -> np.ndarray:
             to_clip_epsilon = clipped_sample_norms > 1.
             if np.any(to_clip_epsilon):
                 clip_where_epsilon = np.argwhere(to_clip_epsilon)
-                clipped_samples_epsilon = np.exp(
-                    (1-epsilon)*1j*clip_angle[clip_where_epsilon], dtype=np.complex_)
+                clipped_samples_epsilon = (1-epsilon)*np.exp(
+                    1j*clip_angle[clip_where_epsilon], dtype=np.complex_)
                 clipped_samples[clip_where_epsilon] = clipped_samples_epsilon
 
             # update samples with clipped values


Test patch: