Removes terminal measurements from a circuit.
cirq.drop_terminal_measurements(
circuit: 'cirq.AbstractCircuit',
*,
context: Optional['cirq.TransformerContext'] = transformer_api.TransformerContext(deep=True)
) -> 'cirq.Circuit'
This transformer is helpful when trying to capture the final state vector
of a circuit with many terminal measurements, as simulating the circuit
with those measurements in place would otherwise collapse the final state.
Args |
circuit
|
The circuit to transform. It will not be modified.
|
context
|
cirq.TransformerContext storing common configurable options
for transformers. The default has deep=True , as "terminal
measurements" is ill-defined without inspecting subcircuits;
passing a context with deep=False will return an error.
|
Returns |
A copy of the circuit, with identity or X gates in place of terminal
measurements.
|
Raises |
ValueError
|
if the circuit contains non-terminal measurements, or if
the provided context hasdeep=False .
|