From eeb5b4c0f22b8c927376aac1ca971398a5c1c31e Mon Sep 17 00:00:00 2001 From: Kevin Tian Date: Thu, 21 Nov 2024 14:11:38 -0500 Subject: [PATCH] Update unit tests for Qiskit 1.3 (#2041) * wip 1.3 unit tests * Update remaining dynamical decoupling tests * pass optimization_level * Add scheduler tests back * Revert change in test_dd * Add dd calibration test back --------- Co-authored-by: ptristan3 <44805021+ptristan3@users.noreply.github.com> --- test/unit/test_backend.py | 2 +- test/unit/test_ibm_primitives_v2.py | 2 +- .../transpiler/passes/scheduling/test_dynamical_decoupling.py | 2 +- test/unit/transpiler/passes/scheduling/test_scheduler.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unit/test_backend.py b/test/unit/test_backend.py index 2de21c5da..c033d157b 100644 --- a/test/unit/test_backend.py +++ b/test/unit/test_backend.py @@ -84,7 +84,7 @@ def test_raise_faulty_edge(self): for i in range(num_qubits - 2): circ.cx(i, i + 1) - transpiled = transpile(circ, backend=fake_backend) + transpiled = transpile(circ, backend=fake_backend, optimization_level=1) edge_qubits = [0, 1] ibm_backend = create_faulty_backend(fake_backend, faulty_edge=("cx", edge_qubits)) sampler = SamplerV2(ibm_backend) diff --git a/test/unit/test_ibm_primitives_v2.py b/test/unit/test_ibm_primitives_v2.py index 00543a87a..31b6b83ec 100644 --- a/test/unit/test_ibm_primitives_v2.py +++ b/test/unit/test_ibm_primitives_v2.py @@ -542,7 +542,7 @@ def test_raise_faulty_edge(self, primitive): circ = QuantumCircuit(num_qubits, num_qubits) for i in range(num_qubits - 2): circ.cx(i, i + 1) - transpiled = transpile(circ, backend=fake_backend) + transpiled = transpile(circ, backend=fake_backend, optimization_level=1) observable = SparsePauliOp("Z" * num_qubits) edge_qubits = [0, 1] diff --git a/test/unit/transpiler/passes/scheduling/test_dynamical_decoupling.py b/test/unit/transpiler/passes/scheduling/test_dynamical_decoupling.py index efb38e96e..bea0f46ae 100644 --- a/test/unit/transpiler/passes/scheduling/test_dynamical_decoupling.py +++ b/test/unit/transpiler/passes/scheduling/test_dynamical_decoupling.py @@ -507,7 +507,7 @@ def test_dd_with_calibrations_with_parameters(self, param_value): for instruction in dd_circuit.data: op = instruction.operation if isinstance(op, RXGate): - self.assertEqual(op.duration, rx_duration) + self.assertEqual(op._params, [param_value]) def test_insert_dd_ghz_xy4_with_alignment(self): """Test DD with pulse alignment constraints.""" diff --git a/test/unit/transpiler/passes/scheduling/test_scheduler.py b/test/unit/transpiler/passes/scheduling/test_scheduler.py index f41a9899a..704446e05 100644 --- a/test/unit/transpiler/passes/scheduling/test_scheduler.py +++ b/test/unit/transpiler/passes/scheduling/test_scheduler.py @@ -895,7 +895,7 @@ def test_c_if_plugin_conversion_with_transpile(self): qc = QuantumCircuit(qr0, cr) qc.x(qr0[0]).c_if(cr[0], True) - qc_transpiled = transpile(qc, backend, initial_layout=[0]) + qc_transpiled = transpile(qc, backend, initial_layout=[0], optimization_level=1) scheduled = pm.run(qc_transpiled) @@ -2052,7 +2052,7 @@ def test_c_if_plugin_conversion_with_transpile(self): qc = QuantumCircuit(qr0, cr) qc.x(qr0[0]).c_if(cr[0], True) - qc_transpiled = transpile(qc, backend, initial_layout=[0]) + qc_transpiled = transpile(qc, backend, initial_layout=[0], optimization_level=1) scheduled = pm.run(qc_transpiled)