Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codedistance/code_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def CSSSXLX2S(SX,LX=None):
# codeDict = CSS2Dict(SX,SZ)
# Lx,Lz = getLogicalPaulis(S)
# print(f'getLogicalPaulis: {len(Lx)}, {len(Lz)}')
# print(f'CSS2Dict: [{codeDict['n']},{codeDict['k']},{codeDict['d']}]')
# print(f"CSS2Dict: [{codeDict['n']},{codeDict['k']},{codeDict['d']}]")
return S

def getLogicalPaulis(S):
Expand Down
4 changes: 2 additions & 2 deletions codedistance/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def codeDistance(H,L=None,tB=1,method='QDistRndMW',params={},seed=None):
if wDict is not None and res['d'] < len(wDict):
res['R'] = wDict[res['d']]
res['T'] = np.sum(wDict)
if params['LOCheck']:
if 'LOCheck' in params:
LOcheck(res['L'],H,L,tB)
return res

Expand Down Expand Up @@ -1834,7 +1834,7 @@ def pySATdist(H,L,params):
myFile = f"{myDir}/{randomFilename()}.wcnf"
with open(myFile,'w') as f:
f.write(SATstr)
funcParams = [f'{params['pySATbinary']}.py', '-vv','-s',params['pySATsolver']]
funcParams = [f"{params['pySATbinary']}.py", '-vv','-s',params['pySATsolver']]
if params['pySATbinary'] == 'lsu':
## LSU doesn't print model by default
funcParams.append("-m")
Expand Down
2 changes: 1 addition & 1 deletion examples/BB_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def uvProcess(l, m, uVec, vVec,c2,certList,outfile):
dX = len(lo)
## write to file
with open(outfile,'a') as f:
f.write(f'{myCode['n']}\t{myCode['k']}\t{dZ}\t{dX}\t{l}\t{m}\t{"\t".join(map(str,uVec))}\t{"\t".join(map(str,vVec))}\t{XCert}\n')
f.write(f"{myCode['n']}\t{myCode['k']}\t{dZ}\t{dX}\t{l}\t{m}\t{'\t'.join(map(str,uVec))}\t{'\t'.join(map(str,vVec))}\t{XCert}\n")


def BBSample(l,m,c,vCycles,outfile,sampleSize):
Expand Down
2 changes: 1 addition & 1 deletion examples/bivariate_bicycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def BBCodeList():
startTimer()
for codeDict in generated_bb_codes:
Hx, Hz = BBIBM(codeDict["l"], codeDict["m"], codeDict["Apoly"], codeDict["Bpoly"])
name = f'BB{codeDict['n']}'
name = f"BB{codeDict['n']}"
myCode = CSS2Dict(Hx, Hz, d=codeDict["d"])
if myCode['k'] > 0:
codeList.append(myCode)
Expand Down
12 changes: 6 additions & 6 deletions examples/exampleCSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@
for method in methods:
res = CSScodeDistance(Hx,Hz,method=method,params=params,seed=0)
print(method)
print(f'Calculated distance: {res['d']}')
print(f'Time Taken: {elapsedTime()}')
print(f"Calculated distance: {res['d']}")
print(f"Time Taken: {elapsedTime()}")
if (res['T'] > 1):
print(f'Total Trials: {res['T']}')
print(f'Trials at d={res['d']}: {res['R']}')
print(f"Total Trials: {res['T']}")
print(f"Trials at d={res['d']}: {res['R']}")
lo = res['L']
if (np.sum(lo)) > 0:
r1,V = HowRes(Hz,lo,2)
print(f'lo: {bin2Set(lo)}')
print(f"lo: {bin2Set(lo)}")
lo = ZMat2D(lo)
r2 = matMul(lo,Hx.T,2)
print(f'Logical Operator Check: commutes with stabilsers {np.sum(r2)==0}; non-trivial {np.sum(r1)!=0}')
print(f"Logical Operator Check: commutes with stabilsers {np.sum(r2)==0}; non-trivial {np.sum(r1)!=0}")
print("###########################################\n")
6 changes: 3 additions & 3 deletions examples/exampleCircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@
for method in methods:
print(method)
res = circuitDistance(qc,method=method,params=params,seed=0)
print(f'Calculated distance: {res['d']}')
print(f"Calculated distance: {res['d']}")
print(f'Time Taken: {elapsedTime()}')
if (res['T'] > 1):
print(f'Total Trials: {res['T']}')
print(f'Trials at d={res['d']}: {res['R']}')
print(f"Total Trials: {res['T']}")
print(f"Trials at d={res['d']}: {res['R']}")
lo = res['L']
if (np.sum(lo)) > 0:
# r1,V = HowRes(Hz,lo,2)
Expand Down
12 changes: 6 additions & 6 deletions examples/exampleQECC.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@
for method in methods:
res = codeDistance(S,L=None,tB=tB,method=method,params=params,seed=0)
print(method)
print(f'Calculated distance: {res['d']}')
print(f'Time Taken: {elapsedTime()}')
print(f"Calculated distance: {res['d']}")
print(f"Time Taken: {elapsedTime()}")
if (res['T'] > 1):
print(f'Total Trials: {res['T']}')
print(f'Trials at d={res['d']}: {res['R']}')
print(f"Total Trials: {res['T']}")
print(f"Trials at d={res['d']}: {res['R']}")
lo = res['L']
if (np.sum(lo)) > 0:
r1,V = HowRes(S,lo,2)
print(f'lo: {bin2Set(lo)}')
print(f"lo: {bin2Set(lo)}")
lo = ZMat2D(lo)
if tB == 2:
lo = XZhad(lo)
r2 = matMul(lo,S.T,2)
print(f'Logical Operator Check: commutes with stabilisers {np.sum(r2)==0}; non-trivial {np.sum(r1)!=0}')
print(f"Logical Operator Check: commutes with stabilisers {np.sum(r2)==0}; non-trivial {np.sum(r1)!=0}")
print("###########################################\n")