Skip to content
This repository was archived by the owner on Oct 7, 2019. It is now read-only.

Commit e4ca313

Browse files
Robert Smithncrubin
Robert Smith
authored andcommitted
check for duplicate qubits
1 parent cc9ec2f commit e4ca313

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

referenceqvm/unitary_generator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ def permutation_arbitrary(args, num_qubits):
202202
if not (0 <= ind < num_qubits):
203203
raise ValueError("Permutation SWAP index not valid")
204204

205+
seen = set()
206+
for x in inds:
207+
if x in seen:
208+
raise ValueError("Duplicate qubit %d found" % x)
209+
205210
# Begin construction of permutation
206211
perm = sps.eye(2 ** num_qubits).astype(np.complex128)
207212

0 commit comments

Comments
 (0)