diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e2818d2..1c9b8f72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ ### Changed - `Pulse.integration_weights` now defaults to `#./default_integration_weights`, which returns [(1, pulse.length)] +### Fixed +- Fixed issues with parameters being references in a QuamRoot object + ## [0.3.8] ### Added diff --git a/quam/core/quam_classes.py b/quam/core/quam_classes.py index db2eb46a..2dafc739 100644 --- a/quam/core/quam_classes.py +++ b/quam/core/quam_classes.py @@ -718,9 +718,6 @@ def generate_config(self) -> Dict[str, Any]: return qua_config - # def get_unreferenced_value(self, attr: str): - # return getattr(self, attr) - class QuamComponent(QuamBase): """Base class for any QuAM component class. diff --git a/tests/quam_base/referencing/test_quam_root_referencing.py b/tests/quam_base/referencing/test_quam_root_referencing.py new file mode 100644 index 00000000..25fbfeb8 --- /dev/null +++ b/tests/quam_base/referencing/test_quam_root_referencing.py @@ -0,0 +1,32 @@ +from quam import QuamRoot, QuamComponent, quam_dataclass +import warnings + + +@quam_dataclass +class Component(QuamComponent): + y: int = 2 + + +@quam_dataclass +class Root(QuamRoot): + a: Component + b: Component = "#/a" + + +def test_quam_root_reference(): + with warnings.catch_warnings(): + warnings.simplefilter("error") + root = Root(a=Component()) + assert root.a is root.b + + +def test_quam_root_reference_to_dict(): + with warnings.catch_warnings(): + warnings.simplefilter("error") + root = Root(a="#/b", b=Component()) + d = root.to_dict() + assert d == { + "a": "#/b", + "b": {}, + "__class__": "test_quam_root_referencing.Root", + } diff --git a/tests/test_quam_get_attrs.py b/tests/quam_base/test_quam_get_attrs.py similarity index 100% rename from tests/test_quam_get_attrs.py rename to tests/quam_base/test_quam_get_attrs.py