diff --git a/src/openfermion/circuits/gates/four_qubit_gates.py b/src/openfermion/circuits/gates/four_qubit_gates.py index 401d378f7..8916f0d03 100644 --- a/src/openfermion/circuits/gates/four_qubit_gates.py +++ b/src/openfermion/circuits/gates/four_qubit_gates.py @@ -124,9 +124,13 @@ def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> cirq.Circ # Split up this string to avoid SyntaxError in Python 3.12. down_up = r'\/ /' + '\\' wire_symbols = (up_down, up_down, down_up, down_up) - return cirq.CircuitDiagramInfo( - wire_symbols=wire_symbols, exponent=self._diagram_exponent(args) - ) + + exponent = self._diagram_exponent(args) + if isinstance(exponent, (int, float, np.integer, np.floating)): + # Canonicalize rounded exponent into (-1, 1] range (DoubleExcitation has period 2) + exponent = 1.0 - (1.0 - exponent) % 2.0 + + return cirq.CircuitDiagramInfo(wire_symbols=wire_symbols, exponent=exponent) def __repr__(self): if self.exponent == 1: