From c530dd566af458fc813a729072042ffbe74eb984 Mon Sep 17 00:00:00 2001 From: Will Shanks Date: Thu, 1 Feb 2024 00:34:59 -0500 Subject: [PATCH] Replace qiskit.providers.basicaer test usage with qiskit-aer qiskit.providers.basicaer was removed in Qiskit 1.0. See https://github.com/Qiskit/qiskit/pull/11422 --- test/curve_analysis/test_curve_fitting.py | 4 ++-- test/library/calibration/test_rabi.py | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/curve_analysis/test_curve_fitting.py b/test/curve_analysis/test_curve_fitting.py index e64b5b5d65..937cd65b95 100644 --- a/test/curve_analysis/test_curve_fitting.py +++ b/test/curve_analysis/test_curve_fitting.py @@ -15,7 +15,7 @@ import numpy as np from qiskit import QuantumCircuit, transpile -from qiskit.providers.basicaer import QasmSimulatorPy +from qiskit_aer import AerSimulator from qiskit_experiments.curve_analysis import process_curve_data from qiskit_experiments.curve_analysis.utils import ( level2_probability, @@ -36,7 +36,7 @@ def simulate_experiment_data(self, thetas, shots=1024): qc.measure_all() circuits.append(qc) - sim = QasmSimulatorPy() + sim = AerSimulator() circuits = transpile(circuits, sim) job = sim.run(circuits, shots=shots, seed_simulator=10) result = job.result() diff --git a/test/library/calibration/test_rabi.py b/test/library/calibration/test_rabi.py index 962b3abd92..36df7fce9b 100644 --- a/test/library/calibration/test_rabi.py +++ b/test/library/calibration/test_rabi.py @@ -18,8 +18,8 @@ from qiskit import QuantumCircuit, pulse, transpile from qiskit.exceptions import QiskitError from qiskit.circuit import Parameter -from qiskit.providers.basicaer import QasmSimulatorPy from qiskit.qobj.utils import MeasLevel +from qiskit_aer import AerSimulator from qiskit_experiments.framework import ExperimentData, ParallelExperiment from qiskit_experiments.library import Rabi, EFRabi @@ -223,7 +223,7 @@ def simulate_experiment_data(self, thetas, amplitudes, shots=1024): qc.measure_all() circuits.append(qc) - sim = QasmSimulatorPy() + sim = AerSimulator() circuits = transpile(circuits, sim) job = sim.run(circuits, shots=shots, seed_simulator=10) result = job.result() @@ -272,7 +272,10 @@ def test_bad_analysis(self): """Test the Rabi analysis.""" experiment_data = ExperimentData() - thetas = np.linspace(0.0, np.pi / 4, 31) + # Change rotation angle with square root of amplitude so that + # population versus amplitude will not be sinusoidal and the fit will + # be bad. + thetas = np.sqrt(np.linspace(0.0, 4 * np.pi**2, 31)) amplitudes = np.linspace(0.0, 0.95, 31) experiment_data.add_data(self.simulate_experiment_data(thetas, amplitudes, shots=200))