diff --git a/pyaml/accelerator.py b/pyaml/accelerator.py index 73bfb13de..bfc979ed7 100644 --- a/pyaml/accelerator.py +++ b/pyaml/accelerator.py @@ -6,8 +6,8 @@ from .arrays.array import ArrayConfig from .common.element import Element, __pyaml_repr__ -from .common.element_holder import ElementHolder from .common.exception import PyAMLConfigException +from .common.holders.element_holder import ElementHolder from .configuration import ConfigurationManager, UnsupportedConfigurationRootError from .configuration.factory import Factory from .control.controlsystem import ControlSystem diff --git a/pyaml/apidoc/gen_api.py b/pyaml/apidoc/gen_api.py index 119af3a58..221511549 100644 --- a/pyaml/apidoc/gen_api.py +++ b/pyaml/apidoc/gen_api.py @@ -26,23 +26,25 @@ "pyaml.common.abstract_aggregator", "pyaml.common.constants", "pyaml.common.element", - "pyaml.common.element_holder", "pyaml.common.exception", - "pyaml.magnet.csvcurve", - "pyaml.magnet.csvmatrix", - "pyaml.magnet.curve", + "pyaml.common.holders.element_holder", + "pyaml.common.holders.magnet_holder", + "pyaml.common.holders.magnets_holder", + "pyaml.common.holders.serialized_magnet_holder", + "pyaml.common.holders.serialized_magnets_holder", + "pyaml.common.holders.combinded_function_magnet_holder", + "pyaml.common.holders.combinded_function_magnets_holder", "pyaml.configuration.factory", "pyaml.configuration.fileloader", - "pyaml.magnet.inline_curve", - "pyaml.magnet.inline_matrix", "pyaml.configuration.manager", - "pyaml.magnet.matrix", + "pyaml.configuration.restfetcher", + "pyaml.configuration.unbound_element", "pyaml.control.abstract_impl", "pyaml.control.controlsystem", "pyaml.control.deviceaccess", "pyaml.control.deviceaccesslist", "pyaml.control.readback_value", - "pyaml.tuning_tools.chromaticity_monitor", + "pyaml.diagnostics.atune_monitor", "pyaml.diagnostics.tune_monitor", "pyaml.external.pySC_interface", "pyaml.lattice.abstract_impl", @@ -52,40 +54,57 @@ "pyaml.lattice.simulator", "pyaml.magnet.cfm_magnet", "pyaml.magnet.corrector", + "pyaml.magnet.linear_cfm_model", + "pyaml.magnet.linear_model", + "pyaml.magnet.linear_serialized_model", "pyaml.magnet.function_mapping", "pyaml.magnet.hcorrector", "pyaml.magnet.identity_cfm_model", "pyaml.magnet.identity_model", - "pyaml.magnet.linear_cfm_model", - "pyaml.magnet.linear_model", - "pyaml.magnet.linear_serialized_model", "pyaml.magnet.magnet", + "pyaml.magnet.serialized_magnet", + "pyaml.magnet.spline_model", "pyaml.magnet.model", "pyaml.magnet.octupole", "pyaml.magnet.quadrupole", - "pyaml.magnet.serialized_magnet", "pyaml.magnet.sextupole", "pyaml.magnet.skewoctu", "pyaml.magnet.skewquad", "pyaml.magnet.skewsext", - "pyaml.magnet.spline_model", "pyaml.magnet.vcorrector", + "pyaml.magnet.csvcurve", + "pyaml.magnet.csvmatrix", + "pyaml.magnet.curve", + "pyaml.magnet.inline_curve", + "pyaml.magnet.inline_matrix", + "pyaml.magnet.matrix", "pyaml.rf.rf_plant", "pyaml.rf.rf_transmitter", # "pyaml.tuning_tools.LOCO.loco", # "pyaml.tuning_tools.SOFB.sofb", + "pyaml.tuning_tools.chromaticity", + "pyaml.tuning_tools.measurement_tool", + "pyaml.tuning_tools.chromaticity_response_matrix", "pyaml.tuning_tools.dispersion", + "pyaml.tuning_tools.response_matrix_data", "pyaml.tuning_tools.orbit", "pyaml.tuning_tools.orbit_response_matrix", - "pyaml.tuning_tools.chromaticity", - "pyaml.tuning_tools.tune", - "pyaml.tuning_tools.chromaticity_response_matrix", - "pyaml.tuning_tools.measurement_tool", "pyaml.tuning_tools.orbit_response_matrix_data", - "pyaml.tuning_tools.response_matrix_data", + "pyaml.tuning_tools.chromaticity_monitor", + "pyaml.tuning_tools.tune", "pyaml.tuning_tools.tune_response_matrix", "pyaml.tuning_tools.tuning_tool", + "pyaml.tuning_tools.bba", + "pyaml.tuning_tools.bba2", "pyaml.yellow_pages", + "pyaml._version", + "pyaml.validation.configuration_models", + "pyaml.validation.errors", + "pyaml.validation.generator", + "pyaml.validation.registry", + "pyaml.validation.schema_builder", + "pyaml.validation.validation_models", + "pyaml.validation.validator", ] diff --git a/pyaml/arrays/array.py b/pyaml/arrays/array.py index a1e4e427e..4036b19ac 100644 --- a/pyaml/arrays/array.py +++ b/pyaml/arrays/array.py @@ -5,7 +5,7 @@ from pyaml.common.exception import PyAMLException from ..common.element import __pyaml_repr__ -from ..common.element_holder import ElementHolder +from ..common.holders.element_holder import ElementHolder from ..validation import DynamicValidation, register_schema diff --git a/pyaml/arrays/bpm.py b/pyaml/arrays/bpm.py index 73c0ef800..65f50288c 100644 --- a/pyaml/arrays/bpm.py +++ b/pyaml/arrays/bpm.py @@ -1,4 +1,4 @@ -from ..common.element_holder import ElementHolder +from ..common.holders.element_holder import ElementHolder from ..validation import DynamicValidation, register_schema from .array import ArrayConfig diff --git a/pyaml/arrays/cfm_magnet.py b/pyaml/arrays/cfm_magnet.py index a2cb38c31..3fe229391 100644 --- a/pyaml/arrays/cfm_magnet.py +++ b/pyaml/arrays/cfm_magnet.py @@ -1,4 +1,4 @@ -from ..common.element_holder import ElementHolder +from ..common.holders.element_holder import ElementHolder from ..validation import DynamicValidation, register_schema from .array import ArrayConfig @@ -36,4 +36,4 @@ def fill_array(self, holder: ElementHolder): holder : ElementHolder The element holder to populate with combined function magnet array """ - holder.fill_cfm_magnet_array(self._name, self._elements) + holder.combined_function_magnets.add(self._name, self._elements) diff --git a/pyaml/arrays/element.py b/pyaml/arrays/element.py index 2233ccc0b..65a47b4e9 100644 --- a/pyaml/arrays/element.py +++ b/pyaml/arrays/element.py @@ -1,4 +1,4 @@ -from ..common.element_holder import ElementHolder +from ..common.holders.element_holder import ElementHolder from ..validation import DynamicValidation, register_schema from .array import ArrayConfig diff --git a/pyaml/arrays/element_array.py b/pyaml/arrays/element_array.py index dc6d2f330..942ecd856 100644 --- a/pyaml/arrays/element_array.py +++ b/pyaml/arrays/element_array.py @@ -12,7 +12,7 @@ from ..magnet.serialized_magnet import SerializedMagnets if TYPE_CHECKING: - from ..common.element_holder import ElementHolder + from ..common.holders.element_holder import ElementHolder class ElementArray(list[Element]): diff --git a/pyaml/arrays/magnet.py b/pyaml/arrays/magnet.py index e69f0cd42..93be15573 100644 --- a/pyaml/arrays/magnet.py +++ b/pyaml/arrays/magnet.py @@ -1,4 +1,4 @@ -from ..common.element_holder import ElementHolder +from ..common.holders.element_holder import ElementHolder from ..validation import DynamicValidation, register_schema from .array import ArrayConfig diff --git a/pyaml/arrays/serialized_magnet.py b/pyaml/arrays/serialized_magnet.py index d6a41af6d..62e495964 100644 --- a/pyaml/arrays/serialized_magnet.py +++ b/pyaml/arrays/serialized_magnet.py @@ -1,4 +1,4 @@ -from ..common.element_holder import ElementHolder +from ..common.holders.element_holder import ElementHolder from ..validation import DynamicValidation, register_schema from .array import ArrayConfig diff --git a/pyaml/common/element.py b/pyaml/common/element.py index 613d63b37..a874781ee 100644 --- a/pyaml/common/element.py +++ b/pyaml/common/element.py @@ -5,7 +5,7 @@ from .exception import PyAMLException if TYPE_CHECKING: - from ..common.element_holder import ElementHolder + from .holders.element_holder import ElementHolder def __pyaml_repr__(obj, exclude: list[str] | None = None): diff --git a/pyaml/common/holders/combinded_function_magnet_holder.py b/pyaml/common/holders/combinded_function_magnet_holder.py new file mode 100644 index 000000000..e657a38e7 --- /dev/null +++ b/pyaml/common/holders/combinded_function_magnet_holder.py @@ -0,0 +1,39 @@ +from typing import TYPE_CHECKING + +from ...magnet.cfm_magnet import CombinedFunctionMagnet + +if TYPE_CHECKING: + from .element_holder import ElementHolder + + +class CombinedFunctionMagnetHolder: + def __init__(self, peer: "ElementHolder"): + self._peer = peer + + def all(self) -> list[CombinedFunctionMagnet]: + """ + Returns all combined function magnets as a list + """ + return [value for key, value in self._peer._CFM_MAGNETS.items()] + + def get(self, name: str) -> CombinedFunctionMagnet: + """ + Returns the specified combined function magnet + + Parameters + ---------- + name : str + Name of the magnet + """ + return self._peer._get("Combined function magnet", name, self._peer._CFM_MAGNETS) + + def add(self, m: CombinedFunctionMagnet): + """ + Adds the specified combined function magnet to the holder + + Parameters + ---------- + m : Magnet + Magnet to be added + """ + self._peer._add(self._peer._CFM_MAGNETS, m) diff --git a/pyaml/common/holders/combinded_function_magnets_holder.py b/pyaml/common/holders/combinded_function_magnets_holder.py new file mode 100644 index 000000000..4015c69c5 --- /dev/null +++ b/pyaml/common/holders/combinded_function_magnets_holder.py @@ -0,0 +1,47 @@ +from typing import TYPE_CHECKING + +from ...arrays.cfm_magnet_array import CombinedFunctionMagnetArray + +if TYPE_CHECKING: + from .element_holder import ElementHolder + + +class CombinedFunctionMagnetsHolder: + def __init__(self, peer: "ElementHolder"): + self._peer = peer + + def get(self, name: str = None) -> CombinedFunctionMagnetArray: + """ + Returns the specified conbined function magnet array or all combined function magnets if no name specified + + Parameters + ---------- + name : str + Name of the combined function magnet array + """ + if name is None: + return CombinedFunctionMagnetArray("", self._peer.combined_function_magnet.all()) + else: + return self._peer._get("Combined function magnet array", name, self._peer._CFM_MAGNET_ARRAYS) + + def add(self, arrayName: str, elementNames: list[str]): + """ + Adds the specified combined function magnet array to the holder + + Parameters + ---------- + arrayName : str + Array name + elementNames : list[str] + List of magnet names + """ + self._peer._fill_array( + arrayName, + elementNames, + self._peer.combined_function_magnet.get, + CombinedFunctionMagnetArray, + self._peer._CFM_MAGNET_ARRAYS, + ) + + def __getitem__(self, key): + return self.get().__getitem__(key) diff --git a/pyaml/common/element_holder.py b/pyaml/common/holders/element_holder.py similarity index 85% rename from pyaml/common/element_holder.py rename to pyaml/common/holders/element_holder.py index 847d41672..90b5d224c 100644 --- a/pyaml/common/element_holder.py +++ b/pyaml/common/holders/element_holder.py @@ -7,37 +7,39 @@ from abc import ABCMeta, abstractmethod from typing import TYPE_CHECKING -from ..arrays.bpm_array import BPMArray -from ..arrays.cfm_magnet_array import CombinedFunctionMagnetArray -from ..arrays.element_array import ElementArray -from ..arrays.magnet_array import MagnetArray -from ..arrays.serialized_magnet_array import SerializedMagnetsArray -from ..bpm.bpm import BPM -from ..common.abstract_aggregator import ScalarAggregator -from ..common.exception import PyAMLException -from ..diagnostics.tune_monitor import BetatronTuneMonitor -from ..magnet.cfm_magnet import CombinedFunctionMagnet -from ..magnet.magnet import Magnet -from ..magnet.serialized_magnet import SerializedMagnets -from ..rf.rf_plant import RFPlant -from ..rf.rf_transmitter import RFTransmitter -from ..tuning_tools.chromaticity_monitor import ChomaticityMonitor -from .element import Element +from ...arrays.bpm_array import BPMArray +from ...arrays.cfm_magnet_array import CombinedFunctionMagnetArray +from ...arrays.element_array import ElementArray +from ...arrays.magnet_array import MagnetArray +from ...arrays.serialized_magnet_array import SerializedMagnetsArray +from ...bpm.bpm import BPM +from ...diagnostics.tune_monitor import BetatronTuneMonitor +from ...magnet.cfm_magnet import CombinedFunctionMagnet +from ...magnet.magnet import Magnet +from ...magnet.serialized_magnet import SerializedMagnets +from ...rf.rf_plant import RFPlant +from ...rf.rf_transmitter import RFTransmitter +from ...tuning_tools.chromaticity_monitor import ChomaticityMonitor +from ..abstract_aggregator import ScalarAggregator +from ..element import Element +from ..exception import PyAMLException +from .combinded_function_magnet_holder import CombinedFunctionMagnetHolder +from .combinded_function_magnets_holder import CombinedFunctionMagnetsHolder from .magnet_holder import MagnetHolder from .magnets_holder import MagnetsHolder from .serialized_magnet_holder import SerializedMagnetHolder from .serialized_magnets_holder import SerializedMagnetsHolder if TYPE_CHECKING: - from ..accelerator import Accelerator - from ..tuning_tools.bba import BBA - from ..tuning_tools.chromaticity import Chromaticity - from ..tuning_tools.chromaticity_response_matrix import ChromaticityResponseMatrix - from ..tuning_tools.dispersion import Dispersion - from ..tuning_tools.orbit import Orbit - from ..tuning_tools.orbit_response_matrix import OrbitResponseMatrix - from ..tuning_tools.tune import Tune - from ..tuning_tools.tune_response_matrix import TuneResponseMatrix + from ...accelerator import Accelerator + from ...tuning_tools.bba import BBA + from ...tuning_tools.chromaticity import Chromaticity + from ...tuning_tools.chromaticity_response_matrix import ChromaticityResponseMatrix + from ...tuning_tools.dispersion import Dispersion + from ...tuning_tools.orbit import Orbit + from ...tuning_tools.orbit_response_matrix import OrbitResponseMatrix + from ...tuning_tools.tune import Tune + from ...tuning_tools.tune_response_matrix import TuneResponseMatrix class ElementHolder(metaclass=ABCMeta): @@ -79,6 +81,8 @@ def __init__(self): self._magnets_holder = MagnetsHolder(self) self._serialized_magnet_holder = SerializedMagnetHolder(self) self._serialized_magnets_holder = SerializedMagnetsHolder(self) + self._combined_function_magnet_holder = CombinedFunctionMagnetHolder(self) + self._combined_function_magnets_holder = CombinedFunctionMagnetsHolder(self) @property def peer(self) -> "Accelerator": @@ -87,6 +91,8 @@ def peer(self) -> "Accelerator": """ return self._peer + # Sub holders ---------------------------------------------------------------- + @property def magnet(self) -> MagnetHolder: return self._magnet_holder @@ -103,6 +109,14 @@ def serialized_magnet(self) -> SerializedMagnetHolder: def serialized_magnets(self) -> SerializedMagnetsHolder: return self._serialized_magnets_holder + @property + def combined_function_magnet(self) -> CombinedFunctionMagnetHolder: + return self._combined_function_magnet_holder + + @property + def combined_function_magnets(self) -> CombinedFunctionMagnetsHolder: + return self._combined_function_magnets_holder + def post_init(self): """ Method triggered after all initialisations are done @@ -205,29 +219,6 @@ def get_elements(self, name: str) -> ElementArray: def get_all_elements(self) -> list[Element]: return [value for key, value in self._ALL.items()] - # Combined Function Magnets - - def fill_cfm_magnet_array(self, arrayName: str, elementNames: list[str]): - self._fill_array( - arrayName, - elementNames, - self.get_cfm_magnet, - CombinedFunctionMagnetArray, - self._CFM_MAGNET_ARRAYS, - ) - - def get_cfm_magnet(self, name: str) -> Magnet: - return self._get("CombinedFunctionMagnet", name, self._CFM_MAGNETS) - - def add_cfm_magnet(self, m: Magnet): - self._add(self._CFM_MAGNETS, m) - - def get_cfm_magnets(self, name: str) -> CombinedFunctionMagnetArray: - return self._get("CombinedFunctionMagnet array", name, self._CFM_MAGNET_ARRAYS) - - def get_all_cfm_magnets(self) -> list[CombinedFunctionMagnet]: - return [value for key, value in self._CFM_MAGNETS.items()] - # BPMs def fill_bpm_array(self, arrayName: str, elementNames: list[str]): diff --git a/pyaml/common/magnet_holder.py b/pyaml/common/holders/magnet_holder.py similarity index 95% rename from pyaml/common/magnet_holder.py rename to pyaml/common/holders/magnet_holder.py index 61dcec821..8e8a12b4a 100644 --- a/pyaml/common/magnet_holder.py +++ b/pyaml/common/holders/magnet_holder.py @@ -1,6 +1,6 @@ from typing import TYPE_CHECKING -from ..magnet.magnet import Magnet +from ...magnet.magnet import Magnet if TYPE_CHECKING: from .element_holder import ElementHolder diff --git a/pyaml/common/magnets_holder.py b/pyaml/common/holders/magnets_holder.py similarity index 95% rename from pyaml/common/magnets_holder.py rename to pyaml/common/holders/magnets_holder.py index aeeb01d32..afff96256 100644 --- a/pyaml/common/magnets_holder.py +++ b/pyaml/common/holders/magnets_holder.py @@ -1,6 +1,6 @@ from typing import TYPE_CHECKING -from ..arrays.magnet_array import MagnetArray +from ...arrays.magnet_array import MagnetArray if TYPE_CHECKING: from .element_holder import ElementHolder diff --git a/pyaml/common/serialized_magnet_holder.py b/pyaml/common/holders/serialized_magnet_holder.py similarity index 94% rename from pyaml/common/serialized_magnet_holder.py rename to pyaml/common/holders/serialized_magnet_holder.py index c778270e1..375f38399 100644 --- a/pyaml/common/serialized_magnet_holder.py +++ b/pyaml/common/holders/serialized_magnet_holder.py @@ -1,6 +1,6 @@ from typing import TYPE_CHECKING -from ..magnet.serialized_magnet import SerializedMagnets +from ...magnet.serialized_magnet import SerializedMagnets if TYPE_CHECKING: from .element_holder import ElementHolder diff --git a/pyaml/common/serialized_magnets_holder.py b/pyaml/common/holders/serialized_magnets_holder.py similarity index 95% rename from pyaml/common/serialized_magnets_holder.py rename to pyaml/common/holders/serialized_magnets_holder.py index 44b160021..8ed8dccc6 100644 --- a/pyaml/common/serialized_magnets_holder.py +++ b/pyaml/common/holders/serialized_magnets_holder.py @@ -1,6 +1,6 @@ from typing import TYPE_CHECKING -from ..arrays.serialized_magnet_array import SerializedMagnetsArray +from ...arrays.serialized_magnet_array import SerializedMagnetsArray if TYPE_CHECKING: from .element_holder import ElementHolder diff --git a/pyaml/control/controlsystem.py b/pyaml/control/controlsystem.py index eb7df8909..36c322f0e 100644 --- a/pyaml/control/controlsystem.py +++ b/pyaml/control/controlsystem.py @@ -6,8 +6,8 @@ from ..common.abstract import RWMapper from ..common.abstract_aggregator import ScalarAggregator from ..common.element import Element -from ..common.element_holder import ElementHolder from ..common.exception import PyAMLException +from ..common.holders.element_holder import ElementHolder from ..configuration.factory import Factory from ..configuration.unbound_element import UnboundElement from ..control.abstract_impl import ( @@ -147,7 +147,7 @@ def fill_device(self, elements: list[Element]): # Create unique refs the cfm and # each of its function for this control system ms = e.attach(self, strengths, currents) - self.add_cfm_magnet(ms[0]) + self.combined_function_magnet.add(ms[0]) for m in ms[1:]: self.magnet.add(m) diff --git a/pyaml/external/pySC_interface.py b/pyaml/external/pySC_interface.py index f39b2c5ca..fc5b3256f 100644 --- a/pyaml/external/pySC_interface.py +++ b/pyaml/external/pySC_interface.py @@ -4,7 +4,7 @@ import numpy as np if TYPE_CHECKING: - from ..common.element_holder import ElementHolder + from ..common.holders.element_holder import ElementHolder from ..common.exception import PyAMLException diff --git a/pyaml/lattice/simulator.py b/pyaml/lattice/simulator.py index d67f656ca..5d529f59b 100644 --- a/pyaml/lattice/simulator.py +++ b/pyaml/lattice/simulator.py @@ -6,8 +6,8 @@ from ..bpm.bpm import BPM from ..common.abstract_aggregator import ScalarAggregator from ..common.element import Element -from ..common.element_holder import ElementHolder from ..common.exception import PyAMLException +from ..common.holders.element_holder import ElementHolder from ..configuration import ROOT from ..diagnostics.tune_monitor import BetatronTuneMonitor from ..lattice.abstract_impl import ( @@ -149,7 +149,7 @@ def fill_device(self, elements: list[Element]): strengths = RWStrengthArray(self.get_at_elems(e), e.polynoms, e.model) if e.model.has_physics() else None # Create unique refs of each function for this simulator ms = e.attach(self, strengths, currents) - self.add_cfm_magnet(ms[0]) + self.combined_function_magnet.add(ms[0]) for m in ms[1:]: self.magnet.add(m) diff --git a/pyaml/tuning_tools/dispersion.py b/pyaml/tuning_tools/dispersion.py index d62dbefe5..e8daa116d 100644 --- a/pyaml/tuning_tools/dispersion.py +++ b/pyaml/tuning_tools/dispersion.py @@ -7,7 +7,7 @@ from ..common.constants import Action from ..common.element import ElementConfigModel -from ..common.element_holder import ElementHolder +from ..common.holders.element_holder import ElementHolder from ..external.pySC_interface import pySCInterface from .measurement_tool import MeasurementTool diff --git a/pyaml/tuning_tools/measurement_tool.py b/pyaml/tuning_tools/measurement_tool.py index c1cbeba6e..34c8417d4 100644 --- a/pyaml/tuning_tools/measurement_tool.py +++ b/pyaml/tuning_tools/measurement_tool.py @@ -11,7 +11,7 @@ from ..common.exception import PyAMLException if TYPE_CHECKING: - from ..common.element_holder import ElementHolder + from ..common.holders.element_holder import ElementHolder logger = logging.getLogger(__name__) diff --git a/pyaml/tuning_tools/orbit.py b/pyaml/tuning_tools/orbit.py index 3fc07110f..243e10692 100644 --- a/pyaml/tuning_tools/orbit.py +++ b/pyaml/tuning_tools/orbit.py @@ -11,7 +11,7 @@ from pydantic import ConfigDict if TYPE_CHECKING: - from ..common.element_holder import ElementHolder + from ..common.holders.element_holder import ElementHolder from pySC import ResponseMatrix as pySC_ResponseMatrix from pySC.apps import orbit_correction diff --git a/pyaml/tuning_tools/tuning_tool.py b/pyaml/tuning_tools/tuning_tool.py index f24f42c91..4c5e1cd5e 100644 --- a/pyaml/tuning_tools/tuning_tool.py +++ b/pyaml/tuning_tools/tuning_tool.py @@ -2,7 +2,7 @@ from typing import Self from ..common.element import Element -from ..common.element_holder import ElementHolder +from ..common.holders.element_holder import ElementHolder class TuningTool(Element): diff --git a/tests/arrays/test_arrays.py b/tests/arrays/test_arrays.py index f1466dc68..fbe8e91ec 100644 --- a/tests/arrays/test_arrays.py +++ b/tests/arrays/test_arrays.py @@ -72,8 +72,8 @@ def test_arrays(install_test_package): # Using aggregators sr.live.magnets.get("HCORR").strengths.set([0.000010, -0.000008]) - ps1 = sr.live.get_cfm_magnet("SH1A-C01").hardwares.get() - ps2 = sr.live.get_cfm_magnet("SH1A-C02").hardwares.get() + ps1 = sr.live.combined_function_magnet.get("SH1A-C01").hardwares.get() + ps2 = sr.live.combined_function_magnet.get("SH1A-C02").hardwares.get() assert np.abs(ps1[0] - 0.02956737880874648) < 1e-10 assert np.abs(ps1[1] - 0) < 1e-10 assert np.abs(ps1[2] - 0) < 1e-10 @@ -81,8 +81,8 @@ def test_arrays(install_test_package): assert np.abs(ps2[1] - 0) < 1e-10 assert np.abs(ps2[2] - 0) < 1e-10 sr.live.magnets.get("VCORR").strengths.set([0.000015, -0.000017]) - ps1 = sr.live.get_cfm_magnet("SH1A-C01").hardwares.get() - ps2 = sr.live.get_cfm_magnet("SH1A-C02").hardwares.get() + ps1 = sr.live.combined_function_magnet.get("SH1A-C01").hardwares.get() + ps2 = sr.live.combined_function_magnet.get("SH1A-C02").hardwares.get() assert np.abs(ps1[0] - 0.02956737880874648) < 1e-10 assert np.abs(ps1[1] + 0.058240333933172066) < 1e-10 assert np.abs(ps1[2] - 0.05601656539392866) < 1e-10 @@ -101,8 +101,8 @@ def test_arrays(install_test_package): ma.LAST_NB_WRITTEN = 0 # Total number of setpoints done by multi_attribute sr.live.magnets.get("HVCORR").strengths.set(0.0) assert ma.LAST_NB_WRITTEN == 6 # 6 power supply setpoints are needed - ps1 = sr.live.get_cfm_magnet("SH1A-C01").hardwares.get() - ps2 = sr.live.get_cfm_magnet("SH1A-C02").hardwares.get() + ps1 = sr.live.combined_function_magnet.get("SH1A-C01").hardwares.get() + ps2 = sr.live.combined_function_magnet.get("SH1A-C02").hardwares.get() assert np.abs(ps1[0]) < 1e-10 assert np.abs(ps1[1]) < 1e-10 assert np.abs(ps1[2]) < 1e-10 @@ -116,8 +116,8 @@ def test_arrays(install_test_package): mags.append(m) array = MagnetArray("HVCOOR_noagg", mags, use_aggregator=False) array.strengths.set([0.000010, -0.000008, 0.000015, -0.000017]) - ps1 = sr.live.get_cfm_magnet("SH1A-C01").hardwares.get() - ps2 = sr.live.get_cfm_magnet("SH1A-C02").hardwares.get() + ps1 = sr.live.combined_function_magnet.get("SH1A-C01").hardwares.get() + ps2 = sr.live.combined_function_magnet.get("SH1A-C02").hardwares.get() assert np.abs(ps1[0] - 0.02956737880874648) < 1e-10 assert np.abs(ps1[1] + 0.058240333933172066) < 1e-10 assert np.abs(ps1[2] - 0.05601656539392866) < 1e-10 @@ -178,7 +178,7 @@ def test_arrays(install_test_package): allBpms = BPMArray("AllBPMs", sr.design.get_all_bpms()) assert len(allBpms) == 2 - cfm = sr.design.get_cfm_magnets("CFM") + cfm = sr.design.combined_function_magnets.get("CFM") strHVSQ = cfm.strengths.get() assert np.abs(strHVSQ[0] - 0.000010) < 1e-10 # H assert np.abs(strHVSQ[1] - 0.000015) < 1e-10 # V @@ -211,7 +211,7 @@ def test_arrays(install_test_package): sr: Accelerator = Accelerator.load("tests/config/EBSOrbit.yaml", include_locations=False) ae = ElementArray("All", sr.design.get_all_elements()) - acfm = ElementArray("AllCFM", sr.design.get_all_cfm_magnets(), use_aggregator=False) + acfm = ElementArray("AllCFM", sr.design.combined_function_magnet.all(), use_aggregator=False) bpmC5 = ae["BPM*"][10:20] # All BPM C5 assert isinstance(bpmC5, BPMArray) and len(bpmC5) == 10 @@ -237,7 +237,7 @@ def test_arrays(install_test_package): emptyCFM = CombinedFunctionMagnet(name="emptyCFM", elements=[]) emptyCFM.fill_array(sr.design) # Attach the array - v = sr.design.get_cfm_magnets("emptyCFM").strengths.get() # Ensure good attach + v = sr.design.combined_function_magnets.get("emptyCFM").strengths.get() # Ensure good attach assert np.shape(v) == (0,) diff --git a/tests/integration/test_dt4acc_twin_smoke.py b/tests/integration/test_dt4acc_twin_smoke.py index 4d0b63da0..af6426653 100644 --- a/tests/integration/test_dt4acc_twin_smoke.py +++ b/tests/integration/test_dt4acc_twin_smoke.py @@ -101,7 +101,7 @@ def test_dt4acc_twin_accelerator_instantiates_and_reads_live_values(root_folder: def test_dt4acc_twin_reads_all_declared_magnetic_strengths(root_folder: Path, config_files: dict[str, str]): accelerator = _build_accelerator(root_folder, config_files) magnets = [magnet for magnet in accelerator.live.magnets.get() if magnet.get_model_name() == magnet.get_name()] - combined_function_magnets = accelerator.live.get_all_cfm_magnets() + combined_function_magnets = accelerator.live.combined_function_magnet.all() assert magnets or combined_function_magnets diff --git a/tests/magnet/test_ranges_cfm_deviceaccess.py b/tests/magnet/test_ranges_cfm_deviceaccess.py index a80f47b43..6316cc940 100644 --- a/tests/magnet/test_ranges_cfm_deviceaccess.py +++ b/tests/magnet/test_ranges_cfm_deviceaccess.py @@ -38,7 +38,7 @@ def test_cfm_ranges_from_yaml_are_propagated_and_enforced(magnet_file, install_t sr.design.get_lattice().disable_6d() # Parent CFM magnet (the one defined in SH1AC01-range.yaml) - m = sr.live.get_cfm_magnet("SH1A-C01") + m = sr.live.combined_function_magnet.get("SH1A-C01") dev_names = m.model.get_device_names() assert len(dev_names) == 3