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.

34 lines
926B

  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 = 2
  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_multiqubit_pz():
  21. for measurement in (3, 2,):
  22. for outcome in (0, 1):
  23. a, b = dummy.bell()
  24. a.measure(0, str(measurement), outcome)
  25. b.measure(0, m[measurement], None, outcome)
  26. print a.to_json()
  27. print b.to_json()
  28. assert a == b, (measurement, outcome)