14
14
from ..densitymatrix import DMCircuit
15
15
from ..gates import num_to_tensor , array_to_tensor , _swap_matrix
16
16
from ..channels import depolarizingchannel
17
+ from ..commons import sgates
17
18
18
19
logger = logging .getLogger (__name__ )
19
20
92
93
circuit : Circuit , symbol : Union [Tensor , float ] = None , g : Graph = None
93
94
) -> Circuit : # compatible with graph mode
94
95
symbol0 = _resolve (symbol )
95
- if gate .lower () in Circuit . sgates :
96
+ if gate .lower () in sgates :
96
97
for n in range (circuit ._nqubits ):
97
98
getattr (circuit , gate )(n )
98
99
else :
@@ -102,7 +103,7 @@ def f(
102
103
103
104
f .__doc__ = """%slayer""" % gate
104
105
f .__repr__ = """%slayer""" % gate # type: ignore
105
- f .__trainable__ = False if gate in Circuit . sgates else True # type: ignore
106
+ f .__trainable__ = False if gate in sgates else True # type: ignore
106
107
setattr (thismodule , gate + "layer" , f )
107
108
108
109
@@ -118,7 +119,7 @@ def generate_any_gate_layer(gate: str) -> None:
118
119
def f (
119
120
circuit : Circuit , symbol : Union [Tensor , float ] = None , g : Graph = None
120
121
) -> Circuit : # compatible with graph mode
121
- if gate .lower () in Circuit . sgates :
122
+ if gate .lower () in sgates :
122
123
for n in range (circuit ._nqubits ):
123
124
getattr (circuit , gate )(n )
124
125
else :
@@ -128,7 +129,7 @@ def f(
128
129
129
130
f .__doc__ = """any%slayer""" % gate
130
131
f .__repr__ = """any%slayer""" % gate # type: ignore
131
- f .__trainable__ = False if gate in Circuit . sgates else True # type: ignore
132
+ f .__trainable__ = False if gate in sgates else True # type: ignore
132
133
setattr (thismodule , "any" + gate + "layer" , f )
133
134
134
135
@@ -259,7 +260,7 @@ def f(circuit: Circuit, symbol: Tensor, g: Graph = None) -> Circuit:
259
260
260
261
f .__doc__ = """%s_%s_block""" % (d1 , d2 )
261
262
f .__repr__ = """%s_%s_block""" % (d1 , d2 ) # type: ignore
262
- f .__trainable__ = False if (d1 in Circuit . sgates ) and (d2 in Circuit . sgates ) else True # type: ignore
263
+ f .__trainable__ = False if (d1 in sgates ) and (d2 in sgates ) else True # type: ignore
263
264
setattr (thismodule , "%s_%s_block" % (d1 , d2 ), f )
264
265
265
266
0 commit comments