Skip to content

Commit

Permalink
Unit test for Clifford check skipping multi-qubit unitaries (#3168)
Browse files Browse the repository at this point in the history
Unit test to prevent reoccurrence of #3164. Goes along with #3165.
  • Loading branch information
viathor committed Jul 22, 2020
1 parent 7bf16e1 commit 75e5f74
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cirq/sim/clifford/clifford_simulator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,27 @@ def test_sample_seed():


def test_is_supported_operation():

class MultiQubitOp(cirq.Operation):
"""Multi-qubit operation with unitary.
Used to verify that `is_supported_operation` does not attempt to
allocate the unitary for multi-qubit operations.
"""

@property
def qubits(self):
return cirq.LineQubit.range(100)

def with_qubits(self, *new_qubits):
raise NotImplementedError()

def _has_unitary_(self):
return True

def _unitary_(self):
assert False

q1, q2 = cirq.LineQubit.range(2)
assert cirq.CliffordSimulator.is_supported_operation(cirq.X(q1))
assert cirq.CliffordSimulator.is_supported_operation(cirq.H(q1))
Expand All @@ -438,6 +459,7 @@ def test_is_supported_operation():
cirq.GlobalPhaseOperation(1j))

assert not cirq.CliffordSimulator.is_supported_operation(cirq.T(q1))
assert not cirq.CliffordSimulator.is_supported_operation(MultiQubitOp())


def test_simulate_pauli_string():
Expand Down

0 comments on commit 75e5f74

Please sign in to comment.