{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pygsti\n", "from pygsti.objects import Label" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "gs = [Label('Gh',0),Label('Gh',0),Label('Gcnot',(0,1))]\n", "c = pygsti.obj.Circuit(gatestring=gs,num_lines=2,parallelize=False)\n", "c.done_editing()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(c)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "c.predicted_infidelity?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "c.line_items" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "s = '[Gy(2)][|][Gx(0)Gy(1)Gy(1)][Gy(2)][Gx(0)Gy(1)]'" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ssplit = s.split('][')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ssplit" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "newsplit = []\n", "for ss in ssplit:\n", " ss = ss.strip('[')\n", " ss = ss.strip(']')\n", " newsplit.append(ss)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "newsplit" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "temp = []\n", "for ss in newsplit:\n", " out = ss.split(')G')\n", " print(out)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from pygsti.objects.gatestring import GateString as GS" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "gs = GS(['Gh',])" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "gs.str" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pygsti\n", "\n", "gate_names = ['Gp','Gh']\n", "pspec = pygsti.obj.ProcessorSpec(1,gate_names,verbosity=0)\n", "\n", "c = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label('Gp',0)],num_lines=1)\n", "print(c.simulate(pspec.models['target']))\n", "\n", "c = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label('Gh',0)],num_lines=1)\n", "print(c.simulate(pspec.models['target']))\n", "\n", "gate_names = ['Gi','Gp','Gh','Gcnot']\n", "pspec = pygsti.obj.ProcessorSpec(2,gate_names,verbosity=0)\n", "c = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label('Gh',0)],num_lines=4)\n", "print(c.simulate(pspec.models['target']))\n", "\n", "gate_names = ['Gi','Gp','Gh','Gcnot','Gxpi','Gypi','Gzpi']\n", "pspec = pygsti.obj.ProcessorSpec(2,gate_names,verbosity=0)\n", "c = pygsti.obj.Circuit(num_lines=2)\n", "print(c.simulate(pspec.models['target']))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "circuit = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label('Gh',0),pygsti.obj.Label('Gh',1),pygsti.obj.Label('Gp',0)],num_lines=2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(circuit)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\n", "n = pspec.number_of_qubits\n", "paulilist = ['I','X','Y','Z']\n", "d = circuit.depth()\n", "for i in range(0,d+1):\n", " pcircuit = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label(paulilist[np.random.randint(4)],k) for k in range(n)],num_lines=n)\n", " pcircuit.change_gate_library(pspec.compilations['absolute'])\n", " circuit.insert_circuit(pcircuit,d-i)\n", " circuit.replace_gatename('I','Gi')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(circuit)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "s,p = pygsti.random_clifford(2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "c = pygsti.algorithms.compile_clifford" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "c = pygsti.algorithms.compile_clifford(s,p,pspec,pauli_randomize=True)\n", "c.replace_gatename('I','Gi')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(c)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }