File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,11 @@ def auto_similarity(
119119 flattened_circuit : list [GateOperation ] = list (cirq .flatten_op_tree (circuit ))
120120 weights = {}
121121 for i in range (len (flattened_circuit )):
122+ if not cirq .has_unitary (flattened_circuit [i ]):
123+ continue
122124 for j in range (i + 1 , len (flattened_circuit )):
125+ if not cirq .has_unitary (flattened_circuit [j ]):
126+ continue
123127 op1 = flattened_circuit [i ]
124128 op2 = flattened_circuit [j ]
125129 if can_be_parallel (op1 , op2 ):
@@ -297,14 +301,20 @@ def colorize(
297301 for epoch in epochs :
298302 oneq_gates = []
299303 twoq_gates = []
304+ nonunitary_gates = []
300305 for gate in epoch :
301- if len (gate .val .qubits ) == 1 :
306+ if not cirq .has_unitary (gate .val ):
307+ nonunitary_gates .append (gate .val )
308+ elif len (gate .val .qubits ) == 1 :
302309 oneq_gates .append (gate .val )
303310 elif len (gate .val .qubits ) == 2 :
304311 twoq_gates .append (gate .val )
305312 else :
306313 raise RuntimeError ("Unsupported gate type" )
307314
315+ if len (nonunitary_gates ) > 0 :
316+ yield nonunitary_gates
317+
308318 if len (oneq_gates ) > 0 :
309319 yield oneq_gates
310320
You can’t perform that action at this time.
0 commit comments