def test_operation_to_choi(channel): """Verifies that cirq.operation_to_choi correctly computes the Choi matrix.""" n_qubits = cirq.num_qubits(channel) actual = cirq.operation_to_choi(channel) expected = compute_choi(channel) assert np.isclose(np.trace(actual), 2 ** n_qubits) assert np.all(actual == expected)
def test_choi_for_completely_dephasing_channel(): """Checks cirq.operation_to_choi on the completely dephasing channel.""" assert np.all(cirq.operation_to_choi(cirq.phase_damp(1)) == np.diag([1, 0, 0, 1]))