Anders and Briegel in Python
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

46 rindas
1.4KB

  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)