Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.6KB

  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. a, b = dummy.messy_random_state(3)
  33. assert a == b
  34. oa = a.measure(0, str(measurement), outcome)
  35. ob = b.measure(0, m[measurement], None, outcome)
  36. assert oa == ob, (oa, ob)
  37. print a.to_json()
  38. print b.to_json()
  39. assert a == b, (measurement, outcome)