{"cells": [{"cell_type": "markdown", "source": ["# Replica of tutorial 20, built using Python"], "metadata": {}}, {"cell_type": "code", "source": ["import numpy as np\n", "import pygsti\n", "from pygsti.construction import std1Q_XYI\n", "\n", "#The usual GST setup: we're going to run GST on the standard XYI 1-qubit gateset\n", "gs_target = std1Q_XYI.gs_target\n", "fiducials = std1Q_XYI.fiducials\n", "germs = std1Q_XYI.germs\n", "maxLengths = [1,2,4,8]\n", "listOfExperiments = pygsti.construction.make_lsgst_experiment_list(\n", " gs_target.gates.keys(), fiducials, fiducials, germs, maxLengths)\n", "\n", "#Create some datasets for analysis\n", "gs_datagen1 = gs_target.depolarize(gate_noise=0.1, spam_noise=0.001)\n", "gs_datagen2 = gs_target.depolarize(gate_noise=0.05, spam_noise=0.01).rotate(rotate=0.01)\n", "\n", "ds1 = pygsti.construction.generate_fake_data(gs_datagen1, listOfExperiments, nSamples=1000,\n", " sampleError=\"binomial\", seed=1234)\n", "ds2 = pygsti.construction.generate_fake_data(gs_datagen2, listOfExperiments, nSamples=1000,\n", " sampleError=\"binomial\", seed=1234)\n", "ds3 = ds1.copy_nonstatic(); ds3.add_counts_from_dataset(ds2); ds3.done_adding_data()\n", "\n", "#Run GST on all three datasets\n", "gs_target.set_all_parameterizations(\"TP\")\n", "results1 = pygsti.do_long_sequence_gst(ds1, gs_target, fiducials, fiducials, germs, maxLengths, verbosity=0)\n", "results2 = pygsti.do_long_sequence_gst(ds2, gs_target, fiducials, fiducials, germs, maxLengths, verbosity=0)\n", "results3 = pygsti.do_long_sequence_gst(ds3, gs_target, fiducials, fiducials, germs, maxLengths, verbosity=0)\n", "\n", "#make some shorthand variable names for later\n", "tgt = results1.estimates['default'].gatesets['target']\n", "\n", "ds1 = results1.dataset\n", "ds2 = results2.dataset\n", "ds3 = results3.dataset\n", "\n", "gs1 = results1.estimates['default'].gatesets['go0']\n", "gs2 = results2.estimates['default'].gatesets['go0']\n", "gs3 = results3.estimates['default'].gatesets['go0']\n", "\n", "gss = results1.gatestring_structs['final']\n"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "markdown", "source": ["After running GST, a `Workspace` object can be used to interpret the results:"], "metadata": {}}, {"cell_type": "code", "source": ["from pygsti.report import workspace\n", "ws = workspace.Workspace()\n", "ws.init_notebook_mode(connected=False, autodisplay=True)"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.GatesVsTargetTable(gs1, tgt)"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.SpamVsTargetTable(gs2, tgt)"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.ColorBoxPlot((\"chi2\",\"logl\"), gss, ds1, gs1, boxLabels=True)"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.FitComparisonTable(gss.Ls, results1.gatestring_structs['iteration'],\n", " results1.estimates['default'].gatesets['iteration estimates'], ds1)"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.FitComparisonTable([\"GS1\",\"GS2\",\"GS3\"], [gss, gss, gss], [gs1,gs2,gs3], ds1, Xlabel=\"GateSet\")"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.ChoiTable(gs3, display=('matrix','barplot'))"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.GateMatrixPlot(gs1['Gx'],scale=1.5, boxLabels=True)\n", "ws.GateMatrixPlot(pygsti.tools.error_generator(gs1['Gx'], tgt['Gx']), scale=1.5)"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.ErrgenTable(gs3,tgt)"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.PolarEigenvaluePlot([np.linalg.eigvals(gs2['Gx'])],[\"purple\"],scale=1.5)"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}, {"cell_type": "code", "source": ["ws.GateEigenvalueTable(gs2, display=('evals','polar'))"], "outputs": [], "metadata": {"collapsed": false}, "execution_count": 0}], "nbformat": 4, "metadata": {"kernelspec": {"language": "python", "name": "python3", "display_name": "Python 3"}, "language_info": {"version": "3.5.2", "file_extension": ".py", "name": "python", "codemirror_mode": {"version": 3, "name": "ipython"}, "pygments_lexer": "ipython3", "mimetype": "text/x-python", "nbconvert_exporter": "python"}}, "nbformat_minor": 2}