import pygsti
from pygsti.objects import Label
gs = [Label('Gh',0),Label('Gh',0),Label('Gcnot',(0,1))]
c = pygsti.obj.Circuit(gatestring=gs,num_lines=2,parallelize=False)
c.done_editing()
print(c)
c.predicted_infidelity?
c.line_items
s = '[Gy(2)][|][Gx(0)Gy(1)Gy(1)][Gy(2)][Gx(0)Gy(1)]'
ssplit = s.split('][')
ssplit
newsplit = []
for ss in ssplit:
ss = ss.strip('[')
ss = ss.strip(']')
newsplit.append(ss)
newsplit
temp = []
for ss in newsplit:
out = ss.split(')G')
print(out)
from pygsti.objects.gatestring import GateString as GS
gs = GS(['Gh',])
gs.str
import pygsti
gate_names = ['Gp','Gh']
pspec = pygsti.obj.ProcessorSpec(1,gate_names,verbosity=0)
c = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label('Gp',0)],num_lines=1)
print(c.simulate(pspec.models['target']))
c = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label('Gh',0)],num_lines=1)
print(c.simulate(pspec.models['target']))
gate_names = ['Gi','Gp','Gh','Gcnot']
pspec = pygsti.obj.ProcessorSpec(2,gate_names,verbosity=0)
c = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label('Gh',0)],num_lines=4)
print(c.simulate(pspec.models['target']))
gate_names = ['Gi','Gp','Gh','Gcnot','Gxpi','Gypi','Gzpi']
pspec = pygsti.obj.ProcessorSpec(2,gate_names,verbosity=0)
c = pygsti.obj.Circuit(num_lines=2)
print(c.simulate(pspec.models['target']))
circuit = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label('Gh',0),pygsti.obj.Label('Gh',1),pygsti.obj.Label('Gp',0)],num_lines=2)
print(circuit)
import numpy as np
n = pspec.number_of_qubits
paulilist = ['I','X','Y','Z']
d = circuit.depth()
for i in range(0,d+1):
pcircuit = pygsti.obj.Circuit(gatestring=[pygsti.obj.Label(paulilist[np.random.randint(4)],k) for k in range(n)],num_lines=n)
pcircuit.change_gate_library(pspec.compilations['absolute'])
circuit.insert_circuit(pcircuit,d-i)
circuit.replace_gatename('I','Gi')
print(circuit)
s,p = pygsti.random_clifford(2)
c = pygsti.algorithms.compile_clifford
c = pygsti.algorithms.compile_clifford(s,p,pspec,pauli_randomize=True)
c.replace_gatename('I','Gi')
print(c)