From 7fa30a9c5ddbe04e68ad13f8c7fccc14d78ffd78 Mon Sep 17 00:00:00 2001 From: PONS Date: Tue, 3 Feb 2026 09:54:18 +0100 Subject: [PATCH 1/4] Add element description field --- pyaml/common/element.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pyaml/common/element.py b/pyaml/common/element.py index 0c6632bc..0733fb52 100644 --- a/pyaml/common/element.py +++ b/pyaml/common/element.py @@ -37,6 +37,8 @@ class ElementConfigModel(BaseModel): ---------- name : str The name of the PyAML element. + descriton : str + Descrition of the elements lattice_names : str or None, optional The name(s) of the associated element(s) in the lattice. By default, the PyAML element name is used. lattice_name accept the following @@ -51,6 +53,7 @@ class ElementConfigModel(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, extra="forbid") name: str + description: str | None = None lattice_names: str | None = None @@ -82,6 +85,12 @@ def get_lattice_names(self) -> str: else: return self._cfg.lattice_names + def get_descripton(self) -> str: + """ + Returns the description of the element + """ + return self._cfg.description + def set_energy(self, E: float): """ Set the instrument energy on this element From cb7274e8c79d34e3797f471c587697cc8fa6c1fb Mon Sep 17 00:00:00 2001 From: kparasch Date: Wed, 4 Feb 2026 20:07:43 +0100 Subject: [PATCH 2/4] typo fixes --- pyaml/common/element.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyaml/common/element.py b/pyaml/common/element.py index 0733fb52..ae2a1a3b 100644 --- a/pyaml/common/element.py +++ b/pyaml/common/element.py @@ -37,8 +37,8 @@ class ElementConfigModel(BaseModel): ---------- name : str The name of the PyAML element. - descriton : str - Descrition of the elements + description : str + Description of the element. lattice_names : str or None, optional The name(s) of the associated element(s) in the lattice. By default, the PyAML element name is used. lattice_name accept the following From e11327631d192578e2683c194f537e1f33ad0d24 Mon Sep 17 00:00:00 2001 From: PONS Date: Thu, 5 Feb 2026 08:54:11 +0100 Subject: [PATCH 3/4] Added description field to element/simulator and accelerator --- pyaml/accelerator.py | 12 ++++++++++++ pyaml/common/element.py | 4 ++-- pyaml/lattice/simulator.py | 9 +++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/pyaml/accelerator.py b/pyaml/accelerator.py index 73f3d39b..1f5fe5c4 100644 --- a/pyaml/accelerator.py +++ b/pyaml/accelerator.py @@ -40,6 +40,8 @@ class ConfigModel(BaseModel): Data folder arrays : list[ArrayConfig], optional Element family + description : str , optional + Acceleration description devices : list[Element] Element list """ @@ -52,6 +54,7 @@ class ConfigModel(BaseModel): controls: list[ControlSystem] = None simulators: list[Simulator] = None data_folder: str + description: str | None = None arrays: list[ArrayConfig] = None devices: list[Element] @@ -115,6 +118,12 @@ def post_init(self): for c in self._cfg.controls: c.post_init() + def get_description(self) -> str: + """ + Returns the description of the accelerator + """ + return self._cfg.description + @property def live(self) -> ControlSystem: return self.__live @@ -123,6 +132,9 @@ def live(self) -> ControlSystem: def design(self) -> Simulator: return self.__design + def __repr__(self): + return repr(self._cfg).replace("ConfigModel", self.__class__.__name__) + @staticmethod def from_dict(config_dict: dict, ignore_external=False) -> "Accelerator": """ diff --git a/pyaml/common/element.py b/pyaml/common/element.py index ae2a1a3b..5a7ecbb6 100644 --- a/pyaml/common/element.py +++ b/pyaml/common/element.py @@ -37,7 +37,7 @@ class ElementConfigModel(BaseModel): ---------- name : str The name of the PyAML element. - description : str + description : str, optional Description of the element. lattice_names : str or None, optional The name(s) of the associated element(s) in the lattice. By default, @@ -85,7 +85,7 @@ def get_lattice_names(self) -> str: else: return self._cfg.lattice_names - def get_descripton(self) -> str: + def get_description(self) -> str: """ Returns the description of the element """ diff --git a/pyaml/lattice/simulator.py b/pyaml/lattice/simulator.py index 579306c6..33e84e57 100644 --- a/pyaml/lattice/simulator.py +++ b/pyaml/lattice/simulator.py @@ -67,6 +67,8 @@ class ConfigModel(BaseModel): AT lattice ring name linker : LatticeElementsLinker, optional The linker configuration model + description : str , optional + Simulator description """ model_config = ConfigDict(arbitrary_types_allowed=True, extra="forbid") @@ -75,6 +77,7 @@ class ConfigModel(BaseModel): lattice: str mat_key: str = None linker: LatticeElementsLinker = None + description: str | None = None class Simulator(ElementHolder): @@ -109,6 +112,12 @@ def name(self) -> str: def get_lattice(self) -> at.Lattice: return self.ring + def get_description(self) -> str: + """ + Returns the description of the accelerator + """ + return self._cfg.description + def set_energy(self, E: float): self.ring.energy = E # Needed by energy dependant element (i.e. magnet coil current calculation) From 51bc61d938967aec5fb7683372dee8f9e8884e25 Mon Sep 17 00:00:00 2001 From: PONS Date: Thu, 5 Feb 2026 08:55:10 +0100 Subject: [PATCH 4/4] Added description field for unit tests --- tests/config/EBSTune.yaml | 3 +++ tests/test_tune.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/config/EBSTune.yaml b/tests/config/EBSTune.yaml index f4ce69b4..04f25524 100644 --- a/tests/config/EBSTune.yaml +++ b/tests/config/EBSTune.yaml @@ -2,8 +2,10 @@ type: pyaml.accelerator facility: ESRF machine: sr energy: 6e9 +description: "Accelerator configuration for EBS storage ring" simulators: - type: pyaml.lattice.simulator + description: "EBS lattice" lattice: sr/lattices/ebs.mat name: design controls: @@ -141,6 +143,7 @@ arrays: - QF1A-C03 devices: - type: pyaml.magnet.quadrupole + description: "QF1E-C04 quadrupole" name: QF1E-C04 model: type: pyaml.magnet.linear_model diff --git a/tests/test_tune.py b/tests/test_tune.py index 93e0b978..4c1af3f6 100644 --- a/tests/test_tune.py +++ b/tests/test_tune.py @@ -6,7 +6,14 @@ def test_tune(): - sr: Accelerator = Accelerator.load("tests/config/EBSTune.yaml", ignore_external=True) + sr: Accelerator = Accelerator.load( + "tests/config/EBSTune.yaml", ignore_external=True + ) + + assert sr.get_description() == "Accelerator configuration for EBS storage ring" + assert sr.design.get_magnet("QF1E-C04").get_description() == "QF1E-C04 quadrupole" + assert sr.design.get_description() == "EBS lattice" + sr.design.get_lattice().disable_6d() quadForTuneDesign = sr.design.get_magnets("QForTune")