-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathtest_optim_init.py
44 lines (31 loc) · 1.11 KB
/
test_optim_init.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
"""Test module to check if optimizer classes are initialized correcty by the main file.
"""
import hjson
from c3.optimizers.c1 import C1
from c3.experiment import Experiment
from c3.main import run_cfg
def test_main_c1() -> None:
with open("test/c1.cfg", "r") as cfg_file:
cfg = hjson.load(cfg_file)
run_cfg(cfg, "test/c1.cfg", debug=True)
def test_main_c2() -> None:
with open("test/c2.cfg", "r") as cfg_file:
cfg = hjson.load(cfg_file)
run_cfg(cfg, "test/c2.cfg", debug=True)
def test_main_c3() -> None:
with open("test/c3.cfg", "r") as cfg_file:
cfg = hjson.load(cfg_file)
run_cfg(cfg, "test/c3.cfg", debug=True)
def test_main_sens() -> None:
with open("test/sensitivity.cfg", "r") as cfg_file:
cfg = hjson.load(cfg_file)
run_cfg(cfg, "test/sensitivity.cfg", debug=True)
def test_create_c1() -> None:
with open("test/c1.cfg", "r") as cfg_file:
cfg = hjson.load(cfg_file)
cfg.pop("optim_type")
cfg.pop("gateset_opt_map")
cfg.pop("opt_gates")
exp = Experiment()
exp.read_config(cfg.pop("exp_cfg"))
C1(**cfg, pmap=exp.pmap)