@@ -490,17 +490,17 @@ def test_cannot_remap_non_measurement_gate():
490490
491491def test_circuit_diagram ():
492492 class TaggyTag :
493- """Tag with a custom repr function to test circuit diagrams."""
493+ """Tag with a custom str function to test circuit diagrams."""
494494
495- def __repr__ (self ):
496- return 'TaggyTag() '
495+ def __str__ (self ):
496+ return '<taggy> '
497497
498498 h = cirq .H (cirq .GridQubit (1 , 1 ))
499499 tagged_h = h .with_tags ('tag1' )
500500 non_string_tag_h = h .with_tags (TaggyTag ())
501501
502502 expected = cirq .CircuitDiagramInfo (
503- wire_symbols = ("H[' tag1' ]" ,),
503+ wire_symbols = ("H[tag1]" ,),
504504 exponent = 1.0 ,
505505 connected = True ,
506506 exponent_qubit_index = None ,
@@ -511,14 +511,14 @@ def __repr__(self):
511511 assert cirq .circuit_diagram_info (tagged_h , args ) == cirq .circuit_diagram_info (h )
512512
513513 c = cirq .Circuit (tagged_h )
514- diagram_with_tags = "(1, 1): ───H[' tag1' ]───"
514+ diagram_with_tags = "(1, 1): ───H[tag1]───"
515515 diagram_without_tags = "(1, 1): ───H───"
516516 assert str (cirq .Circuit (tagged_h )) == diagram_with_tags
517517 assert c .to_text_diagram () == diagram_with_tags
518518 assert c .to_text_diagram (include_tags = False ) == diagram_without_tags
519519
520520 c = cirq .Circuit (non_string_tag_h )
521- diagram_with_non_string_tag = "(1, 1): ───H[TaggyTag() ]───"
521+ diagram_with_non_string_tag = "(1, 1): ───H[<taggy> ]───"
522522 assert c .to_text_diagram () == diagram_with_non_string_tag
523523 assert c .to_text_diagram (include_tags = False ) == diagram_without_tags
524524
@@ -531,7 +531,7 @@ def test_circuit_diagram_tagged_global_phase():
531531 # Just global phase in a circuit
532532 assert cirq .circuit_diagram_info (global_phase , default = 'default' ) == 'default'
533533 cirq .testing .assert_has_diagram (
534- cirq .Circuit (global_phase ), "\n \n global phase: π[' tag0' ]" , use_unicode_characters = True
534+ cirq .Circuit (global_phase ), "\n \n global phase: π[tag0]" , use_unicode_characters = True
535535 )
536536 cirq .testing .assert_has_diagram (
537537 cirq .Circuit (global_phase ),
@@ -558,9 +558,7 @@ def _circuit_diagram_info_(
558558 no_wire_symbol_op = NoWireSymbols (coefficient = - 1.0 )().with_tags ('tag0' )
559559 assert cirq .circuit_diagram_info (no_wire_symbol_op , default = 'default' ) == expected
560560 cirq .testing .assert_has_diagram (
561- cirq .Circuit (no_wire_symbol_op ),
562- "\n \n global phase: π['tag0']" ,
563- use_unicode_characters = True ,
561+ cirq .Circuit (no_wire_symbol_op ), "\n \n global phase: π[tag0]" , use_unicode_characters = True
564562 )
565563
566564 # Two global phases in one moment
@@ -570,9 +568,9 @@ def _circuit_diagram_info_(
570568 cirq .testing .assert_has_diagram (
571569 c ,
572570 """\
573- a: ─────────────X───────────────────
571+ a: ─────────────X───────────────
574572
575- global phase: π[' tag1', ' tag2' ]""" ,
573+ global phase: π[tag1, tag2]""" ,
576574 use_unicode_characters = True ,
577575 precision = 2 ,
578576 )
@@ -583,9 +581,9 @@ def _circuit_diagram_info_(
583581 cirq .testing .assert_has_diagram (
584582 c ,
585583 """\
586- a: ─────────────X[' x_tag' ]─────X── ────────────
584+ a: ─────────────X[x_tag]─────X────────────
587585
588- global phase: 0.5π[' tag1' ] 0.5π[' tag2' ]
586+ global phase: 0.5π[tag1] 0.5π[tag2]
589587""" ,
590588 use_unicode_characters = True ,
591589 include_tags = True ,
@@ -603,7 +601,7 @@ def __repr__(self):
603601 q = cirq .GridQubit (1 , 1 )
604602 expected = "(1, 1): ───guess-i-will-repr───"
605603 assert cirq .Circuit (NoCircuitDiagram ()(q )).to_text_diagram () == expected
606- expected = "(1, 1): ───guess-i-will-repr[' taggy' ]───"
604+ expected = "(1, 1): ───guess-i-will-repr[taggy]───"
607605 assert cirq .Circuit (NoCircuitDiagram ()(q ).with_tags ('taggy' )).to_text_diagram () == expected
608606
609607
0 commit comments