Skip to content

Commit c6f8e8b

Browse files
[minor] rm the __all__ to more cleanly fix operator alias bug (#257)
1 parent ba8321c commit c6f8e8b

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

torchquantum/operator/standard_gates/__init__.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
from .xx_min_yy import XXMINYY
5555
from .xx_plus_yy import XXPLUSYY
5656

57-
all_variables = [
57+
_all_variables = [
5858
EchoedCrossResonance,
5959
ECR,
6060
GlobalPhase,
@@ -127,16 +127,8 @@
127127
XXPLUSYY,
128128
]
129129

130-
__all__ = [a().__class__.__name__ for a in all_variables]
131-
132-
# add the aliased and incomptaible classes
133-
__all__.extend(["U", "CH", "QubitUnitary", "QubitUnitaryFast"])
134-
135-
# add the dictionary
136-
__all__.extend(["op_name_dict", "fixed_ops", "parameterized_ops"])
137-
138130
# create the operations dictionary
139-
op_name_dict = {x.op_name: x for x in all_variables}
131+
op_name_dict = {_x.op_name: _x for _x in _all_variables}
140132

141133
# add aliases as well
142134
op_name_dict.update(
@@ -161,5 +153,6 @@
161153
}
162154
)
163155

164-
fixed_ops = [a().__class__.__name__ for a in all_variables if a.num_params == 0]
165-
parameterized_ops = [a().__class__.__name__ for a in all_variables if a.num_params > 0]
156+
# TODO: make this compatible with aliases
157+
fixed_ops = [_a().__class__.__name__ for _a in _all_variables if _a.num_params == 0]
158+
parameterized_ops = [_a().__class__.__name__ for _a in _all_variables if _a.num_params > 0]

0 commit comments

Comments
 (0)