def test_to_channel_kraus(self): """Test to_channel for Kraus inputs.""" A0 = np.array([[1, 0], [0, np.sqrt(1 - 0.3)]], dtype=complex) A1 = np.array([[0, 0], [0, np.sqrt(0.3)]], dtype=complex) B0 = np.array([[1, 0], [0, np.sqrt(1 - 0.5)]], dtype=complex) B1 = np.array([[0, 0], [0, np.sqrt(0.5)]], dtype=complex) target = SuperOp(Kraus([A0, A1])).tensor(SuperOp(Kraus([B0, B1]))) error = QuantumError([A0, A1]).tensor(QuantumError([B0, B1])) self.assertEqual(target, error.to_channel())
def test_to_channel_circuit(self): """Test to_channel for circuit inputs.""" noise_ops = [([{ 'name': 'reset', 'qubits': [0] }], 0.2), ([{ 'name': 'reset', 'qubits': [1] }], 0.3), ([{ 'name': 'id', 'qubits': [0] }], 0.5)] error = QuantumError(noise_ops) reset = SuperOp( np.array([[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]])) iden = SuperOp(np.eye(4)) target = 0.2 * iden.tensor(reset) + 0.3 * reset.tensor( iden) + 0.5 * iden.tensor(iden) self.assertEqual(target, error.to_channel())