@@ -194,13 +194,13 @@ def prep_I_state():
194194 return q
195195
196196
197+ # TODO - We can test these things better when we have implemented a get_qubit_state function for simulaqron
198+ # for now, we will permon tests based on the tomography function.
197199class TestSingleQubitGate :
198200 iterations : int = 1
199201
200202 @pytest .fixture
201203 def network (self ):
202- print (f"Testing single qubit gates gates with { self .iterations } iterations \n " )
203-
204204 simulaqron_settings .default_settings ()
205205 network = Network (nodes = ["Alice" ], force = True )
206206 network .start ()
@@ -213,144 +213,118 @@ def network(self):
213213 def test_X_Gate (self , network ):
214214 with SimulaQronConnection ("Alice" ) as conn :
215215 # Test X
216- print ("Testing X gate:" )
217216 exp_values = calc_exp_values (prep_X_state ())
218217 ans = conn .test_preparation (prep_X , exp_values , iterations = self .iterations )
219- print ("\n " )
220218 assert ans
221219
222220 def test_Y_Gate (self , network ):
223221 with SimulaQronConnection ("Alice" ) as conn :
224222 # Test Y
225- print ("Testing Y gate:" )
226223 exp_values = calc_exp_values (prep_Y_state ())
227224 ans = conn .test_preparation (prep_Y , exp_values , iterations = self .iterations )
228- print ("\n " )
229225 assert ans
230226
231227 def test_Z_Gate (self , network ):
232228 with SimulaQronConnection ("Alice" ) as conn :
233229 # Test Z
234- print ("Testing Z gate:" )
235230 exp_values = calc_exp_values (prep_Z_state ())
236231 ans = conn .test_preparation (prep_Z , exp_values , iterations = self .iterations )
237- print ("\n " )
238232 assert ans
239233
240234 def test_H_Gate (self , network ):
241235 with SimulaQronConnection ("Alice" ) as conn :
242236 # Test H
243- print ("Testing H gate:" )
244237 exp_values = calc_exp_values (prep_H_state ())
245238 ans = conn .test_preparation (prep_H , exp_values , iterations = self .iterations )
246- print ("\n " )
247239 assert ans
248240
249241 def test_T_Gate (self , network ):
250242 with SimulaQronConnection ("Alice" ) as conn :
251243 # Test T
252- print ("Testing T gate:" )
253244 exp_values = calc_exp_values (prep_T_state ())
254245 if simulaqron_settings .sim_backend == SimBackend .STABILIZER .value :
255246 with pytest .raises (SimUnsupportedError ):
256247 conn .test_preparation (prep_T , exp_values , iterations = self .iterations , progress = False )
257248 else :
258249 ans = conn .test_preparation (prep_T , exp_values , iterations = self .iterations )
259- print ("\n " )
260250 assert ans
261251
262252 def test_K_Gate (self , network ):
263253 with SimulaQronConnection ("Alice" ) as conn :
264254 # Test K
265- print ("Testing K gate:" )
266255 exp_values = calc_exp_values (prep_K_state ())
267256 ans = conn .test_preparation (prep_K , exp_values , iterations = self .iterations )
268- print ("\n " )
269257 assert ans
270258
271259 def test_X_pi8Rot (self , network ):
272260 with SimulaQronConnection ("Alice" ) as conn :
273261 # Test ROT_X pi/8
274- print ("Testing rotation (X,pi/8) gate:" )
275262 exp_values = calc_exp_values (prep_rot_state ([1 , 0 , 0 ], np .pi / 8 ))
276263 if simulaqron_settings .sim_backend == SimBackend .STABILIZER .value :
277264 with pytest .raises (SimUnsupportedError ):
278265 conn .test_preparation (prep_rotx1 , exp_values , iterations = self .iterations , progress = False )
279266 else :
280267 ans = conn .test_preparation (prep_rotx1 , exp_values , iterations = self .iterations )
281- print ("\n " )
282268 assert ans
283269
284270 def test_X_5pi8Rot (self , network ):
285271 with SimulaQronConnection ("Alice" ) as conn :
286272 # Test ROT_X 5*pi/8
287- print ("Testing rotation (X,5*pi/8) gate:" )
288273 exp_values = calc_exp_values (prep_rot_state ([1 , 0 , 0 ], 5 * np .pi / 8 ))
289274 if simulaqron_settings .sim_backend == SimBackend .STABILIZER .value :
290275 with pytest .raises (SimUnsupportedError ):
291276 conn .test_preparation (prep_rotx2 , exp_values , iterations = self .iterations , progress = False )
292277 else :
293278 ans = conn .test_preparation (prep_rotx2 , exp_values , iterations = self .iterations )
294- print ("\n " )
295279 assert ans
296280
297281 def test_Y_pi8Rot (self , network ):
298282 with SimulaQronConnection ("Alice" ) as conn :
299283 # Test ROT_Y pi/8
300- print ("Testing rotation (Y,pi/8) gate:" )
301284 exp_values = calc_exp_values (prep_rot_state ([0 , 1 , 0 ], np .pi / 8 ))
302285 if simulaqron_settings .sim_backend == SimBackend .STABILIZER .value :
303286 with pytest .raises (SimUnsupportedError ):
304287 conn .test_preparation (prep_roty1 , exp_values , iterations = self .iterations , progress = False )
305288 else :
306289 ans = conn .test_preparation (prep_roty1 , exp_values , iterations = self .iterations )
307- print ("\n " )
308290 assert ans
309291
310292 def test_Y_5pi8Rot (self , network ):
311293 with SimulaQronConnection ("Alice" ) as conn :
312294 # Test ROT_Y 5*pi/8
313- print ("Testing rotation (Y,5*pi/8) gate:" )
314295 exp_values = calc_exp_values (prep_rot_state ([0 , 1 , 0 ], 5 * np .pi / 8 ))
315296 if simulaqron_settings .sim_backend == SimBackend .STABILIZER .value :
316297 with pytest .raises (SimUnsupportedError ):
317298 conn .test_preparation (prep_roty2 , exp_values , iterations = self .iterations , progress = False )
318299 else :
319300 ans = conn .test_preparation (prep_roty2 , exp_values , iterations = self .iterations )
320- print ("\n " )
321301 assert ans
322302
323303 def test_Z_pi8Rot (self , network ):
324304 with SimulaQronConnection ("Alice" ) as conn :
325305 # Test ROT_Z pi/8
326- print ("Testing rotation (Z,pi/8) gate:" )
327306 exp_values = calc_exp_values (prep_rot_state ([0 , 0 , 1 ], np .pi / 8 ))
328307 if simulaqron_settings .sim_backend == SimBackend .STABILIZER .value :
329308 with pytest .raises (SimUnsupportedError ):
330309 conn .test_preparation (prep_rotz1 , exp_values , iterations = self .iterations , progress = False )
331310 else :
332311 ans = conn .test_preparation (prep_rotz1 , exp_values , iterations = self .iterations )
333- print ("\n " )
334312 assert ans
335313
336314 def test_Z_5pi8Rot (self , network ):
337315 with SimulaQronConnection ("Alice" ) as conn :
338316 # Test ROT_Z 5*pi/8
339- print ("Testing rotation (Z,5*pi/8) gate:" )
340317 exp_values = calc_exp_values (prep_rot_state ([0 , 0 , 1 ], 5 * np .pi / 8 ))
341318 if simulaqron_settings .sim_backend == SimBackend .STABILIZER .value :
342319 with pytest .raises (SimUnsupportedError ):
343320 conn .test_preparation (prep_rotz2 , exp_values , iterations = self .iterations , progress = False )
344321 else :
345322 ans = conn .test_preparation (prep_rotz2 , exp_values , iterations = self .iterations )
346- print ("\n " )
347323 assert ans
348324
349325 def test_Reset (self , network ):
350326 with SimulaQronConnection ("Alice" ) as conn :
351327 # Test RESET
352- print ("Testing RESET:" )
353328 exp_values = calc_exp_values (prep_I_state ())
354329 ans = conn .test_preparation (prep_reset , exp_values , iterations = self .iterations )
355- print ("\n " )
356330 assert ans
0 commit comments