From 6a9408d8cc6ca86e885105bc65518078985c82d9 Mon Sep 17 00:00:00 2001 From: DanPuzzuoli Date: Tue, 24 Sep 2024 07:48:36 -0700 Subject: [PATCH] adding context --- .../Lindblad_dynamics_simulation.rst | 5 +++ docs/tutorials/Rabi_oscillations.rst | 4 +++ docs/tutorials/dynamics_backend.rst | 31 +++++++++++++++++++ docs/tutorials/optimizing_pulse_sequence.rst | 14 +++++++++ docs/tutorials/qiskit_pulse.rst | 6 ++++ .../how_to_configure_simulations.rst | 16 ++++++++++ .../how_to_use_different_array_libraries.rst | 12 +++++++ .../how_to_use_pulse_schedule_for_jax_jit.rst | 4 +++ docs/userguide/perturbative_solvers.rst | 16 ++++++++++ qiskit_dynamics/pulse/__init__.py | 1 + qiskit_dynamics/signals/__init__.py | 2 ++ 11 files changed, 111 insertions(+) diff --git a/docs/tutorials/Lindblad_dynamics_simulation.rst b/docs/tutorials/Lindblad_dynamics_simulation.rst index 194238767..dc1020ffb 100644 --- a/docs/tutorials/Lindblad_dynamics_simulation.rst +++ b/docs/tutorials/Lindblad_dynamics_simulation.rst @@ -65,6 +65,7 @@ Below, we first set the number of qubits :math:`N` to be simulated, and then pre single-qubit Pauli operators that will be used in the rest of this tutorial. .. plot:: + :context: :include-source: import numpy as np @@ -102,6 +103,7 @@ derivatives of parameters, we do not use the :class:`Signal` class in this tutor tutorials for various generalizations of this approach supported with ``qiskit-dynamics``. .. plot:: + :context: :include-source: from qiskit_dynamics import Solver, Signal @@ -143,6 +145,7 @@ We now define the initial state for the simulation, the time span to simulate fo intermediate times for which the solution is requested. .. plot:: + :context: :include-source: from qiskit.quantum_info import DensityMatrix @@ -179,6 +182,7 @@ observing that this equality holds is a simple and useful verification of the nu that will be added in the next section. .. plot:: + :context: :include-source: n_times = len(sol.y) @@ -223,6 +227,7 @@ a mixed state), becoming tilted along :math:`-y`. This complex dependence of the parameters can be systematically analyzed - we encourage you to try it! .. plot:: + :context: :include-source: from qiskit.visualization import plot_bloch_vector diff --git a/docs/tutorials/Rabi_oscillations.rst b/docs/tutorials/Rabi_oscillations.rst index a9e8a7337..6b4f83f67 100644 --- a/docs/tutorials/Rabi_oscillations.rst +++ b/docs/tutorials/Rabi_oscillations.rst @@ -36,6 +36,7 @@ using matrices and :class:`.Signal` instances. For the time-independent :math:`z signal to a constant, while for the trasverse driving term we setup a harmonic signal. .. plot:: + :context: :include-source: import numpy as np @@ -64,6 +65,7 @@ We now define the initial state for the simulation, the time span to simulate fo intermediate times for which the solution is requested, and solve the evolution. .. plot:: + :context: :include-source: from qiskit.quantum_info.states import Statevector @@ -99,6 +101,7 @@ gates used to manipulate quantum devices - in particular this is a realization o gate. .. plot:: + :context: :include-source: from qiskit.visualization import plot_bloch_vector @@ -165,6 +168,7 @@ state vectors and density matrices. The shrinking of the qubit’s state within to the incoherent evolution can be clearly seen in the plots below. .. plot:: + :context: :include-source: Gamma_1 = .8 diff --git a/docs/tutorials/dynamics_backend.rst b/docs/tutorials/dynamics_backend.rst index c943ba6f9..7de4521e1 100644 --- a/docs/tutorials/dynamics_backend.rst +++ b/docs/tutorials/dynamics_backend.rst @@ -29,12 +29,14 @@ when using a JAX solver method. Here we configure JAX to run on CPU in 64 bit mo array libraries>` for more information. .. plot:: + :context: # a parallelism warning raised by JAX is being raised due to somethign outside of Dynamics import warnings warnings.filterwarnings("ignore", message="os.fork") .. plot:: + :context: :include-source: # Configure JAX @@ -69,6 +71,7 @@ where respectively. .. plot:: + :context: :include-source: import numpy as np @@ -120,6 +123,7 @@ outcomes of :meth:`.DynamicsBackend.run` are independent of the choice of rotati performance. .. plot:: + :context: :include-source: from qiskit_dynamics import Solver @@ -149,6 +153,7 @@ Furthermore, note that in the solver options we set the max step size to the pul variable step solvers from accidentally stepping over pulses in schedules with long idle times. .. plot:: + :context: :include-source: from qiskit_dynamics import DynamicsBackend @@ -186,6 +191,7 @@ that the usual instructions work on the :class:`.DynamicsBackend`. .. plot:: + :context: :include-source: import time @@ -221,6 +227,7 @@ that the usual instructions work on the :class:`.DynamicsBackend`. Visualize one of the schedules. .. plot:: + :context: :include-source: schedules[3].draw() @@ -229,6 +236,7 @@ Retrieve the counts for one of the experiments as would be done using the result backend. .. plot:: + :context: :include-source: result.get_counts(3) @@ -248,6 +256,7 @@ Build a simple circuit. Here we build one consisting of a single Hadamard gate o followed by measurement. .. plot:: + :context: :include-source: from qiskit import QuantumCircuit @@ -263,6 +272,7 @@ we are only demonstrating the mechanics of adding a calibration; we have not att the schedule to implement the Hadamard gate with high fidelity. .. plot:: + :context: :include-source: with pulse.build() as h_q0: @@ -276,6 +286,7 @@ the schedule to implement the Hadamard gate with high fidelity. Call run on the circuit, and get counts as usual. .. plot:: + :context: :include-source: start_time = time.time() @@ -294,6 +305,7 @@ Hadamard gate on qubit :math:`0` to `backend.target`, which impacts how jobs are backend. See the :class:`~qiskit.transpiler.Target` class documentation for further information. .. plot:: + :context: :include-source: from qiskit.circuit.library import HGate @@ -305,6 +317,7 @@ Rebuild the same circuit, however this time we do not need to add the calibratio gate to the circuit object. .. plot:: + :context: :include-source: circ2 = QuantumCircuit(1, 1) @@ -318,6 +331,7 @@ gate to the circuit object. print(f"Run time: {time.time() - start_time}") .. plot:: + :context: :include-source: result.get_counts(0) @@ -348,6 +362,7 @@ To enable running of the single qubit experiments, we add the following to the ` will pass. .. plot:: + :context: :include-source: from qiskit.circuit.library import XGate, SXGate, RZGate, CXGate @@ -389,6 +404,7 @@ object. Here we use the template library to initialize our calibrations. .. plot:: + :context: :include-source: import pandas as pd @@ -406,6 +422,7 @@ Next, run a rough amplitude calibration for ``X`` and ``SX`` gates for both qubi experiments. .. plot:: + :context: :include-source: from qiskit_experiments.library.calibration import RoughXSXAmplitudeCal @@ -419,6 +436,7 @@ experiments. Run the Rabi experiments. .. plot:: + :context: :include-source: start_time = time.time() @@ -431,11 +449,13 @@ Run the Rabi experiments. Plot the results. .. plot:: + :context: :include-source: rabi0_data.figure(0) .. plot:: + :context: :include-source: rabi1_data.figure(0) @@ -443,6 +463,7 @@ Plot the results. Observe the updated parameters for qubit 0. .. plot:: + :context: :include-source: pd.DataFrame(**cals.parameters_table(qubit_list=[0, ()], parameters="amp")) @@ -454,6 +475,7 @@ Run rough Drag parameter calibration for the ``X`` and ``SX`` gates. This follow as above. .. plot:: + :context: :include-source: from qiskit_experiments.library.calibration import RoughDragCal @@ -467,6 +489,7 @@ as above. cal_drag0.circuits()[5].draw(output="mpl") .. plot:: + :context: :include-source: start_time = time.time() @@ -477,12 +500,14 @@ as above. print(f"Run time: {time.time() - start_time}") .. plot:: + :context: :include-source: drag0_data.figure(0) .. plot:: + :context: :include-source: drag1_data.figure(0) @@ -490,6 +515,7 @@ as above. The updated calibrations object: .. plot:: + :context: :include-source: pd.DataFrame(**cals.parameters_table(qubit_list=[0, ()], parameters="amp")) @@ -505,6 +531,7 @@ the control channel index used to drive the corresponding cross-resonance intera required by the experiment to determine which channel to drive for each control-target pair. .. plot:: + :context: :include-source: # set the control channel map @@ -514,6 +541,7 @@ Build the characterization experiment object, and update gate definitions in ``t values for the single qubit gates calibrated above. .. plot:: + :context: :include-source: from qiskit_experiments.library import CrossResonanceHamiltonian @@ -527,6 +555,7 @@ values for the single qubit gates calibrated above. backend.target.update_from_instruction_schedule_map(cals.get_inst_map()) .. plot:: + :context: :include-source: cr_ham_experiment.circuits()[10].draw("mpl") @@ -534,6 +563,7 @@ values for the single qubit gates calibrated above. Run the simulation. .. plot:: + :context: :include-source: start_time = time.time() @@ -544,6 +574,7 @@ Run the simulation. .. plot:: + :context: :include-source: data_cr.figure(0) diff --git a/docs/tutorials/optimizing_pulse_sequence.rst b/docs/tutorials/optimizing_pulse_sequence.rst index 1176bf3e6..21f4f76e1 100644 --- a/docs/tutorials/optimizing_pulse_sequence.rst +++ b/docs/tutorials/optimizing_pulse_sequence.rst @@ -25,6 +25,7 @@ We will optimize an :math:`X`-gate on a model of a qubit system using the follow First, set JAX to operate in 64-bit mode and to run on CPU. .. plot:: + :context: :include-source: import jax @@ -53,6 +54,7 @@ In the above: We will setup the problem to be in the rotating frame of the drift term. .. plot:: + :context: :include-source: import numpy as np @@ -103,6 +105,7 @@ more efficient strategies for achieving a value of :math:`0` at the beginning an This is only meant to demonstrate the need for such an approach, and one simple example of one. .. plot:: + :context: :include-source: from qiskit_dynamics import DiscreteSignal @@ -138,6 +141,7 @@ This is only meant to demonstrate the need for such an approach, and one simple Observe, for example, the signal generated when all parameters are :math:`10^8`: .. plot:: + :context: :include-source: signal = signal_mapping(np.ones(80) * 1e8) @@ -153,6 +157,7 @@ the pulse via the standard fidelity measure: .. math:: f(U) = \frac{|\text{Tr}(XU)|^2}{4} .. plot:: + :context: :include-source: X_op = Operator.from_label('X').data @@ -170,6 +175,7 @@ The function we want to optimize consists of: - Computing and return the infidelity (we minimize :math:`1 - f(U)`). .. plot:: + :context: :include-source: def objective(params): @@ -206,6 +212,7 @@ Finally, we gradient optimize the objective: indicate that the passed objective also computes the gradient. .. plot:: + :context: :include-source: from jax import jit, value_and_grad @@ -228,6 +235,7 @@ We can draw the optimized signal, which is retrieved by applying the ``signal_ma optimized parameters. .. plot:: + :context: :include-source: opt_signal = signal_mapping(opt_results.x) @@ -245,6 +253,7 @@ Summing the signal samples yields approximately :math:`\pm 50`, which is equival would expect based on a rotating wave approximation analysis. .. plot:: + :context: :include-source: opt_signal.samples.sum() @@ -262,6 +271,7 @@ instance, parameterized by ``sigma`` and ``width``. Although qiskit pulse provid entry on :ref:`JAX-compatible pulse schedules `. .. plot:: + :context: :include-source: import sympy as sym @@ -321,6 +331,7 @@ Next, we construct a pulse schedule using the above parametrized Gaussian square to a signal, and simulate the equation over the length of the pulse sequence. .. plot:: + :context: :include-source: from qiskit_dynamics.pulse import InstructionToSignals @@ -353,12 +364,14 @@ We set the initial values of ``sigma`` and ``width`` for the optimization as ``initial_params = np.array([10, 10])``. .. plot:: + :context: :include-source: initial_params = np.array([10, 10]) gaussian_square_generated_by_pulse(initial_params).draw() .. plot:: + :context: :include-source: from jax import jit, value_and_grad @@ -381,6 +394,7 @@ We set the initial values of ``sigma`` and ``width`` for the optimization as We can draw the optimized pulse, whose parameters are retrieved by ``opt_results.x``. .. plot:: + :context: :include-source: gaussian_square_generated_by_pulse(opt_results.x).draw() \ No newline at end of file diff --git a/docs/tutorials/qiskit_pulse.rst b/docs/tutorials/qiskit_pulse.rst index 354228015..c751932f5 100644 --- a/docs/tutorials/qiskit_pulse.rst +++ b/docs/tutorials/qiskit_pulse.rst @@ -33,6 +33,7 @@ steps: First, we use the pulse module in Qiskit to create a pulse schedule. .. plot:: + :context: :include-source: import numpy as np @@ -73,6 +74,7 @@ envelopes and the signals resulting from this conversion. The dashed line shows the virtual ``Z`` gate is applied. .. plot:: + :context: :include-source: from matplotlib import pyplot as plt @@ -102,6 +104,7 @@ carrier frequencies, and sample width ``dt``. Additionally, we setup this solver frame and perform the rotating wave approximation. .. plot:: + :context: :include-source: from qiskit.quantum_info.operators import Operator @@ -135,6 +138,7 @@ In the last step we perform the simulation and plot the results. Note that, as w should produce identical behavior. .. plot:: + :context: :include-source: import time @@ -151,6 +155,7 @@ should produce identical behavior. .. plot:: + :context: :include-source: def plot_populations(sol): @@ -174,6 +179,7 @@ the ``Y`` operator. Therefore, the second pulse, which drives around the ``Y``-a shift, has hardley any influence on the populations of the qubit. .. plot:: + :context: :include-source: plot_populations(sol) diff --git a/docs/userguide/how_to_configure_simulations.rst b/docs/userguide/how_to_configure_simulations.rst index b7909adac..ce7313622 100644 --- a/docs/userguide/how_to_configure_simulations.rst +++ b/docs/userguide/how_to_configure_simulations.rst @@ -42,6 +42,7 @@ where: First, construct the components of the model: .. plot:: + :context: :include-source: import numpy as np @@ -72,6 +73,7 @@ Construct a :class:`.Solver` for the model as stated, without entering a rotatin timing the solver. .. plot:: + :context: :include-source: import time @@ -93,6 +95,7 @@ Next, define a :class:`.Solver` in the rotating frame of the static Hamiltonian ``rotating_frame`` kwarg, and solve, again timing the solver. .. plot:: + :context: :include-source: rf_solver = Solver( @@ -123,6 +126,7 @@ To compare the results, we use the fidelity function for unitary matrices: where :math:`d` is the dimension. A value of :math:`1` indicates equality of the unitaries. .. plot:: + :context: :include-source: def fidelity(U, V): @@ -144,6 +148,7 @@ evaluations when solving the differential equation in each instance. The number for the first simulation (not in the rotating frame) was: .. plot:: + :context: :include-source: results.nfev @@ -151,6 +156,7 @@ for the first simulation (not in the rotating frame) was: Whereas the number of evaluations for the second simulation in the rotating frame was: .. plot:: + :context: :include-source: rf_results.nfev @@ -171,6 +177,7 @@ Construct a solver for the same problem, now specifying an RWA cutoff frequency frequencies relative to which the cutoff should be applied: .. plot:: + :context: :include-source: rwa_solver = Solver( @@ -193,6 +200,7 @@ We observe a further reduction in time, which is a result of the solver requirin evaluations with the RWA: .. plot:: + :context: :include-source: rwa_results.nfev @@ -201,6 +209,7 @@ This speed comes at the cost of lower accuracy, owing to the fact that RWA is a *approximation*, which modifies the structure of the solution: .. plot:: + :context: :include-source: U_rwa = rwa_solver.model.rotating_frame.state_out_of_frame(T, rwa_results.y[-1]) @@ -232,6 +241,7 @@ Dynamics. Start off by configuring JAX. .. plot:: + :context: :include-source: # configure jax to use 64 bit mode @@ -246,6 +256,7 @@ arrays. Furthermore, set up the initial state to be a single column vector, to f benefits of the sparse representation. .. plot:: + :context: :include-source: dim = 300 @@ -271,6 +282,7 @@ Construct standard dense solver in the rotating frame of the static Hamiltonian, to solve the system for a given amplitude, and just-in-time compile it using JAX. .. plot:: + :context: :include-source: solver = Solver( @@ -298,6 +310,7 @@ function to solve the system for a given amplitude, and just-in-time compile it. case the static Hamiltonian is already diagonal, but we explicitly highlight the need for this. .. plot:: + :context: :include-source: sparse_solver = Solver( @@ -324,6 +337,7 @@ case the static Hamiltonian is already diagonal, but we explicitly highlight the Run the dense simulation (twice to see the true compiled speed). .. plot:: + :context: :include-source: yf = jitted_dense_func(1.).block_until_ready() @@ -337,6 +351,7 @@ Run the dense simulation (twice to see the true compiled speed). Run the sparse solver (twice to see the true compiled speed). .. plot:: + :context: :include-source: yf_sparse = jitted_sparse_func(1.).block_until_ready() @@ -350,6 +365,7 @@ Run the sparse solver (twice to see the true compiled speed). Verify equality of the results in a common frame. .. plot:: + :context: :include-source: yf = solver.model.rotating_frame.state_out_of_frame(T, yf) diff --git a/docs/userguide/how_to_use_different_array_libraries.rst b/docs/userguide/how_to_use_different_array_libraries.rst index 1c1bc6806..2f3da23a0 100644 --- a/docs/userguide/how_to_use_different_array_libraries.rst +++ b/docs/userguide/how_to_use_different_array_libraries.rst @@ -24,6 +24,7 @@ This guide addresses the following topics: First, configure JAX and import array libraries. .. plot:: + :context: :include-source: # configure jax to use 64 bit mode @@ -40,6 +41,7 @@ First, configure JAX and import array libraries. Defining equivalent :class:`.Signal` instances, with envelope implemented in either NumPy or JAX. .. plot:: + :context: :include-source: from qiskit_dynamics import Signal @@ -57,6 +59,7 @@ Defining equivalent :class:`.Signal` instances, with envelope implemented in eit Evaluation of ``signal_numpy`` is executed with NumPy: .. plot:: + :context: :include-source: type(signal_numpy(0.1)) @@ -64,6 +67,7 @@ Evaluation of ``signal_numpy`` is executed with NumPy: Evaluation of ``signal_jax`` is executed with JAX: .. plot:: + :context: :include-source: type(signal_jax(0.1)) @@ -71,6 +75,7 @@ Evaluation of ``signal_jax`` is executed with JAX: JAX transformations can be applied to ``signal_jax``, e.g. just-in-time compilation: .. plot:: + :context: :include-source: from jax import jit @@ -86,6 +91,7 @@ Internally, Qiskit Dynamics uses an extension of the default NumPy and SciPy arr by `Arraylias `_. These can be imported as: .. plot:: + :context: :include-source: # alias for NumPy and corresponding aliased library @@ -115,6 +121,7 @@ scans over a control parameter. First, we construct a :class:`.Solver` instance with a simple qubit model. .. plot:: + :context: :include-source: import numpy as np @@ -144,6 +151,7 @@ Next, define the function to be compiled: total evolution time. .. plot:: + :context: :include-source: def sim_function(amp): @@ -165,6 +173,7 @@ Next, define the function to be compiled: Compile the function. .. plot:: + :context: :include-source: from jax import jit @@ -175,6 +184,7 @@ version of the function, which is then executed. Hence, the time taken on the fi compilation time. .. plot:: + :context: :include-source: start_time = time.time() @@ -188,6 +198,7 @@ On subsequent calls the compiled function is directly executed, demonstrating th compiled function. .. plot:: + :context: :include-source: start_time = time.time() @@ -200,6 +211,7 @@ compiled function. We use this function to plot the :math:`Z` expectation value over a range of input amplitudes. .. plot:: + :context: :include-source: import matplotlib.pyplot as plt diff --git a/docs/userguide/how_to_use_pulse_schedule_for_jax_jit.rst b/docs/userguide/how_to_use_pulse_schedule_for_jax_jit.rst index 1ba38cfaa..40c971d5a 100644 --- a/docs/userguide/how_to_use_pulse_schedule_for_jax_jit.rst +++ b/docs/userguide/how_to_use_pulse_schedule_for_jax_jit.rst @@ -31,6 +31,7 @@ Dynamics. First, configure JAX to run on CPU in 64 bit mode. .. plot:: + :context: :include-source: # configure jax to use 64 bit mode @@ -50,6 +51,7 @@ Gaussian pulse to use in optimization, we need to instantiate a the symbolic representation in `sympy`. .. plot:: + :context: :include-source: from qiskit import pulse @@ -78,6 +80,7 @@ the symbolic representation in `sympy`. Next, define the :class:`~qiskit.pulse.library.ScalableSymbolicPulse` using the above expression. .. plot:: + :context: :include-source: _t, _duration, _amp, _sigma, _angle = sym.symbols("t, duration, amp, sigma, angle") @@ -109,6 +112,7 @@ Using a Gaussian pulse as an example, we show that a function involving JAX-compiled (or more generally, JAX-transformed). .. plot:: + :context: :include-source: # use amplitude as the function argument diff --git a/docs/userguide/perturbative_solvers.rst b/docs/userguide/perturbative_solvers.rst index 84580cb0a..48f1197c4 100644 --- a/docs/userguide/perturbative_solvers.rst +++ b/docs/userguide/perturbative_solvers.rst @@ -54,6 +54,7 @@ different array libraries>` for a more detailed explanation of how to work with Dynamics. .. plot:: + :context: :include-source: # configure jax to use 64 bit mode @@ -75,6 +76,7 @@ solver. However after the initial construction, the higher frequencies in the mo on the perturbative solver speed. .. plot:: + :context: :include-source: import numpy as np @@ -127,6 +129,7 @@ See the :class:`.DysonSolver` API docs for more details. For our example Hamiltonian we configure the :class:`.DysonSolver` as follows: .. plot:: + :context: :include-source: import time @@ -166,6 +169,7 @@ over the interval ``[0, (T // dt) * dt]`` for an on-resonance drive with envelop attainable by these solvers. .. plot:: + :context: :include-source: from qiskit_dynamics import Signal @@ -188,6 +192,7 @@ attainable by these solvers. First run includes compile time. .. plot:: + :context: :include-source: import time @@ -203,6 +208,7 @@ Once JIT compilation has been performance we can benchmark the performance of th solver: .. plot:: + :context: :include-source: start_time = time.time() @@ -219,6 +225,7 @@ We now construct the same simulation using a standard solver to compare accuracy speed. .. plot:: + :context: :include-source: from qiskit_dynamics import Solver @@ -245,6 +252,7 @@ speed. Simulate with low tolerance for comparison to high accuracy solution. .. plot:: + :context: :include-source: yf_low_tol = ode_sim(1., 1e-13) @@ -254,6 +262,7 @@ Simulate with low tolerance for comparison to high accuracy solution. For speed comparison, compile at a tolerance with similar accuracy. .. plot:: + :context: :include-source: jit_ode_sim = jit(lambda amp: ode_sim(amp, 1e-8)) @@ -267,6 +276,7 @@ For speed comparison, compile at a tolerance with similar accuracy. Measure compiled time. .. plot:: + :context: :include-source: start_time = time.time() @@ -279,6 +289,7 @@ Measure compiled time. Confirm similar accuracy solution. .. plot:: + :context: :include-source: np.linalg.norm(yf_low_tol - yf_ode) @@ -295,6 +306,7 @@ Next, we repeat our example using the Magnus-based perturbative solver. Setup of matrix exponentiation to simulate over each fixed time step. .. plot:: + :context: :include-source: from qiskit_dynamics import MagnusSolver @@ -320,6 +332,7 @@ matrix exponentiation to simulate over each fixed time step. Setup simulation function. .. plot:: + :context: :include-source: @jit @@ -336,6 +349,7 @@ Setup simulation function. First run includes compile time. .. plot:: + :context: :include-source: start_time = time.time() @@ -347,6 +361,7 @@ First run includes compile time. Second run demonstrates speed of the simulation. .. plot:: + :context: :include-source: start_time = time.time() @@ -357,6 +372,7 @@ Second run demonstrates speed of the simulation. .. plot:: + :context: :include-source: np.linalg.norm(yf_magnus - yf_low_tol) diff --git a/qiskit_dynamics/pulse/__init__.py b/qiskit_dynamics/pulse/__init__.py index 75c1c0712..76697f16e 100644 --- a/qiskit_dynamics/pulse/__init__.py +++ b/qiskit_dynamics/pulse/__init__.py @@ -41,6 +41,7 @@ An example schedule, and the corresponding converted signals, is shown below. .. plot:: + :context: import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec diff --git a/qiskit_dynamics/signals/__init__.py b/qiskit_dynamics/signals/__init__.py index 839e1fdc9..751e8dbd0 100644 --- a/qiskit_dynamics/signals/__init__.py +++ b/qiskit_dynamics/signals/__init__.py @@ -143,6 +143,7 @@ of sampling just the envelope (and keeping the carrier analog). .. plot:: + :context: from qiskit_dynamics.signals import Signal, DiscreteSignal from matplotlib import pyplot as plt @@ -177,6 +178,7 @@ any assumptions about the time and frequency units which we interpret as ns and GHz, respectively. .. plot:: + :context: :include-source: import numpy as np