cirq.optimizers.map_operations

Applies local transformations on operations, by calling map_func(op) for each op.

Note that the function assumes issubset(qubit_set(map_func(op)), op.qubits) is True.

circuit Input circuit to apply the transformations on. The input circuit is not mutated.
map_func Mapping function from (cirq.Operation, moment_index) to a cirq.OP_TREE. If the resulting optree spans more than 1 moment, it's inserted in-place in the same moment as cirq.CircuitOperation(cirq.FrozenCircuit(op_tree)).with_tags(MAPPED_CIRCUIT_OP_TAG) to preserve moment structure. Utility methods like cirq.unroll_circuit_op can subsequently be used to unroll the mapped circuit operation.

ValueError if issubset(qubit_set(map_func(op)), op.qubits) is False.

Copy of input circuit with mapped operations (wrapped in a tagged CircuitOperation).