cirq.testing.assert_has_consistent_apply_unitary

cirq.testing.assert_has_consistent_apply_unitary(val: Any, *, qubit_count: Optional[int] = None, atol: float = 1e-08) → None[source]

Tests whether a value’s apply_unitary is correct.

Contrasts the effects of the value’s _apply_unitary_ with the
matrix returned by the value’s _unitary_ method.
Parameters:
  • val – The value under test. Should have a __pow__ method.
  • qubit_count – Usually inferred. The number of qubits the value acts on. This argument isn’t needed if the gate has a unitary matrix or implements cirq.SingleQubitGate/cirq.TwoQubitGate/ cirq.ThreeQubitGate.