Skip to content

Commit 159d324

Browse files
authored
Merge branch 'main' into result_dict_reprs
2 parents a5bcf12 + d432730 commit 159d324

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

cirq-core/cirq/protocols/has_stabilizer_effect_protocol.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ def _strat_has_stabilizer_effect_from_unitary(val: Any) -> Optional[bool]:
102102

103103

104104
def _strat_has_stabilizer_effect_from_decompose(val: Any) -> Optional[bool]:
105-
qid_shape = qid_shape_protocol.qid_shape(val, default=None)
106-
if qid_shape is None or len(qid_shape) <= 3:
107-
return None
108-
109-
decomposition = decompose_protocol.decompose_once(val, default=None)
105+
decomposition, _, _ = decompose_protocol._try_decompose_into_operations_and_qubits(val)
110106
if decomposition is None:
111107
return None
112108
for op in decomposition:

cirq-core/cirq/protocols/has_stabilizer_effect_protocol_test.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ def _has_stabilizer_effect_(self):
4141
return True
4242

4343

44-
q = cirq.LineQubit(0)
45-
46-
4744
class EmptyOp(cirq.Operation):
4845
"""A trivial operation."""
4946

47+
def __init__(self, q: cirq.Qid = cirq.LineQubit(0)):
48+
self.q = q
49+
5050
@property
5151
def qubits(self):
52-
return (q,)
52+
return (self.q,)
5353

5454
def with_qubits(self, *new_qubits): # pragma: no cover
5555
return self
@@ -97,6 +97,14 @@ def qubits(self):
9797
return cirq.LineQubit.range(self.unitary.shape[0].bit_length() - 1)
9898

9999

100+
class GateDecomposes(cirq.Gate):
101+
def _num_qubits_(self):
102+
return 1
103+
104+
def _decompose_(self, qubits):
105+
yield YesOp(*qubits)
106+
107+
100108
def test_inconclusive():
101109
assert not cirq.has_stabilizer_effect(object())
102110
assert not cirq.has_stabilizer_effect('boo')
@@ -146,3 +154,4 @@ def test_via_decompose():
146154
assert not cirq.has_stabilizer_effect(
147155
OpWithUnitary(cirq.unitary(cirq.Circuit(cirq.T.on_each(cirq.LineQubit.range(4)))))
148156
)
157+
assert cirq.has_stabilizer_effect(GateDecomposes())

0 commit comments

Comments
 (0)