Grouping operations into moments is intended to be a strong suggestion to
whatever is scheduling operations on real hardware. Operations in the same
moment should execute at the same time (to the extent possible; not all
operations have the same duration) and it is expected that all operations
in a moment should be completed before beginning the next moment.
Moment can be indexed by qubit or list of qubits:
moment[qubit] returns the Operation in the moment which touches the
given qubit, or throws KeyError if there is no such operation.
moment[qubits] returns another Moment which consists only of those
operations which touch at least one of the given qubits. If there
are no such operations, returns an empty Moment.
Args
contents
The operations applied within the moment.
Will be flattened and frozen into a tuple before storing.
_flatten_contents
If True, use flatten_to_ops to convert
the OP_TREE of contents into a tuple of Operation. If False,
we skip flattening and assume that contents already consists
of individual operations. This is used internally by helper
methods to avoid unnecessary validation.
tags
Optional tags to denote specific Moment objects with meta-data.
These are a tuple of any Hashable object. Typically, a class
will be passed. Tags apply only to this specific set of operations
and will be lost on any transformation of the
Moment. For instance, if operations are added to the Moment, tags
will be dropped unless explicitly added back in by the user.
This avoids calling flatten_to_ops in the moment constructor, which
results in better performance in cases where the contents of the moment
are already in the form of a sequence of operations rather than an
arbitrary OP_TREE.
Args
*ops
Operations to include in the Moment.
tags
Optional tags to denote specific Moment objects with meta-data.
These are a tuple of any Hashable object. Tags will be dropped if
the operations in the Moment are modified or transformed.
A function to split qubits/qudits into x and y
components. For example, the default breakdown turns
cirq.GridQubit(row, col) into the tuple (col, row) and
cirq.LineQubit(x) into (x, 0).
extra_qubits
Extra qubits/qudits to include in the diagram, even
if they don't have any operations applied in the moment.
use_unicode_characters
Whether or not the output should use fancy
unicode characters or stick to plain ASCII. Unicode characters
look nicer, but some environments don't draw them with the same
width as ascii characters (which ruins the diagrams).
precision
How precise numbers, such as angles, should be. Use None
for infinite precision, or an integer for a certain number of
digits of precision.
include_tags
Controls which tags attached to operations are
included. True includes all tags, False includes none,
or a collection of tag classes may be specified to include only
those tags.
Creates a new Moment with the current ops and the specified tags.
If the moment already has tags, this will add the new_tags to the
preexisting tags.
This method can be used to attach meta-data to moments
without affecting their functionality. The intended usage is to
attach classes intended for this purpose or strings to mark operations
for specific usage that will be recognized by consumers.
Tags can be a list of any type of object that is useful to identify
this operation as long as the type is hashable. If you wish the
resulting operation to be eventually serialized into JSON, you should
also restrict the operation to be JSON serializable.
Please note that tags should be instantiated if classes are
used. Raw types are not allowed.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-11-18 UTC."],[],[]]