Skip to content

Commit

Permalink
Conf_test, basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLaudatQM committed Mar 18, 2024
1 parent 24c149b commit adb49f9
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests_against_server/callable_from_qua/test_basic_qua_callable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from qm.qua import *
from qualang_tools.callable_from_qua import *

patch_qua_program_addons()


registered_calls = []
@callable_from_qua
def register_calls(*args, **kwargs):
registered_calls.append({"args": args, "kwargs": kwargs})

def test_qua_callable_no_args(qmm, config):
registered_calls.clear()
with program() as prog:
register_calls()

assert not registered_calls
qm = qmm.open_qm(config)
job = qm.execute(prog)

from time import sleep
sleep(10)
assert registered_calls == [{"args": (), "kwargs": {}}]
101 changes: 101 additions & 0 deletions tests_against_server/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from pathlib import Path
import toml
import pytest

from qm import QuantumMachinesManager


@pytest.fixture
def qmm():
config_file = Path.home() / ".qm_config.toml"
if not config_file.exists():
raise FileNotFoundError(
"Could not locate ~/.qm_config.toml, cannot extract IP and port to execute tests"
)

config = toml.load(config_file)
if "qmm" not in config:
raise KeyError("'qmm' must be defined in ~/.qm_config.toml to run server tests")

qmm = QuantumMachinesManager(**config["qmm"])
qmm.close_all_quantum_machines()

return qmm


@pytest.fixture
def config():

return {
"version": 1,
"controllers": {
"con1": {
"type": "opx1",
"analog_outputs": {
1: {"offset": +0.0},
2: {"offset": +0.0},
3: {"offset": +0.0},
},
"digital_outputs": {1: {}, 2: {}},
}
},
"elements": {
"qe1": {
"singleInput": {"port": ("con1", 1)},
"intermediate_frequency": 0,
"operations": {
"playOp": "constPulse",
"a_pulse": "arb_pulse1",
"playOp2": "constPulse2",
},
"digitalInputs": {
"digital_input1": {
"port": ("con1", 1),
"delay": 0,
"buffer": 0,
}
},
},
},
"pulses": {
"constPulse": {
"operation": "control",
"length": 1000, # in ns
"waveforms": {"single": "const_wf"},
},
"constPulse2": {
"operation": "control",
"length": 1000, # in ns
"waveforms": {"single": "const_wf"},
"digital_marker": "ON",
},
"arb_pulse1": {
"operation": "control",
"length": 100, # in ns
"waveforms": {"single": "arb_wf"},
},
"constPulse_mix": {
"operation": "control",
"length": 80,
"waveforms": {"I": "const_wf", "Q": "zero_wf"},
},

},
"waveforms": {
"zero_wf": {"type": "constant", "sample": 0.0},
"const_wf": {"type": "constant", "sample": 0.2},
"arb_wf": {"type": "arbitrary", "samples": [i / 200 for i in range(100)]},
},
"digital_waveforms": {
"ON": {"samples": [(1, 0)]},
},
"mixers": {
"mixer_qubit": [
{
"intermediate_frequency": 0,
"lo_frequency": 0,
"correction": (1,0,0,1),
}
],
},
}

0 comments on commit adb49f9

Please sign in to comment.