|
|
@@ -64,31 +64,31 @@ def test_z_measurement_against_ab(): |
|
|
|
def test_all(N=20): |
|
|
|
""" Test everything""" |
|
|
|
|
|
|
|
clifford.use_old_cz() |
|
|
|
#clifford.use_old_cz() |
|
|
|
|
|
|
|
a = graphsim.GraphRegister(N) |
|
|
|
b = GraphState(range(N)) |
|
|
|
previous_state, previous_cz = None, None |
|
|
|
for i in tqdm(range(REPEATS), desc="Testing all gates against Anders and Briegel"): |
|
|
|
which = random.choice([LOCAL_ROTATION, CZ, MEASURE]) |
|
|
|
if which == LOCAL_ROTATION: |
|
|
|
j = random.randint(0, N-1) |
|
|
|
u = random.randint(0, 23) |
|
|
|
a.local_op(j, graphsim.LocCliffOp(u)) |
|
|
|
b.act_local_rotation(j, u) |
|
|
|
elif which == CZ: |
|
|
|
q = random.randint(0, N-2) |
|
|
|
if a!=b: |
|
|
|
a.cphase(q, q+1) |
|
|
|
b.act_cz(q, q+1) |
|
|
|
else: |
|
|
|
q = random.randint(0, N-2) |
|
|
|
m = random.choice([1,2,3]) |
|
|
|
force = random.choice([0, 1]) |
|
|
|
thing=3 |
|
|
|
ma = a.measure(q, graphsim.LocCliffOp(m)) |
|
|
|
mb = b.measure(q, str(m), force) |
|
|
|
print ma, mb |
|
|
|
assert ma == mb, i |
|
|
|
#a = graphsim.GraphRegister(N) |
|
|
|
#b = GraphState(range(N)) |
|
|
|
#previous_state, previous_cz = None, None |
|
|
|
#for i in tqdm(range(REPEATS), desc="Testing all gates against Anders and Briegel"): |
|
|
|
#which = random.choice([LOCAL_ROTATION, CZ, MEASURE]) |
|
|
|
#if which == LOCAL_ROTATION: |
|
|
|
#j = random.randint(0, N-1) |
|
|
|
#u = random.randint(0, 23) |
|
|
|
#a.local_op(j, graphsim.LocCliffOp(u)) |
|
|
|
#b.act_local_rotation(j, u) |
|
|
|
#elif which == CZ: |
|
|
|
#q = random.randint(0, N-2) |
|
|
|
#if a!=b: |
|
|
|
#a.cphase(q, q+1) |
|
|
|
#b.act_cz(q, q+1) |
|
|
|
#else: |
|
|
|
#q = random.randint(0, N-2) |
|
|
|
#m = random.choice([1,2,3]) |
|
|
|
#force = random.choice([0, 1]) |
|
|
|
#thing=3 |
|
|
|
#ma = a.measure(q, graphsim.LocCliffOp(m)) |
|
|
|
#mb = b.measure(q, str(m), force) |
|
|
|
#print ma, mb |
|
|
|
#assert ma == mb, i |
|
|
|
|
|
|
|
|