Merges connected components of operations and wraps each component into a circuit operation.
cirq.merge_operations_to_circuit_op(
circuit: CIRCUIT_TYPE,
can_merge: Callable[[Sequence['cirq.Operation'], Sequence['cirq.Operation']], bool],
*,
tags_to_ignore: Sequence[Hashable] = (),
merged_circuit_op_tag: str = 'Merged connected component',
deep: bool = False
) -> CIRCUIT_TYPE
Used in the notebooks
Uses cirq.merge_operations
to identify connected components of operations. Moment structure
is preserved for operations that do not participate in merging. For merged operations, the
newly created circuit operations are constructed by inserting operations using EARLIEST
strategy.
If you need more control on moment structure of newly created circuit operations, consider
using cirq.merge_operations
directly with a custom merge_func
.
Args |
circuit
|
Input circuit to apply the transformations on. The input circuit is not mutated.
|
can_merge
|
Callable to determine whether a new operation right_op can be merged into an
existing connected component of operations left_ops based on boolen returned by
can_merge(left_ops, right_op) .
|
tags_to_ignore
|
Tagged operations marked any of tags_to_ignore will not be considered as
potential candidates for any connected component.
|
merged_circuit_op_tag
|
Tag to be applied on circuit operations wrapping valid connected
components.
|
deep
|
If true, the transformer primitive will be recursively applied to all circuits
wrapped inside circuit operations.
|
Returns |
Copy of input circuit with valid connected components wrapped in tagged circuit operations.
|