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.

test_measurement_against_anders_and_briegel.py 1.4KB

преди 8 години
преди 8 години
преди 8 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_multiqubit_measurement_pz():
  10. """ Test a multiqubit measurement """
  11. for i in tqdm(range(REPEATS)):
  12. a, b = dummy.random_state(messy=False)
  13. j = np.random.choice(range(N))
  14. k = "pz"
  15. a.measure(j, k, 0)
  16. print a.to_json()
  17. print b.to_json()
  18. print
  19. #assert a.to_json() == b.to_json(), a
  20. def test_2qubit():
  21. """ Relentless testing of measurements """
  22. for measurement in (3, 2, 1):
  23. for outcome in (0, 1):
  24. a, b = dummy.bell()
  25. a.measure(0, str(measurement), outcome)
  26. b.measure(0, m[measurement], None, outcome)
  27. assert a == b, "FUCK"
  28. #print a.to_json()
  29. #print b.to_json()
  30. assert a == b, (measurement, outcome)
  31. def test_multiqubit():
  32. """ Relentless testing of measurements """
  33. for measurement in (1,):
  34. for i in tqdm(range(1000), "Testing {} measurement".format(measurement)):
  35. for outcome in (0, 1):
  36. a, b = dummy.random_state(N, messy=False)
  37. a.measure(0, str(measurement), outcome)
  38. b.measure(0, m[measurement], None, outcome)
  39. assert a == b, (measurement, outcome)