Applies an action to a state argument.

For example, the action may be a cirq.Operation and the state argument may represent the internal state of a state vector simulator (a cirq.ActOnStateVectorArgs).

For non-operations, the qubits argument must be explicitly supplied.

The action is applied by first checking if action._act_on_ exists and returns True (instead of NotImplemented) for the given object. Then fallback strategies specified by the state argument via _act_on_fallback_ are attempted. If those also fail, the method fails with a TypeError.

action The operation, gate, or other to apply to the state tensor.
args A mutable state object that should be modified by the action. May specify an _act_on_fallback_ method to use in case the action doesn't recognize it.
qubits The sequence of qubits to use when applying the action.
allow_decompose Defaults to True. Forwarded into the _act_on_fallback_ method of args. Determines if decomposition should be used or avoided when attempting to act action on args. Used by internal methods to avoid redundant decompositions.

Nothing. Results are communicated by editing args.

ValueError If called on an operation and supplied qubits, if not called on an operation and no qubits are supplied, or if _act_on_ or _act_on_fallback_ returned something other than True or NotImplemented.
TypeError Failed to act action on args.