-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurface_code_test.py
More file actions
105 lines (84 loc) · 2.53 KB
/
surface_code_test.py
File metadata and controls
105 lines (84 loc) · 2.53 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""
Test routines for the functions in 'surface_code.py'
created on: 20/07/17
@author: eduardo
"""
import unittest
import numpy as np
import numpy.testing as nptest
import surface_code
# initialize the surface code object
distance = 6
surface = "toric"
sc = surface_code.SurfaceCode(distance, surface)
sc.select_measurement_protocol(0, 0, "single_rounds")
print("-------------------Testing random noise------------------------")
sc.apply_qubit_error(0.5, 0.5)
print(sc.qubits)
print("-------------------Testing stabilizer measurements-------------")
sc.reset()
sc.apply_qubit_error(.3, .3)
sc.measure_stabilizer_type("star")
sc.measure_stabilizer_type("plaq")
print(sc.tags)
print(sc.qubits)
print("-------------------Testing stabilizer lie-------------")
sc.reset()
sc._stabilizer_lie("S", .5)
sc._stabilizer_lie("P", .5)
print(sc.qubits[0])
#
#
#
# class TestSurfaceCode(unittest.TestCase):
# """Test class for the surface code."""
#
# def test_structure(self):
# print("-------------------Testing structure------------------------")
# stars_position = np.array([[0, 0, 0, 2, 2, 2, 4, 4, 4],
# [1, 3, 5, 1, 3, 5, 1, 3, 5]])
#
# plaqs_position = np.array([[1, 1, 1, 3, 3, 3, 5, 5, 5],
# [0, 2, 4, 0, 2, 4, 0, 2, 4]])
#
# np.testing.assert_array_equal(stars_position, sc.stars)
# np.testing.assert_array_equal(plaqs_position, sc.plaqs)
#
#
# def test_apply_random_error(self):
# print("-------------------Testing random noise------------------------")
# sc._apply_noise_qubit(0.5, 0.5)
# print(sc.qubits)
#
# def test_measure_stabilizer(self):
# print("-------------------Testing stabilizer measurements-------------")
# sc.reset()
# sc._apply_noise_qubit(.3, .3)
# sc.measure_stabilizer_type("star")
# sc.measure_stabilizer_type("plaq")
# print(sc.tags)
# print(sc.qubits)
#
# def test_stabilizer_lie_all(self):
# print("-------------------Testing stabilizer lie-------------")
# sc.reset()
# sc._stabilizer_lie("S", .5)
# sc._stabilizer_lie("P", .5)
# print(sc.qubits[0])
#
#
# # def test_two_rand_stab_qubits(self):
# # print("____________________________")
# # test_pos = np.array([[0, 1], [0, 2]])
# # a,b = sc._two_rand_stab_qubits(test_pos)
# # print(test_pos)
# # print(a)
# # print(b)
#
# # def test_
#
#
#
#
# if __name__ == '__main__':
# unittest.main()