diff --git a/cirq-core/cirq/ops/common_gates.py b/cirq-core/cirq/ops/common_gates.py index 133de6dc9cf..237a6ec75f2 100644 --- a/cirq-core/cirq/ops/common_gates.py +++ b/cirq-core/cirq/ops/common_gates.py @@ -285,7 +285,7 @@ def _phase_by_(self, phase_turns, qubit_index): def _has_stabilizer_effect_(self) -> bool | None: if self._is_parameterized_() or self._dimension != 2: return None - return self.exponent % 0.5 == 0 + return abs(self.exponent % 0.5) < 1e-8 def __str__(self) -> str: if self._global_shift == 0: @@ -480,7 +480,7 @@ def _phase_by_(self, phase_turns, qubit_index): def _has_stabilizer_effect_(self) -> bool | None: if self._is_parameterized_(): return None - return self.exponent % 0.5 == 0 + return abs(self.exponent % 0.5) < 1e-8 def __str__(self) -> str: if self._global_shift == 0: @@ -760,7 +760,7 @@ def _phase_by_(self, phase_turns: float, qubit_index: int): def _has_stabilizer_effect_(self) -> bool | None: if self._is_parameterized_() or self._dimension != 2: return None - return self.exponent % 0.5 == 0 + return abs(self.exponent % 0.5) < 1e-8 def _circuit_diagram_info_( self, args: cirq.CircuitDiagramInfoArgs