Skip to content

Commit

Permalink
add util
Browse files Browse the repository at this point in the history
  • Loading branch information
Weilei Zeng at qlab01 committed Apr 26, 2024
1 parent de78338 commit 71f51a3
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# define codes with k=1 and k=2
#result_folder='result/unchecked/' #move to top of file
code1='NA NA NA n7k1d3-x3z3dx3dz3-0 n15k1d4-x8z6dx4dz4-0 n25k1d5-x13z11dx5dz5-0'.split()
code2='NA NA NA n11k2d3-x4z5dx3dz3-0 n18k2d4-x8z8dx4dz4-0 n27k2d5-x13z12dx5dz5-0'.split()
code2='NA NA NA n11k2d3-x4z5dx3dz3-1 n18k2d4-x8z8dx4dz4-1 n27k2d5-x13z12dx5dz5-1'.split()
code3='NA NA NA n11k3d3-x4z4dx3dz3-0 n19k3d4-x9z7dx4dz4-0 n29k3d5-x13z13dx5dz5-0'.split()

code1='NA NA NA n7k1d3-x3z3dx3dz3 n15k1d4-x8z6dx4dz4 n25k1d5-x13z11dx5dz5'.split()
code2='NA NA NA n11k2d3-x4z5dx3dz3 n18k2d4-x8z8dx4dz4 n27k2d5-x13z12dx5dz5'.split()
code3='NA NA NA n11k3d3-x4z4dx3dz3 n19k3d4-x9z7dx4dz4 n29k3d5-x13z13dx5dz5'.split()

codes=[None,code1,code2,code3]


import argparse

parser = argparse.ArgumentParser()

parser.add_argument("--k1",type=int,help="logical qubits of the first code")
parser.add_argument("--d1",type=int,help="distance")
parser.add_argument("--k2",type=int)
parser.add_argument("--d2",type=int)
parser.add_argument("--index",type=int,help="identification index for codes with same parameters in the data base")

"""
parser.add_argument(
"--name", action="store"
) # Equivalent to parser.add_argument("--name")
parser.add_argument("--pi", action="store_const", const=3.14)
parser.add_argument("--is-valid", action="store_true")
parser.add_argument("--is-invalid", action="store_false")
parser.add_argument("--item", action="append")
parser.add_argument("--repeated", action="append_const", const=42)
parser.add_argument("--add-one", action="count")
parser.add_argument(
"--version", action="version", version="%(prog)s 0.1.0"
)
"""
args = parser.parse_args()

print(args)




# Python
# whatever.py
#import sys
#sys.stdout.write('abc')
#sys.exit(0)

# In your shell
#OUT=`python whatever.py`
#echo $OUT
# Will print abc, and it's stored in the variable `OUT` for later consumption.


codelist=list(range(10))

def get_code(k1,d1,k2,d2,index):
print(f"{codes[k1][d1]}-{index}")
print(f"{codes[k2][d2]}-{index}")

if args.k1:
get_code(k1=args.k1,d1=args.d1,k2=args.k2,d2=args.d2,index=args.index)
else:
get_code(k1=1,d1=3,k2=1,d2=3,index=0)

#if __name__=="__main__":
# get_code


#python3 util.py --k1 2 --d1 3 --k2 2 --d2 5 --index 3

0 comments on commit 71f51a3

Please sign in to comment.