Skip to content

Commit

Permalink
Replace qiskit.providers.basicaer test usage with qiskit-aer
Browse files Browse the repository at this point in the history
qiskit.providers.basicaer was removed in Qiskit 1.0. See
Qiskit/qiskit#11422
  • Loading branch information
wshanks committed Feb 1, 2024
1 parent a7a3112 commit 90f60a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions test/curve_analysis/test_curve_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
12 changes: 8 additions & 4 deletions test/library/calibration/test_rabi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
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.providers.basic_provider import BasicSimulator
from qiskit_aer import AerSimulator

from qiskit_experiments.framework import ExperimentData, ParallelExperiment
from qiskit_experiments.library import Rabi, EFRabi
Expand Down Expand Up @@ -223,7 +224,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()
Expand Down Expand Up @@ -272,15 +273,18 @@ 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))

data_processor = DataProcessor("counts", [Probability(outcome="1")])

experiment_data = OscillationAnalysis().run(
experiment_data, data_processor=data_processor, plot=False
experiment_data, data_processor=data_processor, #plot=False
)
result = experiment_data.analysis_results()

Expand Down

0 comments on commit 90f60a6

Please sign in to comment.