-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
61 lines (51 loc) · 1.66 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import unittest
from qecco import System
class TestEncoder(unittest.TestCase):
def test_simple_cost(self):
en_params = {
"simple_cost": True,
"ancillae": [0],
"save_data": False,
"verbose": False,
}
en_simple = System("encoder", en_params)
en_simple.build_codes().optimize()
self.assertLess(en_simple.results["bestError"], 1e-13)
def test_default(self):
en_params = {
"print_every": 10,
"simple_cost": True,
"ancillae": [0],
"save_data": False,
"verbose": False,
}
en = System("encoder", en_params)
en.build_codes().optimize()
self.assertLess(en.results["bestError"], 1e-13)
class TestDecoder(unittest.TestCase):
def test_default(self):
de_params = {
"print_every": 10,
"simple_cost": False,
"ancillae": [0],
"save_data": False,
"verbose": False,
}
de = System("decoder", de_params)
de.build_rhos().apply_loss().optimize()
self.assertAlmostEqual(de.results["bestError"], 0.092746875)
class TestRydberg(unittest.TestCase):
def test_CNOT(self):
ryd_params = {
"num_of_layers": 5,
"opt_algorithm": "BOBYQA",
"code_name": "CNOT_rydberg",
"pulse_sequence": "CNOT",
"verbose": True,
"save_data": False,
}
ryd = System("rydberg", ryd_params)
ryd.build_codes().optimize()
self.assertLess(ryd.results["bestError"], 1e-13)
if __name__ == '__main__':
unittest.main()