Skip to content

Commit 5f665a0

Browse files
committed
Added test with faulty config.
1 parent 1d6c0cc commit 5f665a0

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed

test/test_model_breaking.cfg

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"Qubits" : {
3+
"Q1" : {
4+
"c3type": "Qubit",
5+
"desc" : "Qubit 1",
6+
"params": {
7+
"freq" : {
8+
"value" : 4.8e9,
9+
"unit" : "Hz 2pi",
10+
"min_val" : 4.5e9,
11+
"max_val" : 5.5e9
12+
}
13+
},
14+
"hilbert_dim" : 2
15+
},
16+
"Q2" : {
17+
"c3type": "Qubit",
18+
"desc" : "Qubit 2",
19+
"params": {
20+
"freq" : {
21+
"value" : 4.9e9,
22+
"unit" : "Hz 2pi",
23+
"min_val" : 4.5e9,
24+
"max_val" : 5.5e9
25+
}
26+
},
27+
"hilbert_dim" : 2
28+
},
29+
"Q3" : {
30+
"c3type": "Qubit",
31+
"desc" : "Qubit 1",
32+
"params": {
33+
"freq" : {
34+
"value" : 5e9,
35+
"unit" : "Hz 2pi",
36+
"min_val" : 4.5e9,
37+
"max_val" : 5.5e9
38+
}
39+
},
40+
"hilbert_dim" : 2
41+
},
42+
"Q4" : {
43+
"c3type": "Qubit",
44+
"desc" : "Qubit 2",
45+
"params": {
46+
"freq" : {
47+
"value" : 5.2e9,
48+
"unit" : "Hz 2pi",
49+
"min_val" : 4.5e9,
50+
"max_val" : 5.5e9
51+
}
52+
},
53+
"hilbert_dim" : 2
54+
},
55+
"Q5" : {
56+
"c3type": "Qubit",
57+
"desc" : "Qubit 1",
58+
"params": {
59+
"freq" : {
60+
"value" : 5.1e9,
61+
"unit" : "Hz 2pi",
62+
"min_val" : 4.5e9,
63+
"max_val" : 5.5e9
64+
}
65+
},
66+
"hilbert_dim" : 2
67+
},
68+
"Q6" : {
69+
"c3type": "Qubit",
70+
"desc" : "Qubit 2",
71+
"params": {
72+
"freq" : {
73+
"value" : 4.6e9,
74+
"unit" : "Hz 2pi",
75+
"min_val" : 4.5e9,
76+
"max_val" : 5.5e9
77+
}
78+
},
79+
"hilbert_dim" : 2
80+
}
81+
},
82+
"Couplings" : {
83+
"Q1-Q2" : {
84+
"c3type": "Coupling",
85+
"desc" : "Coupling qubit 1 and 2",
86+
"params": {
87+
"strength" : {
88+
"value" : 20e6,
89+
"unit" : "Hz 2pi",
90+
"min_val" : -1e6,
91+
"max_val" : 50e6
92+
}
93+
},
94+
"hamiltonian_func" : "int_XX",
95+
"connected" : ["Q1", "Q2"]
96+
},
97+
"Q4-Q6" : {
98+
"c3type": "Coupling",
99+
"desc" : "Coupling qubit 1 and 2",
100+
"params": {
101+
"strength" : {
102+
"value" : 20e6,
103+
"unit" : "Hz 2pi",
104+
"min_val" : -1e6,
105+
"max_val" : 50e6
106+
}
107+
},
108+
"hamiltonian_func" : "int_XX",
109+
"connected" : ["Q4", "Q6"]
110+
},
111+
"d1" : {
112+
"c3type": "Drive",
113+
"desc" : "Drive on qubit 1",
114+
"connected" : ["Q1"],
115+
"hamiltonian_func" : "x_drive"
116+
},
117+
"Q2" : {
118+
"c3type": "Drive",
119+
"desc" : "Drive on qubit 2",
120+
"connected" : ["Q2"],
121+
"hamiltonian_func" : "x_drive"
122+
}
123+
}
124+
}

test/test_parsers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
pmap.read_config("test/instructions.cfg")
1818

1919

20+
@pytest.mark.unit
21+
def test_name_collision() -> None:
22+
broken_model = Model()
23+
with pytest.raises(KeyError):
24+
broken_model.read_config("test/test_model_breaking.cfg")
25+
26+
2027
@pytest.mark.unit
2128
def test_subsystems() -> None:
2229
assert list(model.subsystems.keys()) == ["Q1", "Q2", "Q3", "Q4", "Q5", "Q6"]

0 commit comments

Comments
 (0)