Applies an action to a state argument.
cirq.protocols.act_on(
action: Any,
args: Any,
*,
allow_decompose: bool = True
)
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
).
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
.
Args |
action
|
The action to apply to the state tensor. Typically a
cirq.Operation .
|
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.
|
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.
|
Returns |
Nothing. Results are communicated by editing args .
|
Raises |
TypeError
|
Failed to act action on args .
|