@@ -39,7 +39,7 @@ def __init__(self, q_id, queue):
3939
4040 logging .debug ("Qubit thread with qubit %s has been created." , q_id )
4141
42- def apply_single_gate (self , mat , id ):
42+ def apply_single_gate (self , mat , q_id ):
4343 """
4444 Applys a single gate to a qubit.
4545
@@ -48,7 +48,7 @@ def apply_single_gate(self, mat, id):
4848 id (String): Qubit on which the gate should be applied to.
4949 """
5050 apply_mat = mat
51- nr = self .qubits .index (id )
51+ nr = self .qubits .index (q_id )
5252 total_amount = len (self .qubits )
5353 before = nr
5454 after = total_amount - nr - 1
@@ -58,14 +58,14 @@ def apply_single_gate(self, mat, id):
5858 apply_mat = np .kron (apply_mat , np .eye (2 ** after ))
5959 self .qubit = np .dot (apply_mat , self .qubit )
6060
61- def apply_controlled_gate (self , mat , id1 , id2 ):
61+ def apply_controlled_gate (self , mat , q_id1 , q_id2 ):
6262 """
6363 Apply a controlled gate to
6464 """
6565 first_mat = 1
6666 second_mat = 1
67- nr1 = self .qubits .index (id1 )
68- nr2 = self .qubits .index (id2 )
67+ nr1 = self .qubits .index (q_id1 )
68+ nr2 = self .qubits .index (q_id2 )
6969 min_nr = min (nr1 , nr2 )
7070 max_nr = max (nr1 , nr2 )
7171 if min_nr == nr1 :
@@ -128,13 +128,13 @@ def send_qubits(self, channel):
128128 channel .put (dp (self .qubits ))
129129 return
130130
131- def measure_non_destructive (self , id , ret_channel ):
131+ def measure_non_destructive (self , q_id , ret_channel ):
132132 """
133133 Perform a non destructive measurement on qubit with the id.
134134 """
135135 # determine probability for |1>
136136 measure_vec = np .array ([1 , 0 ], dtype = np .csingle )
137- nr = self .qubits .index (id )
137+ nr = self .qubits .index (q_id )
138138 total_amount = len (self .qubits )
139139 before = nr
140140 after = total_amount - nr - 1
@@ -166,13 +166,13 @@ def measure_non_destructive(self, id, ret_channel):
166166 norm = np .linalg .norm (self .qubit )
167167 self .qubit = self .qubit / norm
168168
169- def measure (self , id , ret_channel ):
169+ def measure (self , q_id , ret_channel ):
170170 """
171171 Perform a destructive measurement on qubit with the id.
172172 """
173173 # determine probability for |1>
174174 measure_vec = np .array ([1 , 0 ], dtype = np .csingle )
175- nr = self .qubits .index (id )
175+ nr = self .qubits .index (q_id )
176176 total_amount = len (self .qubits )
177177 before = nr
178178 after = total_amount - nr - 1
@@ -198,7 +198,7 @@ def measure(self, id, ret_channel):
198198 if after > 0 :
199199 reduction_mat = np .kron (
200200 reduction_mat , np .eye (2 ** after , dtype = np .csingle ))
201- self .qubits .remove (id )
201+ self .qubits .remove (q_id )
202202 if total_amount == 1 :
203203 # it was the last qubit, just terminate this process
204204 return
0 commit comments