Skip to content

Commit

Permalink
Refactor monkey-patching so it is active during docs build
Browse files Browse the repository at this point in the history
  • Loading branch information
wshanks committed Oct 15, 2024
1 parent 50bcd9d commit 3b223b7
Show file tree
Hide file tree
Showing 25 changed files with 393 additions and 247 deletions.
7 changes: 7 additions & 0 deletions docs/howtos/artifacts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ Viewing artifacts
Here we run a parallel experiment consisting of two :class:`.T1` experiments in parallel and then view the output
artifacts as a list of :class:`.ArtifactData` objects accessed by :meth:`.ExperimentData.artifacts`:

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_ibm_runtime.fake_provider import FakePerth
Expand Down
7 changes: 7 additions & 0 deletions docs/manuals/characterization/t1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ for qubit 0.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

import numpy as np
Expand Down
7 changes: 7 additions & 0 deletions docs/manuals/characterization/t2ramsey.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ pure T1/T2 relaxation noise model.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

# A T1 simulator
Expand Down
7 changes: 7 additions & 0 deletions docs/manuals/characterization/tphi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ From the :math:`T_1` and :math:`T_2` estimates, we compute the results for
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

import numpy as np
Expand Down
7 changes: 7 additions & 0 deletions docs/manuals/measurement/readout_mitigation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ experiments to generate the corresponding mitigators.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

import numpy as np
Expand Down
7 changes: 7 additions & 0 deletions docs/manuals/measurement/restless_measurements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ they use always starts with the qubits in the ground state.
This tutorial requires the :external+qiskit_ibm_runtime:doc:`qiskit-ibm-runtime <index>` package to model a
backend. You can install it with ``python -m pip install qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_ibm_runtime.fake_provider import FakePerth
Expand Down
7 changes: 7 additions & 0 deletions docs/manuals/verification/quantum_volume.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ z_value = 2), and at least 100 trials have been ran.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_experiments.framework import BatchExperiment
Expand Down
7 changes: 7 additions & 0 deletions docs/manuals/verification/randomized_benchmarking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ explanation on the RB method, which is based on Refs. [1]_ [2]_.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

import numpy as np
Expand Down
7 changes: 7 additions & 0 deletions docs/manuals/verification/state_tomography.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ complete basis of measurement operators.

We first initialize a simulator to run the experiments on.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_aer import AerSimulator
Expand Down
7 changes: 7 additions & 0 deletions docs/tutorials/custom_experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,13 @@ To test our code, we first simulate a noisy backend with asymmetric readout erro
You can install it with ``python -m pip install qiskit-aer``.


.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_aer import AerSimulator, noise
Expand Down
7 changes: 7 additions & 0 deletions docs/tutorials/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ backend, real or simulated, that you can access through Qiskit.
packages to run simulations. You can install them with ``python -m pip
install qiskit-aer qiskit-ibm-runtime``.

.. jupyter-execute::
:hide-code:

# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()

.. jupyter-execute::

from qiskit_ibm_runtime.fake_provider import FakePerth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class CorrelatedReadoutError(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit_aer import AerSimulator
Expand Down
4 changes: 4 additions & 0 deletions qiskit_experiments/library/characterization/fine_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class FineFrequency(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakePerth
from qiskit_aer import AerSimulator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class LocalReadoutError(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime.fake_provider import FakePerth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class MultiStateDiscrimination(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend
backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=False, seed=199)
Expand Down
4 changes: 4 additions & 0 deletions qiskit_experiments/library/characterization/ramsey_xy.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class RamseyXY(BaseExperiment, RestlessMixin):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_aer import AerSimulator
from qiskit_ibm_runtime.fake_provider import FakePerth
Expand Down
4 changes: 4 additions & 0 deletions qiskit_experiments/library/characterization/t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class T1(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
from qiskit_aer import AerSimulator
Expand Down
4 changes: 4 additions & 0 deletions qiskit_experiments/library/characterization/t2ramsey.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class T2Ramsey(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
from qiskit_aer import AerSimulator
Expand Down
4 changes: 4 additions & 0 deletions qiskit_experiments/library/characterization/tphi.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class Tphi(BatchExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakeManilaV2
from qiskit_aer import AerSimulator
Expand Down
4 changes: 4 additions & 0 deletions qiskit_experiments/library/characterization/zz_ramsey.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class ZZRamsey(BaseExperiment):
.. jupyter-execute::
:hide-code:
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support
patch_sampler_test_support()
# backend
from qiskit_ibm_runtime.fake_provider import FakePerth
from qiskit_aer import AerSimulator
Expand Down
5 changes: 5 additions & 0 deletions qiskit_experiments/test/mock_iq_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def __init__(
backend_version: str = None,
**fields,
):
# Temporary workaround for missing support in Qiskit and qiskit-ibm-runtime
from qiskit_experiments.test.patching import patch_sampler_test_support

patch_sampler_test_support()

super().__init__(provider, name, description, online_date, backend_version, **fields)

backend_v1 = FakeOpenPulse2Q()
Expand Down
Loading

0 comments on commit 3b223b7

Please sign in to comment.