cirq.Circuit.prev_moment_operating_on

Circuit.prev_moment_operating_on(qubits: Sequence[cirq.ops.raw_types.Qid], end_moment_index: Optional[int] = None, max_distance: Optional[int] = None) → Optional[int][source]

Finds the index of the next moment that touches the given qubits.

Parameters:
  • qubits – We’re looking for operations affecting any of these qubits.
  • end_moment_index – The moment index just after the starting point of the reverse search. Defaults to the length of the list of moments.
  • max_distance – The number of moments (starting just before from the end index and moving backward) to check. Defaults to no limit.
Returns:

None if there is no matching moment, otherwise the index of the latest matching moment.

Raises:

ValueError – negative max_distance.