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 do_long_sequence_gst to run GST, generating a Results 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 Results object.

In [1]:
import numpy as np
import pygsti
from pygsti.construction import std1Q_XYI
In [2]:
#The usual GST setup: we're going to run GST on the standard XYI 1-qubit model
target_model = std1Q_XYI.target_model()
fiducials = std1Q_XYI.fiducials
germs = std1Q_XYI.germs
maxLengths = [1,2]
listOfExperiments = pygsti.construction.make_lsgst_experiment_list(
    target_model.operations.keys(), fiducials, fiducials, germs, maxLengths)
In [3]:
#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.construction.generate_fake_data(mdl_datagen1, listOfExperiments, nSamples=1000,
                                            sampleError="binomial", seed=1234)
ds2 = pygsti.construction.generate_fake_data(mdl_datagen2, listOfExperiments, nSamples=1000,
                                            sampleError="binomial", seed=1234)
ds3 = ds1.copy_nonstatic(); ds3.add_counts_from_dataset(ds2); ds3.done_adding_data()
In [4]:
#Run GST on all three datasets
results1 = pygsti.do_long_sequence_gst(ds1, target_model, fiducials, fiducials, germs, maxLengths, verbosity=0)
results2 = pygsti.do_long_sequence_gst(ds2, target_model, fiducials, fiducials, germs, maxLengths, verbosity=0)
results3 = pygsti.do_long_sequence_gst(ds3, target_model, fiducials, fiducials, germs, maxLengths, verbosity=0)

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

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

mdl1 = results1.estimates['default'].models['go0']
mdl2 = results2.estimates['default'].models['go0']
mdl3 = results3.estimates['default'].models['go0']

gss = results1.circuit_structs['final']

Now that we have some results, let's create a Workspace and make some plots and tables.

To get tables and plots to display properly, one must run init_notebook_mode. The connected argument indicates whether you want to rely on an active internet connection. If True, then resources will be loaded from the web (e.g. a CDN), and if you save a notebook as HTML the file size may be smaller. If False, then all the needed resources (except MathJax) are provided by pyGSTi, and an offline directory is automatically created in the same directory as your notebook. This directory contains all the necessary resources, and must "tag along" with the notebook and any saved-as-HTML versions of it in order for everything to work. The second argument, autodisplay, determines whether tables and plots are automatically displayed when they are created. If autodisplay=False, one must call the display() member function of a table or plot to display it.

In [5]:
from pygsti.report import workspace
w = workspace.Workspace()
w.init_notebook_mode(connected=False, autodisplay=True)