File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
cirq-core/cirq/contrib/svg Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ def fixup_text(text: str):
2323 if '[cirq.VirtualTag()]' in text :
2424 # https://github.com/quantumlib/Cirq/issues/2905
2525 return text .replace ('[cirq.VirtualTag()]' , '' )
26+ if '<' in text :
27+ return text .replace ('<' , '<' )
28+ if '>' in text :
29+ return text .replace ('>' , '>' )
2630 return text
2731
2832
Original file line number Diff line number Diff line change @@ -57,3 +57,22 @@ def test_empty_moments():
5757 svg_2 = circuit_to_svg (cirq .Circuit (cirq .Moment ()))
5858 assert '<svg' in svg_2
5959 assert '</svg>' in svg_2
60+
61+
62+ def test_gate_with_less_greater_str ():
63+ class CustomGate (cirq .Gate ):
64+ def _num_qubits_ (self ) -> int :
65+ return 4
66+
67+ def _circuit_diagram_info_ (self , _ ) -> cirq .CircuitDiagramInfo :
68+ return cirq .CircuitDiagramInfo (wire_symbols = ['<a' , '<=b' , '>c' , '>=d' ])
69+
70+ circuit = cirq .Circuit (CustomGate ().on (* cirq .LineQubit .range (4 )))
71+ svg = circuit_to_svg (circuit )
72+ import IPython .display # type: ignore
73+
74+ _ = IPython .display .SVG (svg )
75+ assert '<a' in svg
76+ assert '<=b' in svg
77+ assert '>c' in svg
78+ assert '>=d' in svg
You can’t perform that action at this time.
0 commit comments