Skip to content

Add a public tuning and measurement tool holder - #432

Merged
gupichon merged 1 commit into
199-elementholder-api-refurbishmentfrom
375-feature-add-a-public-tuning-and-measurement-tool-holder
Sep 17, 2026
Merged

gupichon merged 1 commit into
199-elementholder-api-refurbishmentfrom
375-feature-add-a-public-tuning-and-measurement-tool-holder

Conversation

@gupichon

Copy link
Copy Markdown
Member

Description

Adds a public tool property (ToolHolder) on ElementHolder, mirroring RFHolder. It exposes tool.get(name)/tool.get() for name-based/untyped access to all configured tuning and measurement tools, plus typed convenience properties (tune, trm, orbit, orm, chromaticity, crm, dispersion) that resolve their DEFAULT_... name and validate the resolved object's type, raising a clear PyAMLException when it's missing or of the wrong type. Something the previous flat _TOOLS dict never checked.

Related Issue

Features/issues described there are:

  • new feature: ToolHolder was added (pyaml/common/holders/tool_holder.py) and wired up as ElementHolder.tool, because tools were only reachable through ad-hoc get_xxx_tuning(name) methods and 7 hardcoded default-name properties directly on ElementHolder, with no type validation.
  • new feature: tool.get(name=None) returns a named tool or, when no name is given, all configured tools as an ElementArray, because the epic (ElementHolder API refurbishment #199) wants a consistent get()-based API across all sub-holders.

Changes to existing functionality

  • ElementHolder.tune/.trm/.orbit/.orm/.chromaticity/.crm/.dispersion: reimplemented as aliases delegating to self.tool.<name>, because the epic wants these hardcoded-default properties centralized under tool while keeping the existing public API unchanged. The underlying get_xxx_tuning(name) methods (named lookup) are untouched. Behavior is unchanged for correctly-typed configurations; a configuration where a DEFAULT_... name pointed to the wrong tool type would previously return that (wrong) object silently and now raises PyAMLException instead.

Testing

The following tests (compatible with pytest) were added to tests/tuning_tools/test_tool_accessors.py:

  • test_tool_get_returns_named_tool
  • test_tool_get_with_no_name_returns_all_configured_tools
  • test_tool_typed_properties_alias_existing_defaults
  • test_tool_raises_when_default_missing
  • test_tool_raises_when_default_wrong_type

Verify that your checklist complies with the project

  • New and existing unit tests pass locally (320 passed, 6 skipped, 1 pre-existing unrelated failure: tests/tuning_tools/test_tuning_orm.py::test_tuning_orm, a Windows-only NamedTemporaryFile double-open issue)
  • Tests were added to prove that all features/changes are effective
  • The code is commented where appropriate (NumPy-style docstrings, including the ToolHolder class docstring so tool and its properties are discoverable via help())
  • Any existing features are not broken

@gupichon gupichon self-assigned this Sep 17, 2026
@gupichon
gupichon merged commit 6e3aa86 into 199-elementholder-api-refurbishment Sep 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants