-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathtest_quick_setup.py
41 lines (35 loc) · 1.24 KB
/
test_quick_setup.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
"""
testing module quick setup class
"""
import numpy as np
import pytest
import pickle
from c3.experiment import Experiment
exp = Experiment()
exp.load_quick_setup("test/quickstart.hjson")
pmap = exp.pmap
model = pmap.model
generator = pmap.generator
@pytest.mark.integration
def test_exp_quick_setup_freqs() -> None:
"""
Test the quick setup.
"""
print(pmap.instructions.keys())
qubit_freq = model.subsystems["Q1"].params["freq"].get_value()
gate = pmap.instructions["rx90p[0]"]
carrier_freq = gate.comps["d1"]["carrier"].params["freq"].get_value()
offset = gate.comps["d1"]["gaussian"].params["freq_offset"].get_value()
assert qubit_freq == carrier_freq + offset
@pytest.mark.integration
def test_generator() -> None:
gen_signal = pmap.generator.generate_signals(pmap.instructions["rx90p[0]"])
with open("test/quick_data.pickle", "rb") as quickfile:
test_data = pickle.load(quickfile)
np.testing.assert_allclose(gen_signal["d1"]["ts"], test_data["d1"]["ts"], rtol=1e-8)
np.testing.assert_allclose(
actual=gen_signal["d1"]["values"].numpy()[1:],
desired=test_data["d1"]["values"].numpy()[1:],
rtol=1e-8,
)
# First pixel is wrong, due to an artifact in the old method.