lattice_elements_linker#

class LinkerConfigModel[source]#

Bases: BaseModel

Base configuration model for linker definitions.

This class defines the configuration structure used to instantiate a specific linking strategy. Each concrete implementation of a LatticeElementsLinker may define its own subclass extending this model to include additional configuration parameters.

model_config#

Pydantic configuration allowing arbitrary field types and forbidding unexpected extra keys.

Type:

ConfigDict

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

class LatticeElementsLinker(linker_config_model)[source]#

Bases: object

Abstract base class defining the interface for PyAT–PyAML element linking.

Implementations of this class define how PyAML elements are matched to PyAT elements based on a given linking strategy (e.g., by family name, by index, or by a custom attribute).

Parameters:

linker_config_model (LinkerConfigModel) – The configuration model for the linking strategy.

lattice#

Reference to the PyAT lattice handled by this linker.

Type:

at.Lattice

get_at_element(element_id)[source]#

Return a single PyAT element matching the given identifier.

Parameters:

element_id (LinkerIdentifier) – Identifier describing the PyAT element to retrieve.

Returns:

at.Element – The PyAT element matching the identifier.

Raises:

PyAMLException – If no element matches the identifier.

get_at_elements(element_id)[source]#

Return a list of PyAT elements matching the given identifiers.

This method should resolve one or multiple PyAML identifiers into their corresponding PyAT elements according to the specific linking strategy implemented.

Parameters:

element_id (LinkerIdentifier or list of LinkerIdentifier) – One or several identifiers describing which PyAT elements to retrieve.

Returns:

list of at.Element – The list of matching PyAT elements found in the lattice.

Raises:

PyAMLException – If no element matches the given identifier(s).

abstractmethod get_element_identifier(element)[source]#

Get the identifier for linking an element.

Parameters:

element (Element) – The element to get the identifier for

Returns:

LinkerIdentifier – The identifier for the element

set_lattice(lattice)[source]#

Set the lattice for element linking.

Parameters:

lattice (Lattice) – The lattice to link elements with

class LinkerIdentifier[source]#

Bases: object

Abstract base class for identifiers used to match PyAML and PyAT elements.

The identifier acts as an intermediate representation between the PyAML configuration and the PyAT lattice. Its exact structure depends on the linking strategy (e.g., family name, element index, or user-defined tag).

Subclasses should define the fields and logic necessary to represent a unique reference to one or more PyAT elements.