cirq.has_unitary¶

cirq.has_unitary(val: Any) → bool[source]

Returns whether the value has a unitary matrix representation.

Returns: If val has a _has_unitary_ method and its result is not NotImplemented, that result is returned. Otherwise, if val is a cirq.Gate or cirq.Operation, a decomposition is attempted and the resulting unitary is returned if has_unitary is True for all operations of the decompostion. Otherwise, if the value has a _unitary_ method return if that has a non-default value. Returns False if neither function exists.