Skip to content

Commit

Permalink
Python: Mixin Elements Submodule
Browse files Browse the repository at this point in the history
Move the mixin elements (non-physical, mostly helper methods
and attributes) to `impactx.elements.mixin` to avoid that they
are listed by default and, e.g., picked up in the GUI as physical
elements.
  • Loading branch information
ax3l committed Jan 7, 2025
1 parent 426a2d5 commit 3f68b42
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,19 @@ namespace

void init_elements(py::module& m)
{
py::module_ const me = m.def_submodule(
py::module_ me = m.def_submodule(
"elements",
"Accelerator lattice elements in ImpactX"
);

// mixin classes

py::class_<elements::Named>(me, "Named")
py::module_ const mx = me.def_submodule(
"mixin",
"Mixin classes for accelerator lattice elements in ImpactX"
);

py::class_<elements::Named>(mx, "Named")
.def_property("name",
[](elements::Named & nm) { return nm.name(); },
[](elements::Named & nm, std::string new_name) { nm.set_name(new_name); },
Expand All @@ -151,7 +156,7 @@ void init_elements(py::module& m)
.def_property_readonly("has_name", &elements::Named::has_name)
;

py::class_<elements::Thick>(me, "Thick")
py::class_<elements::Thick>(mx, "Thick")
.def(py::init<
amrex::ParticleReal,
amrex::ParticleReal
Expand All @@ -172,7 +177,7 @@ void init_elements(py::module& m)
)
;

py::class_<elements::Thin>(me, "Thin")
py::class_<elements::Thin>(mx, "Thin")
.def(py::init<>(),
"Mixin class for lattice elements with zero length."
)
Expand All @@ -186,7 +191,7 @@ void init_elements(py::module& m)
)
;

py::class_<elements::Alignment>(me, "Alignment")
py::class_<elements::Alignment>(mx, "Alignment")
.def(py::init<>(),
"Mixin class for lattice elements with horizontal/vertical alignment errors."
)
Expand Down

0 comments on commit 3f68b42

Please sign in to comment.