Beispiel #1
0
 def test_inheritance_1(self):
     """test 'inheritance_1'
     """
     qs_expect = QState(qubit_num=2).h(0).cx(0, 1).x(0)
     qs_actual = MyQState(qubit_num=2).bell(0, 1).x(0)
     fid = qs_expect.fidelity(qs_actual)
     self.assertEqual(abs(fid - 1.0) < EPS, True)
Beispiel #2
0
 def test_fidelity_partial(self):
     """test 'fidelity' (for partial system)
     """
     qs_0 = QState(qubit_num=3).h(0).h(1).h(2)
     qs_1 = QState(qubit_num=3).h(0).h(1).h(2)
     fid = qs_0.fidelity(qs_1, qid=[0, 1])
     ans = (round(fid, 4) == 1.0)
     self.assertEqual(ans, True)
Beispiel #3
0
 def test_fidelity(self):
     """test 'fidelity'
     """
     qs_0 = QState(qubit_num=3).h(0).h(1).h(2)
     qs_1 = QState(qubit_num=3).h(0).h(1).h(2)
     fid = qs_0.fidelity(qs_1)
     ans = (round(fid, 4) == 1.0)
     self.assertEqual(ans, True)