Esempio n. 1
0
 def test_expand(self):
     """Test tensor two quantum errors."""
     noise_x = QuantumError([((IGate(), [0]), 0.9), ((XGate(), [0]), 0.1)])
     noise_y = QuantumError([((IGate(), [0]), 0.8), ((YGate(), [0]), 0.2)])
     actual = noise_y.expand(noise_x)  # reversed order of expand
     expected = QuantumError([([(IGate(), [1]), (IGate(), [0])], 0.9 * 0.8),
                              ([(IGate(), [1]), (YGate(), [0])], 0.9 * 0.2),
                              ([(XGate(), [1]), (IGate(), [0])], 0.1 * 0.8),
                              ([(XGate(), [1]), (YGate(), [0])], 0.1 * 0.2)])
     self.assertEqual(actual, expected)
Esempio n. 2
0
    def test_expand_both_unitary_instruction(self):
        """Test expand of two unitary instruction errors."""
        unitaries0 = self.mixed_unitary_error([0.9, 0.1], ['z', 's'])
        unitaries1 = self.mixed_unitary_error([0.6, 0.4], ['x', 'y'])

        error0 = QuantumError(unitaries0, standard_gates=False)
        error1 = QuantumError(unitaries1, standard_gates=False)
        error = error0.expand(error1)
        target = SuperOp(Kraus(unitaries0)).expand(Kraus(unitaries1))

        for j in range(4):
            circ, _ = error.error_term(j)
            self.assertEqual(circ[0]['name'], 'unitary')
            self.assertEqual(circ[0]['qubits'], [0, 1])
        self.assertEqual(SuperOp(error), target)
Esempio n. 3
0
    def test_expand_both_unitary_standard_gates(self):
        """Test expand of two unitary standard gate errors"""
        unitaries0 = self.mixed_unitary_error([0.9, 0.1], ['z', 's'])
        unitaries1 = self.mixed_unitary_error([0.6, 0.4], ['x', 'y'])

        error0 = QuantumError(unitaries0, standard_gates=True)
        error1 = QuantumError(unitaries1, standard_gates=True)
        error = error0.expand(error1)
        target = SuperOp(Kraus(unitaries0)).expand(Kraus(unitaries1))

        for j in range(4):
            circ, _ = error.error_term(j)
            self.assertEqual(len(circ), 2)
            for instr in circ:
                self.assertIn(instr['name'], ['s', 'x', 'y', 'z'])
                self.assertIn(instr['qubits'], [[0], [1]])
        self.assertEqual(SuperOp(error), target)