# cirq.has_unitary

Determines whether the value has a unitary effect.

### Used in the notebooks

Used in the tutorials

Determines whether `val` has a unitary effect by attempting the following strategies:

1. Try to use `val.has_unitary()`. Case a) Method not present or returns `NotImplemented`. Inconclusive. Case b) Method returns `True`. Unitary. Case c) Method returns `False`. Not unitary.

2. Try to use `val._decompose_()`. Case a) Method not present or returns `NotImplemented` or `None`. 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.

3. Try to use `val._apply_unitary_(args)`. Case a) Method not present or returns `NotImplemented`. Inconclusive. Case b) Method returns a numpy array. Unitary. Case c) Method returns `None`. Not unitary.

4. Try to use `val._unitary_()`. Case a) Method not present or returns `NotImplemented`. Continue to next strategy. Case b) Method returns a numpy array. Unitary. Case c) Method returns `None`. 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.

The value that may or may not have a unitary effect.

Whether or not `val` has a unitary effect.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]
{"lastModified": "Last updated 2024-06-27 UTC."}