9
9
import itertools as _itertools
10
10
import networkx as _nx
11
11
12
+ import tqdm
13
+
12
14
import numpy as _np
13
15
import json as _json
14
16
@@ -30,7 +32,7 @@ def sample_lcu_subcircuits(lcu_circ, width_depths, num_samples, strategy='simple
30
32
num_test_samples = num_test_samples , rand_state = rand_state ,
31
33
arch = arch , subgraph_cache = subgraph_cache )
32
34
33
- def sample_subcircuits (full_circs : Union [_Circuit , Dict [ str , _Circuit ]],
35
+ def sample_subcircuits (full_circs : Union [_Circuit , List [ _Circuit ]],
34
36
width_depths : Dict [int , List [int ]],
35
37
num_samples_per_circ : int ,
36
38
strategy : Union [str , Callable [..., Any ]] = 'simple' ,
@@ -54,11 +56,11 @@ def sample_subcircuits(full_circs: Union[_Circuit, Dict[str, _Circuit]],
54
56
subcircuits = _defaultdict (list )
55
57
counter = 0
56
58
57
- if not isinstance (full_circs , dict ): # package pygsti circuit into dict if dict was not provided.
58
- full_circs = { 'default name' : full_circs }
59
+ if not isinstance (full_circs , list ): # package pygsti circuit into dict if dict was not provided.
60
+ full_circs = [ full_circs ]
59
61
60
- for name , full_circ in full_circs . items ( ):
61
- print (f'sampling circuit { name } ' )
62
+ for full_circ in tqdm . tqdm ( full_circs , ascii = True ):
63
+ # print(f'sampling circuit {name}')
62
64
for w , ds in width_depths .items ():
63
65
print (f'Width: { w } , Depth: ' , end = '' )
64
66
for d in ds :
@@ -83,7 +85,7 @@ def sample_subcircuits(full_circs: Union[_Circuit, Dict[str, _Circuit]],
83
85
raise ValueError ("'strategy' is not a function or known string" )
84
86
85
87
for subcirc , drop in zip (subcircs , drops ):
86
- print (subcirc )
88
+ # print(subcirc)
87
89
subcircuits [subcirc ].append ({'width' : w , 'physical_depth' : d , 'dropped_gates' : drop , 'id' : counter })
88
90
counter += 1
89
91
@@ -268,7 +270,7 @@ def simple_weighted_subcirc_selection(full_circ, width, depth, num_subcircs=1, b
268
270
269
271
assert len (subcirc_layers ) == len (layer_names ), "Relationship between layers and layer names is not one to one!"
270
272
271
- print (len (subcirc_layers ))
273
+ # print(len(subcirc_layers))
272
274
273
275
for i in range (len (subcirc_layers )):
274
276
scl = subcirc_layers [i ]
0 commit comments