feat: add generic ElementHolder collection access - #376
Conversation
gupichon
commented
Sep 7, 2026
- Return an element or None for exact-name lookups
- Support typed wildcard selections, slices and insertion-order indexing
- Add get() and [:] access to all registered elements
- Reuse array type inference for selections
- Document the API with NumPy docstrings and readable test examples
- Return an element or None for exact-name lookups - Support typed wildcard selections, slices and insertion-order indexing - Add get() and [:] access to all registered elements - Reuse array type inference for selections - Document the API with NumPy docstrings and readable test examples
|
I tried to look a bit a the code a did some tests. Here is what I found:
Not linked to this MR, but it makes things difficult.
The same is true for other get_XXXs methods.
So I don't know how to access an user defined array Probably some of the tests should use mixed type arrays to catch this type of bugs. |
|
Point 1 2 3 6 are normal, it is a work in progress not already done as mentioned in the initial issue. |
|
I'm not sure why the documentation pipeline is failing. I suspect it's related to the release build on Read the Docs. |
Yes, I will open a separate issue for the element array type inference. |
- Return an element or None for exact-name lookups - Support typed wildcard selections, slices and insertion-order indexing - Add get() and [:] access to all registered elements - Reuse array type inference for selections - Document the API with NumPy docstrings and readable test examples
…older-collection-access' into 366-feature-add-generic-elementholder-collection-access
Regarding point 2: should we raise an error if an unknown value is passed for direct access? |
Because of the quotes here, you're looking for an element named ":", which results in an empty, generic array. The correct syntax is type(sr.design.magnets[:]), but as @JeanLucPons mentioned, this doesn't work yet. |
I would say it's better to raise an error. |
…ic-elementholder-collection-access
Ok, I would like to do this in a future issue to also update ElementArray accordingly. |
…ic-elementholder-collection-access
…ic-elementholder-collection-access