Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/openfermion/circuits/gates/four_qubit_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional - consider using numbers.Real instead.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good point.

# 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:
Expand Down
Loading