Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…eriments into issue-qiskit-community#1238-draft2

update local2/issue-#1238-draft2
  • Loading branch information
Naohnakazawa committed Nov 14, 2024
2 parents 8cece20 + 05d7487 commit 6c86cee
Show file tree
Hide file tree
Showing 18 changed files with 158 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pull_request_rules:
actions:
backport:
branches:
- stable/0.7
- stable/0.8
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

# -- Project information -----------------------------------------------------
# The short X.Y version
version = os.getenv("VERSION_STRING", "0.8")
version = os.getenv("VERSION_STRING", "0.9")

# The full version, including alpha/beta/rc tags
release = os.getenv("RELEASE_STRING", "0.8.0")
release = os.getenv("RELEASE_STRING", "0.9.0")

project = "Qiskit Experiments"
copyright = f"2021-{datetime.date.today().year}, Qiskit Development Team" # pylint: disable=redefined-builtin
Expand Down
5 changes: 5 additions & 0 deletions docs/manuals/characterization/stark_experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ by a variant of the Hahn-echo pulse sequence [5]_.
message=".*Due to the deprecation of Qiskit Pulse.*",
category=DeprecationWarning,
)
warnings.filterwarnings(
"ignore",
message=".*The entire Qiskit Pulse package is being deprecated.*",
category=DeprecationWarning,
)

from qiskit_experiments.library import StarkRamseyXY
from qiskit import schedule, pulse
Expand Down
10 changes: 10 additions & 0 deletions docs/manuals/measurement/restless_measurements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ they use always starts with the qubits in the ground state.
message=".*Support for restless.*",
category=DeprecationWarning,
)
warnings.filterwarnings(
"ignore",
message=".*The entire Qiskit Pulse package is being deprecated.*",
category=DeprecationWarning,
)
warnings.filterwarnings(
"ignore",
message=".*QuantumCircuit.duration.*",
category=DeprecationWarning,
)

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
Expand Down
14 changes: 1 addition & 13 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Release Notes
=============

.. release-notes::
:earliest-version: 0.7.0
:earliest-version: 0.8.0

.. _Release Notes_0.7.0:

Expand Down Expand Up @@ -1344,18 +1344,6 @@ New Features
- A new experiment :class:`.ZZRamsey` has been added to measure the ZZ
coefficient between a pair of qubits.

.. releasenotes/notes/mirror-rb-ec4d695a9a923971.yaml @ b'09fe450c18bf2bb706b664416e34cb26b770a9ff'
- Added a new experiment class :class:`.MirrorRB`. This class implements
mirror randomized benchmarking, a variant of randomized benchmarking that measures
the fidelity of user-defined ensembles of randomized mirror circuits.

.. releasenotes/notes/mirror-rb-ec4d695a9a923971.yaml @ b'09fe450c18bf2bb706b664416e34cb26b770a9ff'
- Added a base class that samples circuit layers for randomized benchmarking experiments,
:class:`.BaseSampler`. The edge grab sampler :class:`.EdgeGrabSampler` and a single
qubit gate sampler :class:`.SingleQubitSampler` are implemented.


.. _Release Notes_0.5.0_Known Issues:

Expand Down
5 changes: 5 additions & 0 deletions docs/tutorials/calibrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ This automatic updating can also be disabled using the ``auto_update`` flag.
message=".*Due to the deprecation of Qiskit Pulse.*",
category=DeprecationWarning,
)
warnings.filterwarnings(
"ignore",
message=".*The entire Qiskit Pulse package is being deprecated.*",
category=DeprecationWarning,
)

.. jupyter-execute::

Expand Down
5 changes: 5 additions & 0 deletions docs/tutorials/data_processor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ The code below sets up the Rabi experiment.
message=".*Due to the deprecation of Qiskit Pulse.*",
category=DeprecationWarning,
)
warnings.filterwarnings(
"ignore",
message=".*The entire Qiskit Pulse package is being deprecated.*",
category=DeprecationWarning,
)

.. jupyter-execute::

Expand Down
5 changes: 5 additions & 0 deletions docs/tutorials/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ First, we display the default figure from a :class:`.Rabi` experiment as a start
message=".*Due to the deprecation of Qiskit Pulse.*",
category=DeprecationWarning,
)
warnings.filterwarnings(
"ignore",
message=".*The entire Qiskit Pulse package is being deprecated.*",
category=DeprecationWarning,
)

.. jupyter-execute::

Expand Down
2 changes: 1 addition & 1 deletion qiskit_experiments/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.0
0.9.0
5 changes: 5 additions & 0 deletions qiskit_experiments/library/characterization/drag.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class RoughDrag(BaseExperiment, RestlessMixin):
message=".*Due to the deprecation of Qiskit Pulse.*",
category=DeprecationWarning,
)
warnings.filterwarnings(
"ignore",
message=".*The entire Qiskit Pulse package is being deprecated.*",
category=DeprecationWarning,
)
# backend
from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend
Expand Down
10 changes: 10 additions & 0 deletions qiskit_experiments/library/characterization/rabi.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class Rabi(BaseExperiment, RestlessMixin):
message=".*Due to the deprecation of Qiskit Pulse.*",
category=DeprecationWarning,
)
warnings.filterwarnings(
"ignore",
message=".*The entire Qiskit Pulse package is being deprecated.*",
category=DeprecationWarning,
)
# backend
from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend
Expand Down Expand Up @@ -254,6 +259,11 @@ class EFRabi(Rabi):
message=".*Due to the deprecation of Qiskit Pulse.*",
category=DeprecationWarning,
)
warnings.filterwarnings(
"ignore",
message=".*The entire Qiskit Pulse package is being deprecated.*",
category=DeprecationWarning,
)
# backend
from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend
Expand Down
1 change: 1 addition & 0 deletions qiskit_experiments/test/pulse_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ def __init__(
}
)
self._target = Target(
num_qubits=1,
qubit_properties=[QubitProperties(frequency=qubit_frequency)],
dt=self.dt,
granularity=16,
Expand Down
3 changes: 2 additions & 1 deletion test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ def setUpClass(cls):

patch_sampler_test_support()

warnings.filterwarnings("error", category=DeprecationWarning)
# Tests should not generate any warnings unless testing those
# warnings. In that case, the test should catch the warning
# assertWarns or warnings.catch_warnings.
warnings.filterwarnings("error", module="qiskit_experiments")
warnings.filterwarnings("error", module=r"test\.")
# Ideally, changes introducing pending deprecations should include
# alternative code paths and not need to generate warnings in the
# tests but until this exception is necessary until the use of the
Expand Down Expand Up @@ -176,6 +176,7 @@ def setUpClass(cls):
".*qiskit.providers.models.backendproperties.BackendProperties.*",
".*qiskit.providers.fake_provider.fake_backend.FakeBackend.*",
".*qiskit.providers.backend.BackendV1.*",
".*The entire Qiskit Pulse package is being deprecated.*",
]
for msg in allow_deprecationwarning_message:
warnings.filterwarnings("default", category=DeprecationWarning, message=msg)
Expand Down
38 changes: 22 additions & 16 deletions test/curve_analysis/test_baseclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# pylint: disable=invalid-name

"""Test curve fitting base class."""
import warnings

from test.base import QiskitExperimentsTestCase
from test.fake_experiment import FakeExperiment

Expand Down Expand Up @@ -139,22 +141,26 @@ def test_data_extraction(self):
},
)

curve_data = analysis._run_data_processing(raw_data=expdata1.data() + expdata2.data())
self.assertListEqual(curve_data.labels, ["s1", "s2"])

# check data of series1
sub1 = curve_data.get_subset_of("s1")
self.assertListEqual(sub1.labels, ["s1"])
np.testing.assert_array_equal(sub1.x, x)
np.testing.assert_array_almost_equal(sub1.y, y1, decimal=3)
np.testing.assert_array_equal(sub1.data_allocation, np.full(x.size, 0))

# check data of series2
sub2 = curve_data.get_subset_of("s2")
self.assertListEqual(sub2.labels, ["s2"])
np.testing.assert_array_equal(sub2.x, x)
np.testing.assert_array_almost_equal(sub2.y, y2, decimal=3)
np.testing.assert_array_equal(sub2.data_allocation, np.full(x.size, 1))
with warnings.catch_warnings():
warnings.filterwarnings("ignore", message=".*ScatterTable.labels.*")
warnings.filterwarnings("ignore", message=".*ScatterTable.get_subset_of.*")
warnings.filterwarnings("ignore", message=".*ScatterTable.data_allocation.*")
curve_data = analysis._run_data_processing(raw_data=expdata1.data() + expdata2.data())
self.assertListEqual(curve_data.labels, ["s1", "s2"])

# check data of series1
sub1 = curve_data.get_subset_of("s1")
self.assertListEqual(sub1.labels, ["s1"])
np.testing.assert_array_equal(sub1.x, x)
np.testing.assert_array_almost_equal(sub1.y, y1, decimal=3)
np.testing.assert_array_equal(sub1.data_allocation, np.full(x.size, 0))

# check data of series2
sub2 = curve_data.get_subset_of("s2")
self.assertListEqual(sub2.labels, ["s2"])
np.testing.assert_array_equal(sub2.x, x)
np.testing.assert_array_almost_equal(sub2.y, y2, decimal=3)
np.testing.assert_array_equal(sub2.data_allocation, np.full(x.size, 1))

def test_create_result(self):
"""A testcase for creating analysis result data from fit data."""
Expand Down
128 changes: 76 additions & 52 deletions test/curve_analysis/test_curve_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# that they have been altered from the originals.

"""Test version string generation."""
import warnings

from test.base import QiskitExperimentsTestCase
import numpy as np

Expand Down Expand Up @@ -88,55 +90,77 @@ def test_process_curve_data(self):
def test_mean_xy_data(self):
"""Test mean_xy_data function"""
# pylint: disable=unbalanced-tuple-unpacking
x = np.array([1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5])
y = np.array([1, 2, 3, 8, 10, 50, 60, 10, 11, 17, 10, 10, 10, 10])
x_mean, y_mean, y_sigma, _ = mean_xy_data(x, y, method="sample")

expected_x_mean = np.array([1, 2, 3, 4, 5])
expected_y_mean = np.array([2, 32, 10.5, 17, 10])
expected_y_sigma = np.sqrt(np.array([2 / 9, 542 / 4, 0.25 / 2, 0, 0]))
self.assertTrue(np.allclose(expected_x_mean, x_mean), msg=f"{x_mean} != {expected_x_mean}")
self.assertTrue(np.allclose(expected_y_mean, y_mean), msg=f"{y_mean} != {expected_y_mean}")
self.assertTrue(
np.allclose(expected_y_sigma, y_sigma), msg=f"{y_sigma} != {expected_y_sigma}"
)

sigma = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
x_mean, y_mean, y_sigma, _ = mean_xy_data(x, y, sigma, method="iwv")
expected_y_mean = np.array([1.34693878, 23.31590234, 10.44137931, 17.0, 10.0])
expected_y_sigma = np.array([0.85714286, 2.57610543, 5.97927455, 10.0, 6.17470935])
self.assertTrue(np.allclose(expected_x_mean, x_mean), msg=f"{x_mean} != {expected_x_mean}")
self.assertTrue(np.allclose(expected_y_mean, y_mean), msg=f"{y_mean} != {expected_y_mean}")
self.assertTrue(
np.allclose(expected_y_sigma, y_sigma), msg=f"{y_sigma} != {expected_y_sigma}"
)

sigma = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
shots = np.array([10, 20, 10, 30, 20, 10, 40, 10, 10, 20, 30, 20, 30, 10])
x_mean, y_mean, y_sigma, y_shots = mean_xy_data(x, y, sigma, shots, method="shots_weighted")
expected_y_mean = np.array([2.0, 33.4, 10.5, 17.0, 10.0])
expected_y_sigma = np.array([1.27475488, 3.26190129, 6.02079729, 10.0, 6.46166282])
expected_y_shots = np.array([40, 100, 20, 20, 90])
self.assertTrue(np.allclose(expected_x_mean, x_mean), msg=f"{x_mean} != {expected_x_mean}")
self.assertTrue(np.allclose(expected_y_mean, y_mean), msg=f"{y_mean} != {expected_y_mean}")
self.assertTrue(
np.allclose(expected_y_sigma, y_sigma), msg=f"{y_sigma} != {expected_y_sigma}"
)
self.assertTrue(
np.allclose(expected_y_shots, y_shots), msg=f"{y_shots} != {expected_y_shots}"
)

x = np.array([1, 1, 1, 1, 2, 2, 2, 2])
y = np.array([2, 6, 100, 200, 17, 50, 60, 70])
series = np.array([0, 0, 1, 1, 0, 1, 1, 1])
series, x_mean, y_mean, y_sigma, _ = multi_mean_xy_data(series, x, y, method="sample")
expected_x_mean = np.array([1, 2, 1, 2])
expected_y_mean = np.array([4, 17, 150, 60])
expected_y_sigma = np.sqrt(np.array([4.0 / 2, 0.0 / 1, 2500.0 / 2, 66.66666667 / 3]))
expected_series = np.array([0, 0, 1, 1])
self.assertTrue(np.allclose(expected_x_mean, x_mean), msg=f"{x_mean} != {expected_x_mean}")
self.assertTrue(np.allclose(expected_y_mean, y_mean), msg=f"{y_mean} != {expected_y_mean}")
self.assertTrue(
np.allclose(expected_y_sigma, y_sigma), msg=f"{y_sigma} != {expected_y_sigma}"
)
self.assertTrue(np.allclose(expected_series, series), msg=f"{series} != {expected_series}")
with warnings.catch_warnings():
warnings.filterwarnings("ignore", message=".*mean_xy_data.*")
x = np.array([1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5])
y = np.array([1, 2, 3, 8, 10, 50, 60, 10, 11, 17, 10, 10, 10, 10])
x_mean, y_mean, y_sigma, _ = mean_xy_data(x, y, method="sample")

expected_x_mean = np.array([1, 2, 3, 4, 5])
expected_y_mean = np.array([2, 32, 10.5, 17, 10])
expected_y_sigma = np.sqrt(np.array([2 / 9, 542 / 4, 0.25 / 2, 0, 0]))
self.assertTrue(
np.allclose(expected_x_mean, x_mean), msg=f"{x_mean} != {expected_x_mean}"
)
self.assertTrue(
np.allclose(expected_y_mean, y_mean), msg=f"{y_mean} != {expected_y_mean}"
)
self.assertTrue(
np.allclose(expected_y_sigma, y_sigma), msg=f"{y_sigma} != {expected_y_sigma}"
)

sigma = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
x_mean, y_mean, y_sigma, _ = mean_xy_data(x, y, sigma, method="iwv")
expected_y_mean = np.array([1.34693878, 23.31590234, 10.44137931, 17.0, 10.0])
expected_y_sigma = np.array([0.85714286, 2.57610543, 5.97927455, 10.0, 6.17470935])
self.assertTrue(
np.allclose(expected_x_mean, x_mean), msg=f"{x_mean} != {expected_x_mean}"
)
self.assertTrue(
np.allclose(expected_y_mean, y_mean), msg=f"{y_mean} != {expected_y_mean}"
)
self.assertTrue(
np.allclose(expected_y_sigma, y_sigma), msg=f"{y_sigma} != {expected_y_sigma}"
)

sigma = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
shots = np.array([10, 20, 10, 30, 20, 10, 40, 10, 10, 20, 30, 20, 30, 10])
x_mean, y_mean, y_sigma, y_shots = mean_xy_data(
x, y, sigma, shots, method="shots_weighted"
)
expected_y_mean = np.array([2.0, 33.4, 10.5, 17.0, 10.0])
expected_y_sigma = np.array([1.27475488, 3.26190129, 6.02079729, 10.0, 6.46166282])
expected_y_shots = np.array([40, 100, 20, 20, 90])
self.assertTrue(
np.allclose(expected_x_mean, x_mean), msg=f"{x_mean} != {expected_x_mean}"
)
self.assertTrue(
np.allclose(expected_y_mean, y_mean), msg=f"{y_mean} != {expected_y_mean}"
)
self.assertTrue(
np.allclose(expected_y_sigma, y_sigma), msg=f"{y_sigma} != {expected_y_sigma}"
)
self.assertTrue(
np.allclose(expected_y_shots, y_shots), msg=f"{y_shots} != {expected_y_shots}"
)

x = np.array([1, 1, 1, 1, 2, 2, 2, 2])
y = np.array([2, 6, 100, 200, 17, 50, 60, 70])
series = np.array([0, 0, 1, 1, 0, 1, 1, 1])
series, x_mean, y_mean, y_sigma, _ = multi_mean_xy_data(series, x, y, method="sample")
expected_x_mean = np.array([1, 2, 1, 2])
expected_y_mean = np.array([4, 17, 150, 60])
expected_y_sigma = np.sqrt(np.array([4.0 / 2, 0.0 / 1, 2500.0 / 2, 66.66666667 / 3]))
expected_series = np.array([0, 0, 1, 1])
self.assertTrue(
np.allclose(expected_x_mean, x_mean), msg=f"{x_mean} != {expected_x_mean}"
)
self.assertTrue(
np.allclose(expected_y_mean, y_mean), msg=f"{y_mean} != {expected_y_mean}"
)
self.assertTrue(
np.allclose(expected_y_sigma, y_sigma), msg=f"{y_sigma} != {expected_y_sigma}"
)
self.assertTrue(
np.allclose(expected_series, series), msg=f"{series} != {expected_series}"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[[0.016967836206746738, 0.11989893254007651, 0.00394654461853002, 0.13589528784677357, 0.20511482048008703, 0.0816791691977386, 0.14060546401643623, 0.2958919450936116], [0.12056007843940977, 0.10070988761274678, 0.41332860589623954, 0.07543734133716322, 0.021096066850169303, 0.1601488559241172, 0.03780114546996992, 0.0709180184701846], [0.10058394660184918, 0.39126225007098714, 0.09012977139125049, 0.02982028558144569, 0.005523508253283623, 0.040983681969626276, 0.2946239196681466, 0.04707263646341052], [0.3688522014926478, 0.09580420366241688, 0.027757018918742504, 0.15826915582072928, 0.13834528025457885, 0.11281057034461814, 0.04713950685498301, 0.05102206265128345], [0.2238855389562393, 0.0177775881962427, 0.0010361793224677451, 0.49743548639570334, 0.14345035837415962, 0.010983952529157095, 0.030086371572847458, 0.07534452465318305], [0.07191730758022169, 0.08577798556935443, 0.05222185324072163, 0.011505080428938406, 0.1506083560400655, 0.07947214515779061, 0.06954659702813472, 0.4789506749547722], [0.02933798117949475, 0.0905804630987942, 0.13414073913728367, 0.3283400904287246, 0.0039327427715444745, 0.06305126971619468, 0.07960132612718543, 0.27101538754077775], [0.10361935285611489, 0.5602661574454084, 0.0033379483277632236, 0.024104300671844853, 0.11180012107386983, 0.018590174540476845, 0.06496224115302754, 0.11331970393149465], [0.28002251748562146, 0.15659108128101512, 0.06931560231414717, 0.015939512694748054, 0.20272160865971692, 0.06437155774108827, 0.17997014329975955, 0.031067976523903224], [0.2583110429786593, 0.39280733849970395, 0.01004465642965845, 0.10112365839530935, 0.04820792916847759, 0.019172100821762683, 0.07396094843817139, 0.09637232526825651], [0.04205005835070806, 0.5982838080237505, 0.24825488091343656, 0.11141125271210575, 0.0, 0.0, 0.0, 0.0], [0.21631173866223324, 0.07201585886194255, 0.19647582952426423, 0.10741584491273042, 0.054982878753641044, 0.021165794683348307, 0.2526914377956466, 0.07894061680619284], [0.04109901108305593, 0.5346418163425509, 0.0, 0.0, 0.19988603142757153, 0.22437314114682205, 0.0, 0.0], [0.1069722912636189, 0.19610594120528163, 0.13827775538043613, 0.12862292833267164, 0.05652810658633324, 0.0979666878234763, 0.15917488848657904, 0.1163514009216026], [0.1599264302659344, 0.32405634292478286, 0.050423144948197246, 0.03657193295081257, 0.13405197214337658, 0.1872187743627101, 0.0005017400591434017, 0.1072496623450432], [0.057428879095657914, 0.07553302531949552, 0.05869499440092844, 0.031696849711854186, 0.20158700775693938, 0.20118430243224272, 0.02391580078822289, 0.34995914049465865], [0.12733557958689173, 0.08478618874152216, 0.032857670388396855, 0.08627573094283553, 0.18807352626751228, 0.2365561765088683, 0.15519965863714033, 0.08891546892683337], [0.05434853562358783, 0.1282198611011262, 0.11416220587356729, 0.049568640406240184, 0.1511891111128068, 0.14032078289874864, 0.3087935419191839, 0.05339732106473909], [0.06135629616886566, 0.25774569674205117, 0.0464794921453153, 0.15917144757251409, 0.1677568850176423, 0.18787259587234334, 0.05248811617198047, 0.0671294703092877], [0.005879541314725802, 0.025021402090856428, 0.44431583322312285, 0.05198340090748109, 0.04211534913258567, 0.013297849871047806, 0.26003956333041356, 0.15734706012976746]]
Loading

0 comments on commit 6c86cee

Please sign in to comment.