{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "As noted in Tutorial 00, `pygsti` can provide many reports or presentation slides.\n", "\n", "In this tutorial, we look at how to customize some of the output of `pygsti`'s report generating module." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "#Import the GST module -- you probably want this at the beginning of every notebook\n", "import pygsti\n", "import json" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Creating reports is a method of the `pygsti.report.Results` object. Below, we create such an object, and then initialize it with the appropriate fiducials, germs, maximum lengths, etc.\n", "\n", "It's important to note that the `pygsti.report.Results` object requires an argument to indicate which objective function you wish to score the estimate using. It's recommended that, if you ran MC2GST, you use the `\"chi2\"` argument, while if you ran MLGST, you use `\"logL\"`. Otherwise, you will score your estimate based on an objective function you weren't optimizing over, so your scores may be rather weird!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Creating reports is a method of the `pygsti.report.Results` object. Below, we create such an object, and then initialize it with the appropriate fiducials, germs, maximum lengths, etc.\n", "\n", "It's important to note that the `pygsti.report.Results` object requires an argument to indicate which objective function you wish to score the estimate using. It's recommended that, if you ran MC2GST, you use the `\"chi2\"` argument, while if you ran MLGST, you use `\"logL\"`. Otherwise, you will score your estimate based on an objective function you weren't optimizing over, so your scores may be rather weird!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, we'll make smaller reports that don't contain any confidence intervals for the estimates,\n", "nor any appendices.\n", "\n", "NOTE: In order for you to create PowerPoint files, you'll have to have `python-pptx` installed on your system." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [], "source": [ "# Follow Algorithm tutorial to generate LSGST gatesets\n", "gs_target = pygsti.io.load_gateset(\"tutorial_files/Example_Gateset.txt\")\n", "gs_target.set_basis(\"gm\",2)\n", "ds = pygsti.io.load_dataset(\"tutorial_files/Example_Dataset.txt\", cache=True)\n", "fiducialList = pygsti.io.load_gatestring_list(\"tutorial_files/Example_FiducialList.txt\")\n", "\n", "#Run LGST to get an initial estimate for the gates in gs_target based on the data in ds\n", "specs = pygsti.construction.build_spam_specs(fiducialGateStrings=fiducialList)\n", "gs_lgst = pygsti.do_lgst(ds, specs, targetGateset=gs_target, svdTruncateTo=4, verbosity=1)\n", "\n", "#Gauge optimize the result to match the target gateset\n", "gs_lgst_after_gauge_opt = pygsti.optimize_gauge(gs_lgst, \"target\", targetGateset=gs_target)\n", "\n", "#Contract the result to CPTP\n", "gs_clgst = pygsti.contract(gs_lgst_after_gauge_opt, \"CPTP\")\n", "\n", "#Get lists of gate strings for successive iterations of MC2GST to use\n", "specs = pygsti.construction.build_spam_specs(fiducialGateStrings=fiducialList)\n", "germList = pygsti.io.load_gatestring_list(\"tutorial_files/Example_GermsList.txt\")\n", "maxLengthList = json.load(open(\"tutorial_files/Example_maxLengths.json\",\"r\"))\n", "lsgstListOfLists = [ pygsti.io.load_gatestring_list(\"tutorial_files/Example_LSGSTlist%d.txt\" % l) for l in maxLengthList]\n", " \n", "gs_lsgst_list = pygsti.do_iterative_mc2gst(ds, gs_clgst, lsgstListOfLists, verbosity=2,\n", " minProbClipForWeighting=1e-6, probClipInterval=(-1e6,1e6),\n", " returnAll=True )\n", "\n", "go_gatesets = [ pygsti.optimize_gauge(gs, \"target\", targetGateset=gs_target, gateWeight=1, spamWeight=0.001) for gs in gs_lsgst_list]" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "res = pygsti.report.Results()\n", "res.init_Ls_and_germs(\"chi2\", gs_target, ds, gs_clgst, maxLengthList, germList,\n", " go_gatesets, lsgstListOfLists, fiducialList, fiducialList, \n", " pygsti.construction.repeat_with_max_length, False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [], "source": [ "#Make smaller reports (no confidence intervals or appendicies)\n", "res.create_full_report_pdf(filename=\"tutorial_files/Example_reportB.pdf\", verbosity=2, confidenceLevel=None,\n", " debugAidsAppendix=False, gaugeOptAppendix=False,\n", " pixelPlotAppendix=False, whackamoleAppendix=False)\n", "\n", "res.create_brief_report_pdf(filename=\"tutorial_files/Example_briefB.pdf\", verbosity=2, confidenceLevel=None)\n", "\n", "res.create_presentation_pdf(filename=\"tutorial_files/Example_slidesB.pdf\", verbosity=2, confidenceLevel=None,\n", " debugAidsAppendix=False, pixelPlotAppendix=False, whackamoleAppendix=False)\n", "\n", "res.create_presentation_ppt(filename=\"tutorial_files/Example_slidesB.ppt\", verbosity=2, confidenceLevel=None,\n", " debugAidsAppendix=False, pixelPlotAppendix=False, whackamoleAppendix=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [], "source": [ "res.create_full_report_pdf(filename=\"tutorial_files/Example_report.pdf\", verbosity=2, confidenceLevel=95,\n", " debugAidsAppendix=True, gaugeOptAppendix=True,\n", " pixelPlotAppendix=True, whackamoleAppendix=True)\n", "\n", "res.create_brief_report_pdf(filename=\"tutorial_files/Example_brief.pdf\", verbosity=2, confidenceLevel=95)\n", "\n", "res.create_presentation_pdf(filename=\"tutorial_files/Example_slides.pdf\", verbosity=2, confidenceLevel=95,\n", " debugAidsAppendix=True, pixelPlotAppendix=True, whackamoleAppendix=True)\n", "\n", "res.create_presentation_ppt(filename=\"tutorial_files/Example_slides.ppt\", verbosity=2, confidenceLevel=95,\n", " debugAidsAppendix=True, pixelPlotAppendix=True, whackamoleAppendix=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pygsti.report.latex as LU\n", "from imp import reload\n", "reload(LU)\n", "LU.latex_value(1.2e30,2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 0 }