-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24c149b
commit adb49f9
Showing
2 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
tests_against_server/callable_from_qua/test_basic_qua_callable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": {}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
} | ||
], | ||
}, | ||
} |