Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

53 lignes
2.1KB

  1. from abp import GraphState, clifford
  2. from anders_briegel import graphsim
  3. import numpy as np
  4. from tqdm import tqdm
  5. import dummy
  6. N = 10
  7. REPEATS = 10
  8. m = {1: graphsim.lco_X, 2: graphsim.lco_Y, 3: graphsim.lco_Z}
  9. def test_2qubit():
  10. """ Relentless testing of measurements """
  11. clifford.use_old_cz()
  12. for measurement in (3, 2, 1):
  13. for outcome in (0, 1):
  14. a, b = dummy.bell()
  15. a.measure(0, str(measurement), outcome)
  16. b.measure(0, m[measurement], None, outcome)
  17. assert a == b, (measurement, outcome)
  18. def test_multiqubit():
  19. """ Relentless testing of measurements """
  20. for measurement in (3,2,1,):
  21. for i in tqdm(range(REPEATS), "Testing measurement {}".format(measurement)):
  22. for outcome in (0, 1):
  23. a, b = dummy.clean_random_state(N)
  24. a.measure(0, str(measurement), outcome)
  25. b.measure(0, m[measurement], None, outcome)
  26. assert a == b, (measurement, outcome)
  27. def test_multiqubit2():
  28. """ Relentless testing of measurements """
  29. for measurement in (3,):
  30. for i in tqdm(range(REPEATS), "Testing {} measurement".format(measurement)):
  31. for outcome in (0, 1):
  32. for rotation in range(24):
  33. a, b = dummy.clean_random_state(3)
  34. assert a == b
  35. a.act_local_rotation(0, str(rotation))
  36. b.local_op(0, graphsim.LocCliffOp(rotation))
  37. #print "{} ------------------".format(rotation)
  38. #print "pjs b4:", a.to_json()
  39. #print "a&b b4:", b.to_json()
  40. oa = a.measure(0, str(measurement), outcome)
  41. ob = b.measure(0, m[measurement], None, outcome)
  42. assert oa == ob, (oa, ob, rotation)
  43. #print "pjs af:", a.to_json()
  44. #print "a&b af:", b.to_json()
  45. assert a == b, (measurement, outcome, rotation)
  46. #print