Beispiel #1
0
 def test_to_quantumchannel_kraus(self):
     """Test to_quantumchannel for Kraus inputs."""
     a_0 = np.array([[1, 0], [0, np.sqrt(1 - 0.3)]], dtype=complex)
     a_1 = np.array([[0, 0], [0, np.sqrt(0.3)]], dtype=complex)
     b_0 = np.array([[1, 0], [0, np.sqrt(1 - 0.5)]], dtype=complex)
     b_1 = np.array([[0, 0], [0, np.sqrt(0.5)]], dtype=complex)
     target = SuperOp(Kraus([a_0, a_1])).tensor(SuperOp(Kraus([b_0, b_1])))
     error = QuantumError([a_0, a_1]).tensor(QuantumError([b_0, b_1]))
     self.assertEqual(target, error.to_quantumchannel())
 def test_to_quantumchannel_kraus(self):
     """Test to_quantumchannel for Kraus inputs."""
     a_0 = np.array([[1, 0], [0, np.sqrt(1 - 0.3)]], dtype=complex)
     a_1 = np.array([[0, 0], [0, np.sqrt(0.3)]], dtype=complex)
     b_0 = np.array([[1, 0], [0, np.sqrt(1 - 0.5)]], dtype=complex)
     b_1 = np.array([[0, 0], [0, np.sqrt(0.5)]], dtype=complex)
     target = SuperOp(Kraus([a_0, a_1])).tensor(SuperOp(Kraus([b_0, b_1])))
     with self.assertWarns(
         DeprecationWarning,
         msg=r"Constructing QuantumError .* Kraus channel .* qiskit-aer 0\.10\.0 .*",
     ):
         error = QuantumError([a_0, a_1]).tensor(QuantumError([b_0, b_1]))
     self.assertEqual(target, error.to_quantumchannel())
Beispiel #3
0
 def test_to_quantumchannel_circuit(self):
     """Test to_quantumchannel 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_quantumchannel())
 def test_to_quantumchannel_circuit(self):
     """Test to_quantumchannel for circuit inputs."""
     noise_ops = [
         ([{'name': 'reset', 'qubits': [0]}], 0.2),
         ([{'name': 'reset', 'qubits': [1]}], 0.3),
         ([{'name': 'id', 'qubits': [0]}], 0.5),
     ]
     with self.assertWarns(
         DeprecationWarning,
         msg=r"Constructing QuantumError .* list of dict .* qiskit-aer 0\.10\.0 .*",
     ):
         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_quantumchannel())