Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove remaining code usage deprecated in Qiskit 0.46 #1384

Merged
merged 7 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/manuals/measurement/readout_mitigation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ experiments to generate the corresponding mitigators.
import numpy as np
import matplotlib.pyplot as plt
from qiskit import QuantumCircuit
from qiskit.visualization import plot_histogram
from qiskit.visualization import plot_distribution
from qiskit_experiments.library import LocalReadoutError, CorrelatedReadoutError

from qiskit_aer import AerSimulator
Expand Down Expand Up @@ -128,7 +128,7 @@ Probabilities
.. jupyter-execute::

legend = ['Mitigated Probabilities', 'Unmitigated Probabilities']
plot_histogram([mitigated_probs, unmitigated_probs], legend=legend, sort="value_desc", bar_labels=False)
plot_distribution([mitigated_probs, unmitigated_probs], legend=legend, sort="value_desc", bar_labels=False)


Expectation value
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
qiskit==0.45.3
# Linters
black~=22.0
pylint~=3.0.2
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
numpy>=1.17
scipy>=1.4
qiskit==0.45.3 # Temporary
qiskit>=0.45
qiskit-ibm-experiment>=0.3.4
matplotlib>=3.4
uncertainties
Expand Down
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
9 changes: 5 additions & 4 deletions test/framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
"""Tests for base experiment framework."""

import pickle
from itertools import product
from test.fake_experiment import FakeExperiment, FakeAnalysis
from test.base import QiskitExperimentsTestCase
from itertools import product

import ddt

from qiskit import QuantumCircuit
from qiskit.providers.fake_provider import FakeJob
from qiskit.providers.jobstatus import JobStatus
from qiskit.exceptions import QiskitError
from qiskit_ibm_runtime.fake_provider import FakeVigoV2

from qiskit_experiments.database_service import Qubit
from qiskit_experiments.exceptions import AnalysisError
from qiskit_experiments.framework import (
ExperimentData,
Expand All @@ -33,7 +34,7 @@
AnalysisStatus,
)
from qiskit_experiments.test.fake_backend import FakeBackend
from qiskit_experiments.database_service import Qubit
from qiskit_experiments.test.utils import FakeJob
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good for now. I noticed our FakeJob is implemented differently from the removed FakeJob and also from current Jobs. For example, the qiskit-ibm-runtime Job doesn't have time_per_step() implemented currently. If we're using our own FakeJob going forward, we should make sure it matches the external specs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good. If possible, I would like to see us push more for external specs. The Qiskit base classes are minimal and we rely on a lot of private attributes of the provider classes in a way that seems very brittle.



@ddt.ddt
Expand Down Expand Up @@ -287,7 +288,7 @@ class MyBackend(FakeVigoV2):
"""A backend that works with `MyJob`"""

def run(self, run_input, **options):
return MyJob(self, "jobid", None)
return MyJob(self)

class MyJob(FakeJob):
"""A job with status ERROR, that errors when the result is queried"""
Expand Down
9 changes: 6 additions & 3 deletions test/library/calibration/test_rabi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed like this test chose somewhat arbitrary input data to be "bad" but changing simulators made it start fitting as good again. I made the data worse so that it should more reliably fit as bad.

amplitudes = np.linspace(0.0, 0.95, 31)

experiment_data.add_data(self.simulate_experiment_data(thetas, amplitudes, shots=200))
Expand Down
Loading