From 7795a328cb1f1e16ba833bc12f4e30188be08f77 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Mon, 15 Apr 2024 22:53:42 -0400 Subject: [PATCH] Replace jupyter-execute --- qiskit_ibm_provider/jupyter/__init__.py | 8 ++--- .../jupyter/dashboard/__init__.py | 2 +- .../transpiler/passes/scheduling/__init__.py | 34 +++++++++---------- .../passes/scheduling/dynamical_decoupling.py | 6 ++-- .../visualization/interactive/error_map.py | 4 +-- .../visualization/interactive/gate_map.py | 4 +-- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/qiskit_ibm_provider/jupyter/__init__.py b/qiskit_ibm_provider/jupyter/__init__.py index 5e2876ce3..7882260a5 100644 --- a/qiskit_ibm_provider/jupyter/__init__.py +++ b/qiskit_ibm_provider/jupyter/__init__.py @@ -29,14 +29,14 @@ Detailed information on a single backend ======================================== -.. jupyter-execute:: +.. code-block:: python :hide-code: :hide-output: from qiskit_ibm_provider.test.ibm_provider_mock import mock_get_backend mock_get_backend('Fake1Q') -.. jupyter-execute:: +.. code-block:: python from qiskit_ibm_provider import IBMProvider import qiskit_ibm_provider.jupyter @@ -44,13 +44,13 @@ provider = IBMProvider(hub='ibm-q') backend = provider.get_backend('ibmq_vigo') -.. jupyter-execute:: +.. code-block:: python :hide-code: :hide-output: backend.jobs = lambda *args, **kwargs: [] -.. jupyter-execute:: +.. code-block:: python backend diff --git a/qiskit_ibm_provider/jupyter/dashboard/__init__.py b/qiskit_ibm_provider/jupyter/dashboard/__init__.py index 2f343fb93..b559fba4f 100644 --- a/qiskit_ibm_provider/jupyter/dashboard/__init__.py +++ b/qiskit_ibm_provider/jupyter/dashboard/__init__.py @@ -19,7 +19,7 @@ The dashboard can be instantiated using -.. jupyter-execute:: +.. code-block:: python from qiskit_ibm_provider import IBMProvider import qiskit_ibm_provider.jupyter diff --git a/qiskit_ibm_provider/transpiler/passes/scheduling/__init__.py b/qiskit_ibm_provider/transpiler/passes/scheduling/__init__.py index 4d5991f90..166e6238b 100644 --- a/qiskit_ibm_provider/transpiler/passes/scheduling/__init__.py +++ b/qiskit_ibm_provider/transpiler/passes/scheduling/__init__.py @@ -32,14 +32,14 @@ Below we demonstrate how to schedule and pad a teleportation circuit with delays for a dynamic circuit backend's execution model: -.. jupyter-execute:: +.. code-block:: python :hide-code: :hide-output: import warnings warnings.filterwarnings("ignore", category=DeprecationWarning) -.. jupyter-execute:: +.. code-block:: python from qiskit.circuit import ClassicalRegister, QuantumCircuit, QuantumRegister from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager @@ -96,7 +96,7 @@ Instead of padding with delays we may also insert a dynamical decoupling sequence using the :class:`PadDynamicalDecoupling` pass as shown below: -.. jupyter-execute:: +.. code-block:: python from qiskit.circuit.library import XGate @@ -129,7 +129,7 @@ Scheduling with old format ``c_if`` conditioned gates is not supported. -.. jupyter-execute:: +.. code-block:: python qc_c_if = QuantumCircuit(1, 1) qc_c_if.x(0).c_if(0, 1) @@ -142,7 +142,7 @@ conditioned gates to new-style control-flow. We may then schedule the transpiled circuit without further modification. -.. jupyter-execute:: +.. code-block:: python # Temporary workaround for mock backends. For real backends this is not required. backend.get_translation_stage_plugin = lambda: "ibm_dynamic_circuits" @@ -164,7 +164,7 @@ :class:`qiskit.transpiler.passes.ConvertConditionsToIfOps` prior to your scheduling pass. -.. jupyter-execute:: +.. code-block:: python from qiskit.transpiler.passes import ConvertConditionsToIfOps @@ -193,7 +193,7 @@ as the measurements flow directly into the conditional blocks which in turn only apply gates to the same measurement qubit. -.. jupyter-execute:: +.. code-block:: python qc = QuantumCircuit(2, 2) qc.measure(0, 0) @@ -210,7 +210,7 @@ The circuit below will not use the fast-path as the conditional gate is on a different qubit than the measurement qubit. -.. jupyter-execute:: +.. code-block:: python qc = QuantumCircuit(2, 2) qc.measure(0, 0) @@ -222,7 +222,7 @@ Similarly, the circuit below contains gates on multiple qubits and will not be performed using the fast-path. -.. jupyter-execute:: +.. code-block:: python qc = QuantumCircuit(2, 2) qc.measure(0, 0) @@ -236,7 +236,7 @@ If there are multiple fast-path blocks being performed in parallel each block will be padded out to the duration of the longest block. -.. jupyter-execute:: +.. code-block:: python qc = QuantumCircuit(2, 2) qc.measure(0, 0) @@ -252,7 +252,7 @@ This behavior is also applied to the else condition of a fast-path eligible branch. -.. jupyter-execute:: +.. code-block:: python qc = QuantumCircuit(1, 1) qc.measure(0, 0) @@ -270,7 +270,7 @@ eligible block it will be applied followed by the non-fast-path blocks which will execute with the standard higher latency conditional branch. -.. jupyter-execute:: +.. code-block:: python qc = QuantumCircuit(2, 2) qc.measure(0, 0) @@ -287,7 +287,7 @@ If you wish to prevent the usage of the fast-path you may insert a barrier between the measurement and the conditional branch. -.. jupyter-execute:: +.. code-block:: python qc = QuantumCircuit(1, 2) qc.measure(0, 0) @@ -300,7 +300,7 @@ Conditional measurements are not eligible for the fast-path. -.. jupyter-execute:: +.. code-block:: python qc = QuantumCircuit(1, 2) qc.measure(0, 0) @@ -312,7 +312,7 @@ Similarly nested control-flow is not eligible. -.. jupyter-execute:: +.. code-block:: python qc = QuantumCircuit(1, 1) qc.measure(0, 0) @@ -331,7 +331,7 @@ there are fast-path blocks that will be performed in parallel they currently *will not* be padded out by the scheduler to ensure they are of the same duration in Qiskit -.. jupyter-execute:: +.. code-block:: python dd_sequence = [XGate(), XGate()] @@ -369,7 +369,7 @@ For example: - .. jupyter-execute:: + .. code-block:: python qc = QuantumCircuit(3, 2) qc.x(1) diff --git a/qiskit_ibm_provider/transpiler/passes/scheduling/dynamical_decoupling.py b/qiskit_ibm_provider/transpiler/passes/scheduling/dynamical_decoupling.py index 1d1cbac05..6f882cd97 100644 --- a/qiskit_ibm_provider/transpiler/passes/scheduling/dynamical_decoupling.py +++ b/qiskit_ibm_provider/transpiler/passes/scheduling/dynamical_decoupling.py @@ -52,7 +52,7 @@ class PadDynamicalDecoupling(BlockBasePadder): This pass ensures that the inserted sequence preserves the circuit exactly (including global phase). - .. jupyter-execute:: + .. code-block:: python import numpy as np from qiskit.circuit import QuantumCircuit @@ -75,7 +75,7 @@ class PadDynamicalDecoupling(BlockBasePadder): ("x", None, 50), ("measure", None, 1000)] ) - .. jupyter-execute:: + .. code-block:: python # balanced X-X sequence on all qubits dd_sequence = [XGate(), XGate()] @@ -84,7 +84,7 @@ class PadDynamicalDecoupling(BlockBasePadder): circ_dd = pm.run(circ) circ_dd.draw() - .. jupyter-execute:: + .. code-block:: python # Uhrig sequence on qubit 0 n = 8 diff --git a/qiskit_ibm_provider/visualization/interactive/error_map.py b/qiskit_ibm_provider/visualization/interactive/error_map.py index bc8a922b6..c0ee5b87b 100644 --- a/qiskit_ibm_provider/visualization/interactive/error_map.py +++ b/qiskit_ibm_provider/visualization/interactive/error_map.py @@ -55,7 +55,7 @@ def iplot_error_map( VisualizationTypeError: If the specified `backend` is a simulator. Example: - .. jupyter-execute:: + .. code-block:: python :hide-code: :hide-output: @@ -65,7 +65,7 @@ def iplot_error_map( # a fake backend in the following cell. mock_get_backend('FakeOpenPulse2Q') - .. jupyter-execute:: + .. code-block:: python from qiskit_ibm_provider import IBMProvider from qiskit_ibm_provider.visualization import iplot_error_map diff --git a/qiskit_ibm_provider/visualization/interactive/gate_map.py b/qiskit_ibm_provider/visualization/interactive/gate_map.py index 498913af7..d9f6dd045 100644 --- a/qiskit_ibm_provider/visualization/interactive/gate_map.py +++ b/qiskit_ibm_provider/visualization/interactive/gate_map.py @@ -59,7 +59,7 @@ def iplot_gate_map( Example: - .. jupyter-execute:: + .. code-block:: python :hide-code: :hide-output: @@ -69,7 +69,7 @@ def iplot_gate_map( # a fake backend in the following cell. mock_get_backend('FakeOpenPulse2Q') - .. jupyter-execute:: + .. code-block:: python from qiskit_ibm_provider import IBMProvider from qiskit_ibm_provider.visualization import iplot_gate_map