Examples of tables and plots available from a Workspace#

PyGSTi’s Workspace object is first a foremost a container and factory for plots and tables. At the most basic level, it can be used to generate nice output based on quantities (e.g. Model, DataSet, etc. objects) that you’ve computed or loaded within a notebook. For this, it’s useful to call init_notebook_mode with autodisplay=True (see below) so that you don’t have to .display() everything - display() gets called automatically when a plot or table is created.

Getting some results#

First, let’s run gate set tomography (GST) on the standard 1-qubit model to get some results to play with. We generate a few DataSet objects and then call run_long_sequence_gst to run GST, generating a ModelEstimateResults object (essentially a container for Model objects). For more details, see the tutorials GST overview tutorial, the tutorial on GST functions, and the tutorial explaining the ModelEstimateResults object.

import numpy as np
import pygsti
from pygsti.modelpacks import smq1Q_XYI
#The usual GST setup: we're going to run GST on the standard XYI 1-qubit model
target_model = smq1Q_XYI.target_model()
prep_fiducials = smq1Q_XYI.prep_fiducials()
meas_fiducials = smq1Q_XYI.meas_fiducials()
germs = smq1Q_XYI.germs()
maxLengths = [1,2]
listOfExperiments = pygsti.circuits.create_lsgst_circuits(
    target_model.operations.keys(), prep_fiducials, meas_fiducials, germs, maxLengths)
#Create some datasets for analysis
mdl_datagen1 = target_model.depolarize(op_noise=0.1, spam_noise=0.02)
mdl_datagen2 = target_model.depolarize(op_noise=0.05, spam_noise=0.01).rotate(rotate=(0.01,0.01,0.01))

ds1 = pygsti.data.simulate_data(mdl_datagen1, listOfExperiments, num_samples=1000,
                                            sample_error="binomial", seed=1234)
ds2 = pygsti.data.simulate_data(mdl_datagen2, listOfExperiments, num_samples=1000,
                                            sample_error="binomial", seed=1234)
ds3 = ds1.copy_nonstatic(); ds3.add_counts_from_dataset(ds2); ds3.done_adding_data()
#Run GST on all three datasets
target_model.set_all_parameterizations("full TP")
results1 = pygsti.run_long_sequence_gst(ds1, target_model, prep_fiducials, meas_fiducials, germs, maxLengths, verbosity=0)
results2 = pygsti.run_long_sequence_gst(ds2, target_model, prep_fiducials, meas_fiducials, germs, maxLengths, verbosity=0)
results3 = pygsti.run_long_sequence_gst(ds3, target_model, prep_fiducials, meas_fiducials, germs, maxLengths, verbosity=0)

#make some shorthand variable names for later
tgt = results1.estimates['GateSetTomography'].models['target']

ds1 = results1.dataset
ds2 = results2.dataset
ds3 = results3.dataset

mdl1 = results1.estimates['GateSetTomography'].models['stdgaugeopt']
mdl2 = results2.estimates['GateSetTomography'].models['stdgaugeopt']
mdl3 = results3.estimates['GateSetTomography'].models['stdgaugeopt']

gss = results1.circuit_lists['final']

Exporting notebooks to HTML#

If you want, you can save figure-containing notebooks (like this one) as an HTML file by going to File => Download As => HTML in the Jupyter menu. The resulting file will retain all of the plot interactivity, so long as its in a directory with an offline folder (because we set connected=False above).