Skip to content

Improve MagnetArray class and implement generic ElementArray class #41

@GamelinAl

Description

@GamelinAl

The MagnetArray class needs to improved, it probably should inherit from a more generic class ElementArray which handles all kind of pyAML elements (BPMs, RF cavities, ...).

Most the features we need are detailed in section 2.3 of the User Interface Specification but I recall a few here:

I propose the following behavior for arrays (which I think match the User Interface Specification document):

  • The array is composed of different types of pyAML elements, then it's a ElementArray and there is no access at the array level to the individual element specific properties (magnet strength, BPM reading, ...), only to the common properties (name, hardware_name, ...).
  • The array is composed of the same pyAML type, then there is an array level access to the individual element specific properties.
  • Specific case of CombinedFunctionMagnet. If an array is composed of Sextupole and CombinedFunctionMagnet with a sextupolar component, then the sextupolar strength is accessible at the array level.
  1. Subset Handling:
    • Subsets (e.g., qcorr[0:5]) should return a MagnetArray, not a list.
      • Bug: qcorr[0:5].strengthsAttributeError: 'list' object has no attribute 'strengths'.
  2. Support heterogeneous MagnetArray (different magnet types).
  3. Implement element access by:
    • hardware_name or list of hardware_name (with wildcard type regex possible)
    • name or list of name (with wildcard type regex possible)
    • Element type filtering
    • a boolean array of len(ElementArray)
  4. Implement element wise boolean operators
    • For example the & operator should return the intersection of two arrays:
    • bpm_cell8 = sr.cell8 & sr.bpm # return an ElementArray with the common element between the two arrays sr.cell8 and sr.bpm.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions