18
18
19
19
from qiskit .circuit .parameterexpression import ParameterExpression
20
20
from qiskit .circuit .exceptions import CircuitError
21
+ from qiskit ._accelerate .circuit import StandardGate
21
22
from .annotated_operation import AnnotatedOperation , ControlModifier , PowerModifier
22
23
from .instruction import Instruction
23
24
@@ -33,6 +34,7 @@ def __init__(
33
34
label : str | None = None ,
34
35
duration = None ,
35
36
unit = "dt" ,
37
+ _skip_validation = False ,
36
38
) -> None :
37
39
"""Create a new gate.
38
40
@@ -42,6 +44,7 @@ def __init__(
42
44
params: A list of parameters.
43
45
label: An optional label for the gate.
44
46
"""
47
+ self ._skip_validation = _skip_validation
45
48
self .definition = None
46
49
super ().__init__ (name , num_qubits , 0 , params , label = label , duration = duration , unit = unit )
47
50
@@ -238,7 +241,9 @@ def broadcast_arguments(self, qargs: list, cargs: list) -> Iterable[tuple[list,
238
241
else :
239
242
raise CircuitError ("This gate cannot handle %i arguments" % len (qargs ))
240
243
241
- def validate_parameter (self , parameter ):
244
+ def validate_parameter (self , parameter , _force_validation = False ):
245
+ if (isinstance (self , StandardGate ) or self ._skip_validation ) and not _force_validation :
246
+ return parameter
242
247
"""Gate parameters should be int, float, or ParameterExpression"""
243
248
if isinstance (parameter , ParameterExpression ):
244
249
if len (parameter .parameters ) > 0 :
0 commit comments