accelmo.machine.accelerators.selection¶
CLI spelling and helpers for accelerator errors / misalignments selections.
Every Accelerator takes errors and
misalignments as mappings from magnet family (keys of FAMILIES) to the
attributes to free. This module holds the one CLI spelling of those mappings
(--errors quad:k1 bend:k0, --misalign quad:tilt,dy) and the helpers that
combine and describe them.
- accelmo.machine.accelerators.selection.NONE_TOKEN = 'none'¶
Token that selects nothing, so an empty selection can be spelled on the CLI.
- accelmo.machine.accelerators.selection.parse_selection(tokens)[source]¶
Parse
["quad:k1,tilt", "bend:k0"]into{"quad": {"k1", "tilt"}, ...}.Repeated families are merged.
none(alone) yields an empty selection.- Return type:
dict[str,set[str]]- Parameters:
tokens (Iterable[str] | None)
- accelmo.machine.accelerators.selection.merge_selections(*selections)[source]¶
Union several selections, dropping families left empty.
- Return type:
dict[str,set[str]]- Parameters:
selections (Mapping[str, Iterable[str]] | None)
- accelmo.machine.accelerators.selection.selects(selection, family, attr)[source]¶
Whether selection frees attr on family.
- Return type:
bool- Parameters:
selection (Mapping[str, Iterable[str]] | None)
family (str)
attr (str)
- accelmo.machine.accelerators.selection.describe_selections(errors, misalignments=None)[source]¶
Human-readable labels such as
["quad k1", "bend k0", "quad dy"].- Return type:
list[str]- Parameters:
errors (Mapping[str, Iterable[str]] | None)
misalignments (Mapping[str, Iterable[str]] | None)
- accelmo.machine.accelerators.selection.add_selection_args(parser, *, accelerator=None, errors_default=(), misalign_default=())[source]¶
Add
--errors/--misalignto parser (raw tokens; seeparse_selection()).Pass accelerator to list its families and valid attributes in the help text.
- Return type:
None- Parameters:
parser (Any)
accelerator (type[Accelerator] | None)
errors_default (Sequence[str])
misalign_default (Sequence[str])