@@ -21,6 +21,9 @@ def __init__(self):
2121 def new_qubit (self , id ):
2222 """
2323 Creates a new qubit with an id.
24+
25+ Args:
26+ id (String): Id of the new qubit.
2427 """
2528 q = multiprocessing .Queue ()
2629 thread = QubitThread (id , q )
@@ -73,7 +76,8 @@ def T_gate(self, q_id):
7376 Applies the T gate to the Qubit with q_id.
7477 """
7578 x = np .array (
76- [[1 , 0 ], [0 , (0.7071067811865476 + 0.7071067811865475j )]], dtype = np .csingle )
79+ [[1 , 0 ], [0 , (0.7071067811865476 + 0.7071067811865475j )]],
80+ dtype = np .csingle )
7781 q = self .shared_dict .get_queues_for_ids ([q_id ])[0 ]
7882 q .put ([SINGLE_GATE , x , q_id ])
7983
@@ -127,6 +131,10 @@ def merge_qubits(self, q_id1, q_id2):
127131 """
128132 Merges two qubits to one process, if they are not already
129133 running in the same process.
134+
135+ Args:
136+ q_id1 (String): Id of the Qubit merged into q_id2.
137+ q_id2 (String): Id of the Qubit merged with q_id1.
130138 """
131139 l = self .shared_dict .get_queues_for_ids ([q_id1 , q_id2 ])
132140 if len (l ) == 1 :
@@ -148,6 +156,10 @@ def cnot_gate(self, q_id1, q_id2):
148156 """
149157 Applies a controlled X gate, where the gate is applied to
150158 q_id1 and controlled by q_id2.
159+
160+ Args:
161+ q_id1 (String): Id of the Qubit on which the X gate is applied.
162+ q_id2 (String): Id of the Qubit which controls the gate.
151163 """
152164 x = np .array ([[0 , 1 ], [1 , 0 ]], dtype = np .csingle )
153165 self .merge_qubits (q_id1 , q_id2 )
@@ -156,7 +168,7 @@ def cnot_gate(self, q_id1, q_id2):
156168
157169 def cphase_gate (self , q_id1 , q_id2 ):
158170 """
159- Applies a controlled X gate, where the gate is applied to
171+ Applies a controlled Z gate, where the gate is applied to
160172 q_id1 and controlled by q_id2.
161173 """
162174 x = np .array ([[0 , 1 ], [0 , - 1 ]], dtype = np .csingle )
@@ -167,8 +179,13 @@ def cphase_gate(self, q_id1, q_id2):
167179 def measure (self , id , non_destructive = False ):
168180 """
169181 Measures a qubit with an id. If non_destructive is False, the qubit
170- is removed from the system, otherwise, the qubit stays in the system after
171- measurement, but its wavefunction collapses.
182+ is removed from the system, otherwise, the qubit stays in the system
183+ after measurement, but its wavefunction collapses.
184+
185+ Args:
186+ id (String): Id of the Qubit which should be measured.
187+ non_destructive(bool): If a qubit should not be removed from the
188+ system after measurement.
172189 """
173190 ret = self .manager .Queue ()
174191 q = self .shared_dict .get_queues_for_ids ([id ])[0 ]
@@ -179,4 +196,6 @@ def measure(self, id, non_destructive=False):
179196 res = ret .get ()
180197 if not non_destructive :
181198 self .shared_dict .delete_id_and_check_to_join_thread (id )
199+ logging .debug (
200+ "Qubit with id %s has been measured with outcome %d." , id , res )
182201 return res
0 commit comments