cirq.ops.Moment

A time-slice of operations within a circuit.

Used in the notebooks

Used in the tutorials

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.

operations The operations applied within the moment. Will be flattened and frozen into a tuple before storing.

ValueError A qubit appears more than once.

operations

qubits

Methods

operates_on

View source

Determines if the moment has operations touching the given qubits.

Args
qubits The qubits that may or may not be touched by operations.

Returns
Whether this moment has operations involving the qubits.

operates_on_single_qubit

View source

Determines if the moment has operations touching the given qubit.

Args
qubit The qubit that may or may not be touched by operations.

Returns
Whether this moment has operations involving the qubit.

operation_at

View source

Returns the operation on a certain qubit for the moment.

Args
qubit The qubit on which the returned Operation operates on.

Returns
The operation that operates on the qubit for that moment.

transform_qubits

View source

Returns the same moment, but with different qubits.

Args
func The function to use to turn each current qubit into a desired new qubit.

Returns
The receiving moment but with qubits transformed by the given function.

with_operation

View source

Returns an equal moment, but with the given op added.

Args
operation The operation to append.

Returns
The new moment.

with_operations

View source

Returns a new moment with the given contents added.

Args
contents New operations to add to this moment.

Returns
The new moment.

without_operations_touching

View source

Returns an equal moment, but without ops on the given qubits.

Args
qubits Operations that touch these will be removed.

Returns
The new moment.

__add__

View source

__bool__

View source

__eq__

View source

Return self==value.

__getitem__

View source

__iter__

View source

__len__

View source

__ne__

View source

Return self!=value.

__pow__

View source

__sub__

View source