View source on GitHub |
Determines whether the value has a unitary effect.
cirq.has_unitary(
val: Any, *, allow_decompose: bool = True
) -> bool
Used in the notebooks
Used in the tutorials |
---|
Determines whether val
has a unitary effect by attempting the following
strategies:
Try to use
val.has_unitary()
. Case a) Method not present or returnsNotImplemented
. Inconclusive. Case b) Method returnsTrue
. Unitary. Case c) Method returnsFalse
. Not unitary.Try to use
val._decompose_()
. Case a) Method not present or returnsNotImplemented
orNone
. Inconclusive. Case b) Method returns an OP_TREE containing only unitary operations. Unitary. Case c) Method returns an OP_TREE containing non-unitary operations. Not Unitary.Try to use
val._apply_unitary_(args)
. Case a) Method not present or returnsNotImplemented
. Inconclusive. Case b) Method returns a numpy array. Unitary. Case c) Method returnsNone
. Not unitary.Try to use
val._unitary_()
. Case a) Method not present or returnsNotImplemented
. Continue to next strategy. Case b) Method returns a numpy array. Unitary. Case c) Method returnsNone
. Not unitary.
It is assumed that, when multiple of these strategies give a conclusive result, that these results will all be consistent with each other. If all strategies are inconclusive, the value is classified as non-unitary.
Args | |
---|---|
The value that may or may not have a unitary effect. |
Returns | |
---|---|
Whether or not val has a unitary effect.
|