Skip to content

Commit

Permalink
Fail early in _strat_has_stabilizer_effect_from_unitary (#6131)
Browse files Browse the repository at this point in the history
* Fail early in

* Fix failing tests
  • Loading branch information
tanujkhattar committed Jun 9, 2023
1 parent 24abfa1 commit 092b996
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cirq-core/cirq/protocols/has_stabilizer_effect_protocol.py
Expand Up @@ -63,7 +63,8 @@ def _strat_has_stabilizer_effect_from_unitary(val: Any) -> Optional[bool]:
"""
# Do not try this strategy if there is no unitary or if the number of
# qubits is not 1 since that would be expensive.
if not protocols.has_unitary(val) or protocols.num_qubits(val) != 1:
qid_shape = protocols.qid_shape(val, default=None)
if qid_shape is None or len(qid_shape) != 1 or not protocols.has_unitary(val):
return None
unitary = protocols.unitary(val)
return SingleQubitCliffordGate.from_unitary(unitary) is not None

0 comments on commit 092b996

Please sign in to comment.