示例#1
0
 def test_x(self):
     """test 'x' gate
     """
     bk = Backend('qlazy_stabilizer_simulator')
     qc = QComp(qubit_num=1, backend=bk)
     res = qc.x(0).run(reset_qubits=False)
     actual = qc.stab.get_str()
     expect = " -Z\n"
     self.assertEqual(actual, expect)
     qc.free()
示例#2
0
 def test_sw(self):
     """test 'sw' gate (following 'x' gate, not 'h' gates)
     """
     bk = Backend('qlazy_qstate_simulator')
     qc = QComp(qubit_num=2, backend=bk)
     res = qc.x(0).sw(0, 1).run(reset_qubits=False)
     actual = qc.qstate.amp
     expect = np.array([0j, (1 + 0j), 0j, 0j])
     ans = equal_vectors(actual, expect)
     qc.free()
     self.assertEqual(ans, True)
示例#3
0
 def test_x_x_csw(self):
     """test 'csw' gate
     """
     bk = Backend('qlazy_qstate_simulator')
     qc = QComp(qubit_num=3, backend=bk)
     res = qc.x(0).x(1).csw(0, 1, 2).run(reset_qubits=False)
     actual = qc.qstate.amp
     expect = np.array([0j, 0j, 0j, 0j, 0j, (1 + 0j), 0j, 0j])
     ans = equal_vectors(actual, expect)
     qc.free()
     self.assertEqual(ans, True)
示例#4
0
 def test_x(self):
     """test 'x' gate
     """
     bk = Backend('qlazy_qstate_simulator')
     qc = QComp(qubit_num=1, backend=bk)
     res = qc.x(0).run(reset_qubits=False)
     actual = qc.qstate.amp
     expect = np.array([0.0, 1.0])
     ans = equal_vectors(actual, expect)
     qc.free()
     self.assertEqual(ans, True)