Esempio n. 1
0
    def test_calculate_1q_epg_with_wrong_basis(self):
        """Test calculating EPGs of single qubit gates with wrong basis."""
        gpc = {0: {'cx': 0, 'rx': 0.3, 'ry': 0.3, 'rz': 0.3}}
        epc = 2.6e-4

        with self.assertRaises(QiskitError):
            rb.calculate_1q_epg(gpc, epc, 0)
Esempio n. 2
0
    def test_calculate_1q_epg_with_cx(self):
        """Test calculating EPGs of single qubit gates with nonzero two qubit gate."""
        gpc = {0: {'cx': 1.5, 'u1': 0.1, 'u2': 0.3, 'u3': 0.5}}
        epc = 2.6e-4

        with self.assertRaises(QiskitError):
            rb.calculate_1q_epg(gpc, epc, 0)
Esempio n. 3
0
    def test_calculate_1q_epg(self):
        """Test calculating EPGs of single qubit gates."""
        gpc = {0: {'cx': 0, 'u1': 0.1, 'u2': 0.3, 'u3': 0.5}}
        epc = 2.6e-4

        epg_u1 = 0
        epg_u2 = epc / (0.3 + 2 * 0.5)
        epg_u3 = 2 * epg_u2

        epgs = rb.calculate_1q_epg(gpc, epc, 0)

        # test raise error when invalid qubit is specified.
        with self.assertRaises(QiskitError):
            rb.calculate_1q_epg(gpc, epc, 1)

        # check values
        self.assertAlmostEqual(epgs['u1'], epg_u1)
        self.assertAlmostEqual(epgs['u2'], epg_u2)
        self.assertAlmostEqual(epgs['u3'], epg_u3)