@@ -1172,7 +1172,7 @@ def to_text_diagram(
11721172 * ,
11731173 use_unicode_characters : bool = True ,
11741174 transpose : bool = False ,
1175- include_tags : bool = True ,
1175+ include_tags : bool | Iterable [ type ] = True ,
11761176 precision : int | None = 3 ,
11771177 qubit_order : cirq .QubitOrderOrList = ops .QubitOrder .DEFAULT ,
11781178 ) -> str :
@@ -1182,7 +1182,10 @@ def to_text_diagram(
11821182 use_unicode_characters: Determines if unicode characters are
11831183 allowed (as opposed to ascii-only diagrams).
11841184 transpose: Arranges qubit wires vertically instead of horizontally.
1185- include_tags: Whether tags on TaggedOperations should be printed
1185+ include_tags: Controls which tags attached to operations are
1186+ included. ``True`` includes all tags, ``False`` includes none,
1187+ or a collection of tag classes may be specified to include only
1188+ those tags.
11861189 precision: Number of digits to display in text diagram
11871190 qubit_order: Determines how qubits are ordered in the diagram.
11881191
@@ -1209,7 +1212,7 @@ def to_text_diagram_drawer(
12091212 use_unicode_characters : bool = True ,
12101213 qubit_namer : Callable [[cirq .Qid ], str ] | None = None ,
12111214 transpose : bool = False ,
1212- include_tags : bool = True ,
1215+ include_tags : bool | Iterable [ type ] = True ,
12131216 draw_moment_groups : bool = True ,
12141217 precision : int | None = 3 ,
12151218 qubit_order : cirq .QubitOrderOrList = ops .QubitOrder .DEFAULT ,
@@ -1224,7 +1227,10 @@ def to_text_diagram_drawer(
12241227 allowed (as opposed to ascii-only diagrams).
12251228 qubit_namer: Names qubits in diagram. Defaults to using _circuit_diagram_info_ or str.
12261229 transpose: Arranges qubit wires vertically instead of horizontally.
1227- include_tags: Whether to include tags in the operation.
1230+ include_tags: Controls which tags attached to operations are
1231+ included. ``True`` includes all tags, ``False`` includes none,
1232+ or a collection of tag classes may be specified to include only
1233+ those tags.
12281234 draw_moment_groups: Whether to draw moment symbol or not
12291235 precision: Number of digits to use when representing numbers.
12301236 qubit_order: Determines how qubits are ordered in the diagram.
@@ -2534,7 +2540,7 @@ def _draw_moment_annotations(
25342540 get_circuit_diagram_info : Callable [
25352541 [cirq .Operation , cirq .CircuitDiagramInfoArgs ], cirq .CircuitDiagramInfo
25362542 ],
2537- include_tags : bool ,
2543+ include_tags : bool | Iterable [ type ] ,
25382544 first_annotation_row : int ,
25392545 transpose : bool ,
25402546):
@@ -2566,7 +2572,7 @@ def _draw_moment_in_diagram(
25662572 get_circuit_diagram_info : (
25672573 Callable [[cirq .Operation , cirq .CircuitDiagramInfoArgs ], cirq .CircuitDiagramInfo ] | None
25682574 ),
2569- include_tags : bool ,
2575+ include_tags : bool | Iterable [ type ] ,
25702576 first_annotation_row : int ,
25712577 transpose : bool ,
25722578):
@@ -2637,8 +2643,16 @@ def _draw_moment_in_diagram(
26372643 desc = _formatted_phase (global_phase , use_unicode_characters , precision )
26382644 if desc :
26392645 y = max (label_map .values (), default = 0 ) + 1
2640- if tags and include_tags :
2641- desc = desc + f"[{ ', ' .join (map (str , tags ))} ]"
2646+ visible_tags = protocols .CircuitDiagramInfoArgs (
2647+ known_qubits = None ,
2648+ known_qubit_count = None ,
2649+ use_unicode_characters = True ,
2650+ precision = None ,
2651+ label_map = None ,
2652+ include_tags = include_tags ,
2653+ ).tags_to_include (tags )
2654+ if visible_tags :
2655+ desc = desc + f"[{ ', ' .join (map (str , visible_tags ))} ]"
26422656 out_diagram .write (x0 , y , desc )
26432657
26442658 if not non_global_ops :
0 commit comments