def test_get_instance(): print("test get instance...") i1 = EQSN.get_instance() i2 = EQSN.get_instance() assert i1 == i2 i1.stop_all() i2.stop_all() print("Test succesfull")
def test_measure(): q_sim = EQSN.get_instance() _id = str(10) q_sim.new_qubit(_id) res = q_sim.measure(_id) assert res == 0 q_sim.stop_all()
def test_x_gate(): q_sim = EQSN.get_instance() id = str(10) q_sim.new_qubit(id) q_sim.X_gate(id) res = q_sim.measure(id) print("measured " + str(res)) assert res == 1 q_sim.stop_all()
def test_H_gate(): q_sim = EQSN.get_instance() id = str(10) q_sim.new_qubit(id) q_sim.H_gate(id) q_sim.H_gate(id) res = q_sim.measure(id) assert res == 0 q_sim.stop_all()
def test_S_gate(): q_sim = EQSN.get_instance() _id = str(11) q_sim.new_qubit(_id) q_sim.H_gate(_id) q_sim.S_gate(_id) q_sim.S_gate(_id) q_sim.H_gate(_id) res = q_sim.measure(_id) assert res == 1 q_sim.stop_all()
def test_epr_creation(): q_sim = EQSN.get_instance() id1 = str(1) id2 = str(2) q_sim.new_qubit(id1) q_sim.new_qubit(id2) q_sim.H_gate(id2) q_sim.cnot_gate(id1, id2) m1 = q_sim.measure(id1) m2 = q_sim.measure(id2) assert m1 == m2 q_sim.stop_all()
def test_S_gate(): q_sim = EQSN.get_instance() id = str(11) q_sim.new_qubit(id) q_sim.H_gate(id) q_sim.S_gate(id) q_sim.S_gate(id) q_sim.H_gate(id) res = q_sim.measure(id) print("measured %d." % res) assert res == 1 q_sim.stop_all()
def test_epr_creation(): q_sim = EQSN.get_instance() id1 = str(1) id2 = str(2) q_sim.new_qubit(id1) q_sim.new_qubit(id2) q_sim.H_gate(id2) q_sim.cnot_gate(id1, id2) m1 = q_sim.measure(id1) m2 = q_sim.measure(id2) print("measured %d and %d." % (m1, m2)) assert m1 == m2 print("Test was successfull!") q_sim.stop_all()
def tearDownClass(cls): EQSN.get_instance().stop_all()
def test_get_instance(): i1 = EQSN.get_instance() i2 = EQSN.get_instance() assert i1 == i2 i1.stop_all() i2.stop_all()
def __init__(self): self._hosts = EQSNBackend.Hosts.get_instance() # keys are from : to, where from is the host calling create EPR self._entaglement_qubits = EQSNBackend.EntanglementIDs.get_instance() self.eqsn = EQSN.get_instance()