Skip to content

Adding Aperture VertexParameters - #101

Open
danielkallendorf wants to merge 6 commits into
pals-project:mainfrom
danielkallendorf:main
Open

danielkallendorf wants to merge 6 commits into
pals-project:mainfrom
danielkallendorf:main

Conversation

@danielkallendorf

Copy link
Copy Markdown

Hey,

I tried adding the generalized vertex description to 'ApertureP', but for some reasons this breaks the loading of an element:

import pals
from pals.parameters.ApertureParameters import Vertex, Vertices
lattice = pals.Lattice(
    name="test_lat",
    branches=[
        pals.BeamLine(
            name="test_bl",
            line=[pals.Sextupole(
                name="sextupole1",
                length=0.2,
                MagneticMultipoleP=pals.MagneticMultipoleParameters(
                    Bn2=1.0),
                ApertureP=pals.ApertureParameters(shape="VERTICES", vertices=Vertices(
                    list=[Vertex(point=(-0.1, 0), radius=0.1), Vertex(point=(0.1, 0))]))
            )
            ])
    ])
lattice.to_file("xyz.pals.yaml")
loaded_lattice = pals.Lattice.from_file('xyz.pals.yaml')
loaded_lattice.branches[0].line
gives `[PlaceholderName('sextupole1', unresolved)]`

Can you give me a hint what the issue might be?

@danielkallendorf

Copy link
Copy Markdown
Author

It seems like list/tuple conversation lowers the matching score in pydantic, such that Placeholder became preferred over the actual element. This is fixed by forcing all unions between elements and Placeholder to follow left_to_right priority.

@danielkallendorf
danielkallendorf marked this pull request as ready for review November 23, 2026 14:13
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.

1 participant