Skip to content

Commit

Permalink
Fix a bug in add_1q_gate (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxiLi authored Oct 7, 2024
1 parent 5c80481 commit 36f38d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/qutip_qip/circuit/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def add_gates(self, gates):
def add_1q_gate(
self,
name,
start=0,
start=None,
end=None,
qubits=None,
**kwargs,
Expand All @@ -309,7 +309,14 @@ def add_1q_gate(
See :class:`~.QubitCircuit.add_gate`.
"""
if qubits is None:
if start is None or end is None:
raise ValueError(
"Both start and end must be specified if target qubits"
" are not provided."
)
qubits = range(start, end + 1)
if not isinstance(qubits, Iterable):
qubits = [qubits]
for q in qubits:
self.add_gate(name, targets=q, **kwargs)

Expand Down

0 comments on commit 36f38d0

Please sign in to comment.