@@ -67,6 +67,9 @@ def stop_all(self):
6767 def X_gate (self , q_id ):
6868 """
6969 Applies the Pauli X gate to the Qubit with q_id.
70+
71+ Args:
72+ q_id(String): ID of the Qubit to apply the gate to.
7073 """
7174 x = np .array ([[0 , 1 ], [1 , 0 ]], dtype = np .csingle )
7275 q = self .shared_dict .get_queues_for_ids ([q_id ])[0 ]
@@ -75,6 +78,9 @@ def X_gate(self, q_id):
7578 def Y_gate (self , q_id ):
7679 """
7780 Applies the Pauli Y gate to the Qubit with q_id.
81+
82+ Args:
83+ q_id(String): ID of the Qubit to apply the gate to.
7884 """
7985 x = np .array ([[0 , 0 - 1j ], [0 + 1j , 0 ]], dtype = np .csingle )
8086 q = self .shared_dict .get_queues_for_ids ([q_id ])[0 ]
@@ -83,6 +89,9 @@ def Y_gate(self, q_id):
8389 def Z_gate (self , q_id ):
8490 """
8591 Applies the Pauli Z gate to the Qubit with q_id.
92+
93+ Args:
94+ q_id(String): ID of the Qubit to apply the gate to.
8695 """
8796 x = np .array ([[1 , 0 ], [0 , - 1 ]], dtype = np .csingle )
8897 q = self .shared_dict .get_queues_for_ids ([q_id ])[0 ]
@@ -91,6 +100,9 @@ def Z_gate(self, q_id):
91100 def H_gate (self , q_id ):
92101 """
93102 Applies the Hadamard gate to the Qubit with q_id.
103+
104+ Args:
105+ q_id(String): ID of the Qubit to apply the gate to.
94106 """
95107 x = (1 / 2.0 ) ** 0.5 * np .array ([[1 , 1 ], [1 , - 1 ]], dtype = np .csingle )
96108 q = self .shared_dict .get_queues_for_ids ([q_id ])[0 ]
@@ -99,6 +111,9 @@ def H_gate(self, q_id):
99111 def T_gate (self , q_id ):
100112 """
101113 Applies the T gate to the Qubit with q_id.
114+
115+ Args:
116+ q_id(String): ID of the Qubit to apply the gate to.
102117 """
103118 x = np .array (
104119 [[1 , 0 ], [0 , (0.7071067811865476 + 0.7071067811865475j )]],
@@ -109,6 +124,9 @@ def T_gate(self, q_id):
109124 def S_gate (self , q_id ):
110125 """
111126 Applies the S gate to the Qubit with q_id.
127+
128+ Args:
129+ q_id(String): ID of the Qubit to apply the gate to.
112130 """
113131 x = np .array ([[1 , 0 ], [0 , 1j ]], dtype = np .csingle )
114132 q = self .shared_dict .get_queues_for_ids ([q_id ])[0 ]
@@ -117,14 +135,21 @@ def S_gate(self, q_id):
117135 def K_gate (self , q_id ):
118136 """
119137 Applies the K gate to the Qubit with q_id.
138+
139+ Args:
140+ q_id(String): ID of the Qubit to apply the gate to.
120141 """
121142 x = 0.5 * np .array ([[1 + 1j , 1 - 1j ], [- 1 + 1j , - 1 - 1j ]], dtype = np .csingle )
122143 q = self .shared_dict .get_queues_for_ids ([q_id ])[0 ]
123144 q .put ([SINGLE_GATE , x , q_id ])
124145
125146 def RX_gate (self , q_id , rad ):
126147 """
127- Applies the T gate to the Qubit with q_id.
148+ Applies a rotational X gate to the Qubit with q_id.
149+
150+ Args:
151+ q_id(String): ID of the Qubit to apply the gate to.
152+ rad(int): Rotational degrees in rad.
128153 """
129154 mid = np .cos (rad / 2 )
130155 other = - 1j * np .sin (rad / 2 )
@@ -134,7 +159,11 @@ def RX_gate(self, q_id, rad):
134159
135160 def RY_gate (self , q_id , rad ):
136161 """
137- Applies the T gate to the Qubit with q_id.
162+ Applies a rotational Y gate to the Qubit with q_id.
163+
164+ Args:
165+ q_id(String): ID of the Qubit to apply the gate to.
166+ rad(int): Rotational degrees in rad.
138167 """
139168 mid = np .cos (rad / 2 )
140169 other = np .sin (rad / 2 )
@@ -144,7 +173,11 @@ def RY_gate(self, q_id, rad):
144173
145174 def RZ_gate (self , q_id , rad ):
146175 """
147- Applies the T gate to the Qubit with q_id.
176+ Applies a rotational Z gate to the Qubit with q_id.
177+
178+ Args:
179+ q_id(String): ID of the Qubit to apply the gate to.
180+ rad(int): Rotational degrees in rad.
148181 """
149182 top = np .exp (- 1j * (rad / 2 ))
150183 bot = np .exp (1j * (rad / 2 ))
@@ -155,6 +188,10 @@ def RZ_gate(self, q_id, rad):
155188 def custom_gate (self , q_id , gate ):
156189 """
157190 Applies a custom gate to the qubit with q_id.
191+
192+ Args:
193+ q_id(String): Id of the Qubit to apply the gate on.
194+ gate(np.ndarray): unitary 2x2 matrix, of the gate.
158195 """
159196 q = self .shared_dict .get_queues_for_ids ([q_id ])[0 ]
160197 q .put ([SINGLE_GATE , gate , q_id ])
@@ -205,25 +242,56 @@ def cphase_gate(self, q_id1, q_id2):
205242 """
206243 Applies a controlled Z gate, where the gate is applied to
207244 q_id1 and controlled by q_id2.
245+
246+ Args:
247+ q_id1(String): Qubit id, on which the gate is applied on.
248+ q_id2(String): Qubit id, which controlls the gate.
208249 """
209250 x = np .array ([[0 , 1 ], [0 , - 1 ]], dtype = np .csingle )
210251 self .merge_qubits (q_id1 , q_id2 )
211252 q = self .shared_dict .get_queues_for_ids ([q_id1 ])[0 ]
212253 q .put ([CONTROLLED_GATE , x , q_id1 , q_id2 ])
213254
214255 def give_statevector_for (self , q_id ):
256+ """
257+ Gives the statevector and Qubits of a Qubit and all other Qubits with
258+ which the qubit is entangled.
259+
260+ Args:
261+ q_id(String): Qubit id of the Qubit to get the statevector from.
262+
263+ Returns:
264+ Tuple. Tuple of a lists and vector, where the first list are the qubits of
265+ the statevector and the second list is the statevector.
266+ """
215267 ret = self .manager .Queue ()
216268 q = self .shared_dict .get_queues_for_ids ([q_id ])[0 ]
217269 q .put ([GIVE_STATEVECTOR , q_id , ret ])
218270 qubits , vector = ret .get ()
219271 return qubits , vector
220272
221273 def custom_two_qubit_gate (self , q_id1 , q_id2 , gate ):
274+ """
275+ Applies a two Qubit gate to two Qubits.
276+
277+ Args:
278+ q_id1(String): ID of the first Qubit of the gate.
279+ q_id2(String): ID of the second Qubit of the gate.
280+ gate(np.ndarray): 4x4 unitary matrix gate.
281+ """
222282 self .merge_qubits (q_id1 , q_id2 )
223283 q = self .shared_dict .get_queues_for_ids ([q_id1 ])[0 ]
224284 q .put ([DOUBLE_GATE , gate , q_id1 , q_id2 ])
225285
226286 def custom_controlled_gate (self , applied_to_id , controlled_by_id , gate ):
287+ """
288+ Applies a custom controlled gate to a Qubit.
289+
290+ Args:
291+ applied_to_id(String): ID of the qubit to apply the gate to.
292+ controlled_by_id(String): ID of the qubit which controls the gate.
293+ gate(np.ndarray): Unitary 2x2 matrix which should be applied.
294+ """
227295 self .merge_qubits (applied_to_id , controlled_by_id )
228296 q = self .shared_dict .get_queues_for_ids ([applied_to_id ])[0 ]
229297 q .put ([CONTROLLED_GATE , gate , applied_to_id , controlled_by_id ])
0 commit comments