From 336bd34d1757a35da46aeb1ae4b69aa605ba49c1 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 23 Feb 2024 08:10:41 -0500 Subject: [PATCH] Update tests for Qiskit 1.0 (#41) * Update tests for Qiskit 1.0 This commit updates the execute tests to remove the use of execute() which was removed in Qiskit 1.0 after being deprecated in 0.46. How this managed to merge, I'm not entirely clear on because it should have failed CI on the removal PR, so there is likely a configuration issue in the neko custom action as well that will need to be fixed. * Fix fake provider usage * Fix typo --- qiskit_neko/aer_plugin.py | 2 +- qiskit_neko/tests/circuits/test_execute.py | 8 ++++---- requirements.txt | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/qiskit_neko/aer_plugin.py b/qiskit_neko/aer_plugin.py index 8623499..981795a 100644 --- a/qiskit_neko/aer_plugin.py +++ b/qiskit_neko/aer_plugin.py @@ -13,7 +13,7 @@ """Qiskit Aer default backend plugin.""" import qiskit_aer as aer -from qiskit.providers import fake_provider +from qiskit_ibm_runtime import fake_provider from qiskit_neko import backend_plugin diff --git a/qiskit_neko/tests/circuits/test_execute.py b/qiskit_neko/tests/circuits/test_execute.py index 87c93ab..75004bf 100644 --- a/qiskit_neko/tests/circuits/test_execute.py +++ b/qiskit_neko/tests/circuits/test_execute.py @@ -15,7 +15,7 @@ import math from qiskit.circuit import QuantumCircuit -from qiskit import execute +from qiskit import transpile from qiskit_neko import decorators from qiskit_neko.tests import base @@ -40,7 +40,7 @@ def test_bell_execute_fixed_shots(self): circuit.h(0) circuit.cx(0, 1) circuit.measure_all() - job = execute(circuit, self.backend, shots=100) + job = self.backend.run(transpile(circuit, self.backend), shots=100) result = job.result() counts = result.get_counts() self.assertDictAlmostEqual(counts, {"00": 50, "11": 50}, delta=10) @@ -53,7 +53,7 @@ def test_bell_execute_default_shots(self): circuit.cx(0, 1) circuit.measure_all() expected_count = self.backend.options.shots / 2 - job = execute(circuit, self.backend) + job = self.backend.run(transpile(circuit, self.backend)) result = job.result() counts = result.get_counts() delta = 10 ** (math.log10(self.backend.options.shots) - 1) @@ -69,7 +69,7 @@ def test_bell_execute_backend_shots_set_options(self): circuit.cx(0, 1) circuit.measure_all() self.backend.set_options(shots=100) - job = execute(circuit, self.backend) + job = self.backend.run(transpile(circuit, self.backend)) result = job.result() counts = result.get_counts() self.assertDictAlmostEqual(counts, {"00": 50, "11": 50}, delta=10) diff --git a/requirements.txt b/requirements.txt index 67cee99..77384a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ qiskit-aer qiskit-nature[pyscf] qiskit-experiments qiskit-machine-learning +qiskit-ibm-runtime>=0.19 stestr>=3.2.0 testtools>=2.5.0 fixtures>=3.0.0