-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
44 lines (36 loc) · 1.48 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import decoding_2d as dc2
import decoding_3d as dc3
import itertools as it
def circuit_syndrome_test():
"""
compares syndromes generated by measurement circuit with q = 0 to
those generated by perfect stabiliser measurement from 2D
simulation.
They all ought to match.
"""
two_d_sim = dc2.Sim2D(15, 15, 0.00)
three_d_sim = dc3.Sim3D(15, 1000, ('pq', 0.1, 0.0))
err_hist, synd_hist = three_d_sim.history()
for idx, err in enumerate(err_hist):
idl_x_synd, idl_z_synd = two_d_sim.syndromes(err)
assert synd_hist['X'][idx] == set(idl_x_synd)
assert synd_hist['Z'][idx] == set(idl_z_synd)
def path_pauli_len_test():
"""
compares lengths of path paulis to distances indicated by
pair_dist and bdy_info.
"""
two_d_sim = dc2.Sim2D(11, 11, 0.0)
anc = two_d_sim.layout.ancillas
x_pts = sum([list(anc[ki]) for ki in ['x_top', 'x_bot', 'x_sq']], [])
z_pts = sum([list(anc[ki]) for ki in ['z_left', 'z_right', 'z_sq']], [])
z_pts += two_d_sim.layout.boundary_points('X')
x_pts += two_d_sim.layout.boundary_points('Z')
for lst, err in zip([x_pts, z_pts], ['Z', 'X']):
for pair in it.combinations(lst, 2):
dist = dc2.pair_dist(*pair)
p_len = two_d_sim.path_pauli(pair[0], pair[1], err).weight()
if dist != p_len:
print pair, err, dist, p_len
assert dist == p_len
#---------------------------------------------------------------------#