1- import eqsn
1+ from eqsn import EQSN
22import uuid
33from objects .qubit import Qubit
44import threading
@@ -117,6 +117,7 @@ def __init__(self):
117117 self ._hosts = EQSNBackend .Hosts .get_instance ()
118118 # keys are from : to, where from is the host calling create EPR
119119 self ._entaglement_qubits = EQSNBackend .EntanglementIDs .get_instance ()
120+ self .eqsn = EQSN ()
120121
121122 def start (self , ** kwargs ):
122123 """
@@ -129,7 +130,7 @@ def stop(self):
129130 """
130131 Stops Backends which are running in an own thread or process.
131132 """
132- eqsn .stop_all ()
133+ self . eqsn .stop_all ()
133134
134135 def add_host (self , host ):
135136 """
@@ -151,7 +152,7 @@ def create_qubit(self, host_id):
151152 Qubit of backend type.
152153 """
153154 id = str (uuid .uuid4 ())
154- eqsn .new_qubit (id )
155+ self . eqsn .new_qubit (id )
155156 return id
156157
157158 def send_qubit_to (self , qubit , from_host_id , to_host_id ):
@@ -183,10 +184,10 @@ def create_EPR(self, host_a_id, host_b_id, q_id=None, block=False):
183184 uid2 = uuid .uuid4 ()
184185 host_a = self ._hosts .get_from_dict (host_a_id )
185186 host_b = self ._hosts .get_from_dict (host_b_id )
186- eqsn .new_qubit (uid1 )
187- eqsn .new_qubit (uid2 )
188- eqsn .H_gate (uid1 )
189- eqsn .cnot_gate (uid2 , uid1 )
187+ self . eqsn .new_qubit (uid1 )
188+ self . eqsn .new_qubit (uid2 )
189+ self . eqsn .H_gate (uid1 )
190+ self . eqsn .cnot_gate (uid2 , uid1 )
190191 q1 = Qubit (host_a , qubit = uid1 , q_id = q_id , blocked = block )
191192 q2 = Qubit (host_b , qubit = uid2 , q_id = q1 .id , blocked = block )
192193 self .store_ent_pair (host_a .host_id , host_b .host_id , q2 )
@@ -245,7 +246,7 @@ def X(self, qubit):
245246 Args:
246247 qubit (Qubit): Qubit on which gate should be applied to.
247248 """
248- eqsn .X_gate (qubit .qubit )
249+ self . eqsn .X_gate (qubit .qubit )
249250
250251 def Y (self , qubit ):
251252 """
@@ -254,7 +255,7 @@ def Y(self, qubit):
254255 Args:
255256 qubit (Qubit): Qubit on which gate should be applied to.
256257 """
257- eqsn .Y_gate (qubit .qubit )
258+ self . eqsn .Y_gate (qubit .qubit )
258259
259260 def Z (self , qubit ):
260261 """
@@ -263,7 +264,7 @@ def Z(self, qubit):
263264 Args:
264265 qubit (Qubit): Qubit on which gate should be applied to.
265266 """
266- eqsn .Z_gate (qubit .qubit )
267+ self . eqsn .Z_gate (qubit .qubit )
267268
268269 def H (self , qubit ):
269270 """
@@ -272,7 +273,7 @@ def H(self, qubit):
272273 Args:
273274 qubit (Qubit): Qubit on which gate should be applied to.
274275 """
275- eqsn .H_gate (qubit .qubit )
276+ self . eqsn .H_gate (qubit .qubit )
276277
277278 def K (self , qubit ):
278279 """
@@ -281,7 +282,7 @@ def K(self, qubit):
281282 Args:
282283 qubit (Qubit): Qubit on which gate should be applied to.
283284 """
284- eqsn .K_gate (qubit .qubit )
285+ self . eqsn .K_gate (qubit .qubit )
285286
286287 def S (self , qubit ):
287288 """
@@ -290,7 +291,7 @@ def S(self, qubit):
290291 Args:
291292 qubit (Qubit): Qubit on which gate should be applied to.
292293 """
293- eqsn .S_gate (qubit .qubit )
294+ self . eqsn .S_gate (qubit .qubit )
294295
295296 def T (self , qubit ):
296297 """
@@ -299,7 +300,7 @@ def T(self, qubit):
299300 Args:
300301 qubit (Qubit): Qubit on which gate should be applied to.
301302 """
302- eqsn .T_gate (qubit .qubit )
303+ self . eqsn .T_gate (qubit .qubit )
303304
304305 def rx (self , qubit , phi ):
305306 """
@@ -309,7 +310,7 @@ def rx(self, qubit, phi):
309310 qubit (Qubit): Qubit on which gate should be applied to.
310311 phi (float): Amount of roation in Rad.
311312 """
312- eqsn .RX_gate (qubit .qubit , phi )
313+ self . eqsn .RX_gate (qubit .qubit , phi )
313314
314315 def ry (self , qubit , phi ):
315316 """
@@ -319,7 +320,7 @@ def ry(self, qubit, phi):
319320 qubit (Qubit): Qubit on which gate should be applied to.
320321 phi (float): Amount of roation in Rad.
321322 """
322- eqsn .RY_gate (qubit .qubit , phi )
323+ self . eqsn .RY_gate (qubit .qubit , phi )
323324
324325 def rz (self , qubit , phi ):
325326 """
@@ -329,7 +330,7 @@ def rz(self, qubit, phi):
329330 qubit (Qubit): Qubit on which gate should be applied to.
330331 phi (float): Amount of roation in Rad.
331332 """
332- eqsn .RZ_gate (qubit .qubit , phi )
333+ self . eqsn .RZ_gate (qubit .qubit , phi )
333334
334335 def cnot (self , qubit , target ):
335336 """
@@ -339,7 +340,7 @@ def cnot(self, qubit, target):
339340 qubit (Qubit): Qubit to control cnot.
340341 target (Qubit): Qubit on which the cnot gate should be applied.
341342 """
342- eqsn .cnot_gate (target .qubit , qubit .qubit )
343+ self . eqsn .cnot_gate (target .qubit , qubit .qubit )
343344
344345 def cphase (self , qubit , target ):
345346 """
@@ -349,7 +350,7 @@ def cphase(self, qubit, target):
349350 qubit (Qubit): Qubit to control cphase.
350351 target (Qubit): Qubit on which the cphase gate should be applied.
351352 """
352- eqsn .cphase_gate (target .qubit , qubit .qubit )
353+ self . eqsn .cphase_gate (target .qubit , qubit .qubit )
353354
354355 def measure (self , qubit , non_destructive ):
355356 """
@@ -362,7 +363,7 @@ def measure(self, qubit, non_destructive):
362363 Returns:
363364 The value which has been measured.
364365 """
365- return eqsn .measure (qubit .qubit , non_destructive )
366+ return self . eqsn .measure (qubit .qubit , non_destructive )
366367
367368 def release (self , qubit ):
368369 """
@@ -371,4 +372,4 @@ def release(self, qubit):
371372 Args:
372373 qubit (Qubit): The qubit which should be released.
373374 """
374- eqsn .measure (qubit .qubit )
375+ self . eqsn .measure (qubit .qubit )
0 commit comments