From 500c45a5193dca2446bc44dd5d4e49c7abfacaa9 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Tue, 7 Jan 2025 12:24:59 -0800 Subject: [PATCH] Python: Mixin Elements Submodule (#786) 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. --- src/python/elements.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/python/elements.cpp b/src/python/elements.cpp index b9c9429d6..7d1488a55 100644 --- a/src/python/elements.cpp +++ b/src/python/elements.cpp @@ -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_(me, "Named") + py::module_ const mx = me.def_submodule( + "mixin", + "Mixin classes for accelerator lattice elements in ImpactX" + ); + + py::class_(mx, "Named") .def_property("name", [](elements::Named & nm) { return nm.name(); }, [](elements::Named & nm, std::string new_name) { nm.set_name(new_name); }, @@ -151,7 +156,7 @@ void init_elements(py::module& m) .def_property_readonly("has_name", &elements::Named::has_name) ; - py::class_(me, "Thick") + py::class_(mx, "Thick") .def(py::init< amrex::ParticleReal, amrex::ParticleReal @@ -172,7 +177,7 @@ void init_elements(py::module& m) ) ; - py::class_(me, "Thin") + py::class_(mx, "Thin") .def(py::init<>(), "Mixin class for lattice elements with zero length." ) @@ -186,7 +191,7 @@ void init_elements(py::module& m) ) ; - py::class_(me, "Alignment") + py::class_(mx, "Alignment") .def(py::init<>(), "Mixin class for lattice elements with horizontal/vertical alignment errors." )