cirq.ExpandComposite

class cirq.ExpandComposite(composite_gate_extension: cirq.extension.extensions.Extensions = None, no_decomp: Callable[cirq.ops.raw_types.Operation, bool] = <function ExpandComposite.<lambda>>)[source]

An optimization pass that expands CompositeOperation instances.

For each operation in the circuit, this pass examines if the operation is a CompositeOperation, or is composite according to a supplied Extension, and if it is, clears the operation and replaces it with its decomposition using a fixed insertion strategy.

__init__(composite_gate_extension: cirq.extension.extensions.Extensions = None, no_decomp: Callable[cirq.ops.raw_types.Operation, bool] = <function ExpandComposite.<lambda>>) → None[source]

Construct the optimization pass.

Parameters:
  • composite_gate_extension – An extension that that can be used to supply or override a CompositeOperation decomposition.
  • no_decomp – A predicate that determines whether an operation should be decomposed or not. Defaults to decomposing everything.

Methods

optimization_at(circuit, index, op) Describes how to change operations near the given location.
optimize_circuit(circuit) Rewrites the given circuit to make it better.