Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
The `efficient_su2` function returns gates in a slightly
different order than a `decompose`d `EfficientSU2`,
hence these changes.
  • Loading branch information
garrison committed Mar 8, 2025
1 parent 0b81d45 commit 01e7ab5
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}
],
"source": [
"circuit = efficient_su2(4, entanglement=\"linear\", reps=2).decompose()\n",
"circuit = efficient_su2(4, entanglement=\"linear\", reps=2)\n",
"circuit.assign_parameters([0.8] * len(circuit.parameters), inplace=True)\n",
"observable = SparsePauliOp([\"ZZZZ\"])\n",
"circuit.draw(\"mpl\", scale=0.8)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"source": [
"from qiskit.circuit.library import efficient_su2\n",
"\n",
"qc = efficient_su2(4, entanglement=\"linear\", reps=2).decompose()\n",
"qc = efficient_su2(4, entanglement=\"linear\", reps=2)\n",
"qc.assign_parameters([0.4] * len(qc.parameters), inplace=True)\n",
"\n",
"qc.draw(\"mpl\", scale=0.8)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"source": [
"from qiskit.circuit.library import efficient_su2\n",
"\n",
"circuit = efficient_su2(num_qubits=4, entanglement=\"circular\").decompose()\n",
"circuit = efficient_su2(num_qubits=4, entanglement=\"circular\")\n",
"circuit.assign_parameters([0.4] * len(circuit.parameters), inplace=True)\n",
"circuit.draw(\"mpl\", scale=0.8)"
]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies = [
"scipy>=1.5.2",
"rustworkx>=0.14.0",
"qiskit-aer>=0.14.0.1",
"qiskit>=1.1.0, !=1.3.0, <2.0",
"qiskit>=1.3.1, <2.0",
"qiskit-ibm-runtime>=0.24.0",
]

Expand Down
4 changes: 4 additions & 0 deletions releasenotes/notes/bump-qiskit-30bb4efa538e5ef0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
upgrade:
- |
Qiskit SDK 1.3.1 or higher is now required.
8 changes: 4 additions & 4 deletions test/cut_finding/test_cco_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create_test_circuit_1():


def create_test_circuit_2():
tc_2 = efficient_su2(2, entanglement="linear", reps=2).decompose()
tc_2 = efficient_su2(2, entanglement="linear", reps=2)
tc_2.assign_parameters([0.4] * len(tc_2.parameters), inplace=True)
return tc_2

Expand Down Expand Up @@ -80,18 +80,18 @@ def internal_test_circuit():
create_test_circuit_2,
[
CircuitElement("ry", [0.4], [0], None),
CircuitElement("rz", [0.4], [0], None),
CircuitElement("ry", [0.4], [1], None),
CircuitElement("rz", [0.4], [0], None),
CircuitElement("rz", [0.4], [1], None),
CircuitElement("cx", [], [0, 1], 3),
CircuitElement("ry", [0.4], [0], None),
CircuitElement("rz", [0.4], [0], None),
CircuitElement("ry", [0.4], [1], None),
CircuitElement("rz", [0.4], [0], None),
CircuitElement("rz", [0.4], [1], None),
CircuitElement("cx", [], [0, 1], 3),
CircuitElement("ry", [0.4], [0], None),
CircuitElement("rz", [0.4], [0], None),
CircuitElement("ry", [0.4], [1], None),
CircuitElement("rz", [0.4], [0], None),
CircuitElement("rz", [0.4], [1], None),
],
),
Expand Down
24 changes: 12 additions & 12 deletions test/cut_finding/test_cut_finder_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

class TestCuttingFourQubitCircuit(unittest.TestCase):
def setUp(self):
qc = efficient_su2(4, entanglement="linear", reps=2).decompose()
qc = efficient_su2(4, entanglement="linear", reps=2)
qc.assign_parameters([0.4] * len(qc.parameters), inplace=True)
self.circuit_internal = qc_to_cco_circuit(qc)

Expand Down Expand Up @@ -134,13 +134,13 @@ def test_four_qubit_cutting_workflow(self):
CutIdentifier(
cut_action="CutTwoQubitGate",
cut_location=CutLocation(
instruction_id=17, gate_name="cx", qubits=[2, 3]
instruction_id=10, gate_name="cx", qubits=[2, 3]
),
),
CutIdentifier(
cut_action="CutTwoQubitGate",
cut_location=CutLocation(
instruction_id=25, gate_name="cx", qubits=[2, 3]
instruction_id=21, gate_name="cx", qubits=[2, 3]
),
),
]
Expand Down Expand Up @@ -233,16 +233,16 @@ def test_four_qubit_cutting_workflow(self):
instruction_id=9, gate_name="cx", qubits=[1, 2], input=1
),
),
CutIdentifier(
cut_action="CutBothWires",
cut_location=CutLocation(
instruction_id=12, gate_name="cx", qubits=[0, 1]
),
),
SingleWireCutIdentifier(
cut_action="CutLeftWire",
wire_cut_location=WireCutLocation(
instruction_id=17, gate_name="cx", qubits=[2, 3], input=1
instruction_id=10, gate_name="cx", qubits=[2, 3], input=1
),
),
CutIdentifier(
cut_action="CutBothWires",
cut_location=CutLocation(
instruction_id=19, gate_name="cx", qubits=[0, 1]
),
),
CutIdentifier(
Expand All @@ -254,7 +254,7 @@ def test_four_qubit_cutting_workflow(self):
CutIdentifier(
cut_action="CutBothWires",
cut_location=CutLocation(
instruction_id=25, gate_name="cx", qubits=[2, 3]
instruction_id=21, gate_name="cx", qubits=[2, 3]
),
),
]
Expand Down Expand Up @@ -290,7 +290,7 @@ def test_four_qubit_cutting_workflow(self):
SingleWireCutIdentifier(
cut_action="CutLeftWire",
wire_cut_location=WireCutLocation(
instruction_id=17, gate_name="cx", qubits=[2, 3], input=1
instruction_id=10, gate_name="cx", qubits=[2, 3], input=1
),
),
SingleWireCutIdentifier(
Expand Down
2 changes: 1 addition & 1 deletion test/qpd/test_qpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
class TestQPDFunctions(unittest.TestCase):
def setUp(self):
# Use HWEA for simplicity and easy visualization
qpd_circuit = efficient_su2(4, entanglement="linear", reps=2).decompose()
qpd_circuit = efficient_su2(4, entanglement="linear", reps=2)

# We will instantiate 2 QPDBasis objects using from_instruction
rxx_gate = RXXGate(np.pi / 3)
Expand Down
4 changes: 2 additions & 2 deletions test/test_cutting_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
class TestCuttingDecomposition(unittest.TestCase):
def setUp(self):
# Use HWEA for simplicity and easy visualization
circuit = efficient_su2(4, entanglement="linear", reps=2).decompose()
qpd_circuit = efficient_su2(4, entanglement="linear", reps=2).decompose()
circuit = efficient_su2(4, entanglement="linear", reps=2)
qpd_circuit = efficient_su2(4, entanglement="linear", reps=2)

# We will instantiate 2 QPDBasis objects using from_instruction
rxx_gate = RXXGate(np.pi / 3)
Expand Down
4 changes: 2 additions & 2 deletions test/test_cutting_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
def test_transpile_before_realizing_basis_id():
"""Test a workflow where a :class:`.SingleQubitQPDGate` is passed through the transpiler."""
num_qubits = 4
circuit = efficient_su2(num_qubits, entanglement="linear", reps=2).decompose()
circuit = efficient_su2(num_qubits, entanglement="linear", reps=2)
circuit.assign_parameters([0.8] * len(circuit.parameters), inplace=True)
observables = PauliList(["ZZII"])
subcircuits, bases, subobservables = partition_problem(
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_transpile_before_realizing_basis_id():
)
def test_exotic_labels(label1, label2):
"""Test workflow with labels of non-uniform type."""
circuit = efficient_su2(4, entanglement="linear", reps=2).decompose()
circuit = efficient_su2(4, entanglement="linear", reps=2)
circuit.assign_parameters([0.8] * len(circuit.parameters), inplace=True)
observables = PauliList(["ZZII", "IZZI", "IIZZ", "XIXI", "ZIZZ", "IXIX"])
subcircuits, bases, subobservables = partition_problem(
Expand Down
2 changes: 1 addition & 1 deletion test/test_find_cuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_find_cuts(self):
assert metadata["minimum_reached"] is True

with self.subTest("Cut both wires instance"):
qc = efficient_su2(4, entanglement="linear", reps=2).decompose()
qc = efficient_su2(4, entanglement="linear", reps=2)
qc.assign_parameters([0.4] * len(qc.parameters), inplace=True)
optimization = OptimizationParameters(
seed=12345, gate_lo=False, wire_lo=True
Expand Down
2 changes: 1 addition & 1 deletion test/utils/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


def prepare_hwea():
circuit = efficient_su2(4, entanglement="linear", reps=1).decompose()
circuit = efficient_su2(4, entanglement="linear", reps=1)

# Exchange CNOTs with gates we support
for i, gate in enumerate(circuit.data):
Expand Down

0 comments on commit 01e7ab5

Please sign in to comment.