Skip to content

Commit

Permalink
added test for barrier ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
raunakkumarsingh committed Jul 18, 2024
1 parent fee9569 commit 198e8fc
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/utils/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,49 @@ def test_separate_circuit(self):
self.assertEqual(
[("A", 0), ("B", 0), ("C", 0)], separated_circuits.qubit_map
)

with self.subTest("barriers are ignored"):
qreg = QuantumRegister(3)
circuit = QuantumCircuit(qreg)
circuit.h(0)
circuit.x(0)
circuit.barrier(0)
circuit.x(1)
circuit.h(1)
circuit.y(2)
circuit.h(2)

separated_circuits = separate_circuit(circuit, partition_labels="ABC")

compare1 = QuantumCircuit(1)
compare1.h(0)
compare1.x(0)
compare2 = QuantumCircuit(1)
compare2.x(0)
compare2.h(0)
compare3 = QuantumCircuit(1)
compare3.y(0)
compare3.h(0)

for i, operation in enumerate(compare1.data):
self.assertEqual(
operation.operation.name,
separated_circuits.subcircuits["A"].data[i].operation.name,
)
for i, operation in enumerate(compare2.data):
self.assertEqual(
operation.operation.name,
separated_circuits.subcircuits["B"].data[i].operation.name,
)
for i, operation in enumerate(compare3.data):
self.assertEqual(
operation.operation.name,
separated_circuits.subcircuits["C"].data[i].operation.name,
)
self.assertEqual(
[("A", 0), ("B", 0), ("C", 0)], separated_circuits.qubit_map
)

with self.subTest("Test bit mapping with partition labels"):
# Prepare a HWEA and add some measurements to clbits in a random order
circuit = prepare_hwea()
Expand Down

0 comments on commit 198e8fc

Please sign in to comment.