-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutil.py
73 lines (53 loc) · 2.21 KB
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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