Skip to content

Commit ada2527

Browse files
committed
Add parametrization check to GlobalPhaseOperation
Assume GlobalPhaseOperation.coefficient is a numerical value otherwise.
1 parent 79b3f41 commit ada2527

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cirq-core/cirq/ops/global_phase_op.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@
1313
# limitations under the License.
1414
"""A no-qubit global phase operation."""
1515

16-
from typing import AbstractSet, Any, cast, Dict, Sequence, Tuple, TYPE_CHECKING, Union
16+
from typing import AbstractSet, Any, cast, Dict, Sequence, Tuple, Union
1717

1818
import numpy as np
1919
import sympy
2020

21+
import cirq
2122
from cirq import value, protocols
2223
from cirq._compat import deprecated_class
2324
from cirq.type_workarounds import NotImplementedType
2425
from cirq.ops import gate_operation, raw_types
2526

26-
if TYPE_CHECKING:
27-
import cirq
28-
2927

3028
@value.value_equality(approximate=True)
3129
@deprecated_class(deadline='v0.16', fix='Use cirq.global_phase_operation')
@@ -90,6 +88,7 @@ def _apply_unitary_(
9088
) -> Union[np.ndarray, NotImplementedType]:
9189
if not self._has_unitary_():
9290
return NotImplemented
91+
assert not cirq.is_parameterized(self)
9392
args.target_tensor *= cast(np.generic, self.coefficient)
9493
return args.target_tensor
9594

0 commit comments

Comments
 (0)