diff --git a/quam/components/__init__.py b/quam/components/__init__.py index 75dde8b9..5c3d6a38 100644 --- a/quam/components/__init__.py +++ b/quam/components/__init__.py @@ -1,9 +1,11 @@ +from .basic_quam import * from .hardware import * from .octave import * from .channels import * from . import pulses __all__ = [ + *basic_quam.__all__, *hardware.__all__, *channels.__all__, *octave.__all__, diff --git a/quam/components/basic_quam.py b/quam/components/basic_quam.py new file mode 100644 index 00000000..d7cd5ee6 --- /dev/null +++ b/quam/components/basic_quam.py @@ -0,0 +1,17 @@ +from typing import Dict +from dataclasses import field + +from quam.core import QuamRoot, quam_dataclass +from quam.components.channels import Channel +from quam.components.octave import Octave + + +__all__ = [ + "BasicQuAM", +] + + +@quam_dataclass +class BasicQuAM(QuamRoot): + channels: Dict[str, Channel] = field(default_factory=dict) + octaves: Dict[str, Octave] = field(default_factory=dict) diff --git a/tests/components/test_basic_quam.py b/tests/components/test_basic_quam.py new file mode 100644 index 00000000..dc31307c --- /dev/null +++ b/tests/components/test_basic_quam.py @@ -0,0 +1,43 @@ +from copy import deepcopy +from quam.components import BasicQuAM, SingleChannel +from quam.core.qua_config_template import qua_config_template + + +def test_instantiate_basic_quam_empty(): + quam = BasicQuAM() + assert quam.channels == {} + assert quam.octaves == {} + + d = quam.to_dict() + assert d == { + "__class__": "quam.components.basic_quam.BasicQuAM", + } + + +def test_instantiate_basic_quam_with_channel(): + quam = BasicQuAM(channels={"single": SingleChannel(opx_output=("con1", 1))}) + d = quam.to_dict() + assert d == { + "__class__": "quam.components.basic_quam.BasicQuAM", + "channels": { + "single": { + "__class__": "quam.components.channels.SingleChannel", + "opx_output": ("con1", 1), + }, + }, + } + + +def test_generate_basic_quam_config(): + quam = BasicQuAM() + cfg = quam.generate_config() + expected_cfg = deepcopy(qua_config_template) + assert cfg == expected_cfg + + quam.channels = {"single": SingleChannel(opx_output=("con1", 1))} + cfg = quam.generate_config() + + quam.channels["single"].apply_to_config(expected_cfg) + expected_cfg["controllers"]["con1"]["analog_outputs"][1]["offset"] = 0.0 + + assert cfg == expected_cfg