Skip to content

Commit

Permalink
Fix: None -> Empty Element/Dist
Browse files Browse the repository at this point in the history
`None` is a keyword in Python and thus should not be used
as a class type for our empty element or our empty distribution.
This fixes it by renaming both to `Empty`.
  • Loading branch information
ax3l committed Apr 29, 2024
1 parent de80f7a commit a6915b5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/source/usage/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ This module provides particle beam distributions that can be used to initialize
A K-V distribution transversely + a uniform distribution
in t + a Gaussian distribution in pt.

.. py:class:: impactx.distribution.None
.. py:class:: impactx.distribution.Empty
This distribution sets all values to zero.

Expand Down Expand Up @@ -564,7 +564,7 @@ This module provides elements for the accelerator lattice.
:param dy: vertical translation error in m
:param rotation: rotation error in the transverse plane [degrees]

.. py::class:: impactx.elements.None
.. py::class:: impactx.elements.Empty
This element does nothing.

Expand Down
4 changes: 2 additions & 2 deletions src/particles/distribution/All.H
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "Kurth4D.H"
#include "Kurth6D.H"
#include "KVdist.H"
#include "None.H"
#include "Empty.H"
#include "Semigaussian.H"
#include "Thermal.H"
#include "Triangle.H"
Expand All @@ -26,7 +26,7 @@
namespace impactx::distribution
{
using KnownDistributions = std::variant<
None, /* must be first, so KnownDistributions creates a default constructor */
Empty, /* must be first, so KnownDistributions creates a default constructor */
Gaussian,
Kurth4D,
Kurth6D,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* Authors: Chad Mitchell, Axel Huebl
* License: BSD-3-Clause-LBNL
*/
#ifndef IMPACTX_DISTRIBUTION_NONE
#define IMPACTX_DISTRIBUTION_NONE
#ifndef IMPACTX_DISTRIBUTION_EMPTY_H
#define IMPACTX_DISTRIBUTION_EMPTY_H

#include "particles/ReferenceParticle.H"

Expand All @@ -18,11 +18,11 @@

namespace impactx::distribution
{
struct None
struct Empty
{
/** This distribution sets all values to zero.
*/
None()
Empty()
{
}

Expand Down Expand Up @@ -81,4 +81,4 @@ namespace impactx::distribution

} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_NONE
#endif // IMPACTX_DISTRIBUTION_EMPTY_H
4 changes: 2 additions & 2 deletions src/particles/elements/All.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "ExactSbend.H"
#include "Kicker.H"
#include "Multipole.H"
#include "None.H"
#include "Empty.H"
#include "NonlinearLens.H"
#include "Programmable.H"
#include "Quad.H"
Expand All @@ -44,7 +44,7 @@
namespace impactx
{
using KnownElements = std::variant<
None, /* must be first, so KnownElements creates a default constructor */
Empty, /* must be first, so KnownElements creates a default constructor */
Aperture,
Buncher,
CFbend,
Expand Down
10 changes: 5 additions & 5 deletions src/particles/elements/None.H → src/particles/elements/Empty.H
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* Authors: Axel Huebl
* License: BSD-3-Clause-LBNL
*/
#ifndef IMPACTX_NONE_H
#define IMPACTX_NONE_H
#ifndef IMPACTX_ELEMENT_EMPTY_H
#define IMPACTX_ELEMENT_EMPTY_H

#include "particles/ImpactXParticleContainer.H"
#include "mixin/thin.H"
Expand All @@ -20,7 +20,7 @@

namespace impactx
{
struct None
struct Empty
: public elements::Thin,
public elements::NoFinalize
{
Expand All @@ -29,7 +29,7 @@ namespace impactx

/** This element does nothing.
*/
None ()
Empty ()
{
}

Expand Down Expand Up @@ -81,4 +81,4 @@ namespace impactx

} // namespace impactx

#endif // IMPACTX_NONE_H
#endif // IMPACTX_ELEMENT_EMPTY_H
2 changes: 1 addition & 1 deletion src/python/distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void init_distribution(py::module& m)
"in t + a Gaussian distribution in pt"
);

py::class_<distribution::None>(md, "None")
py::class_<distribution::Empty>(md, "Empty")
.def(py::init<>(),
"Sets all values to zero."
);
Expand Down
6 changes: 3 additions & 3 deletions src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,11 +674,11 @@ void init_elements(py::module& m)
;
register_beamoptics_push(py_Multipole);

py::class_<None, elements::Thin> py_None(me, "None");
py::class_<Empty, elements::Thin> py_None(me, "Empty");
py_None
.def("__repr__",
[](None const & /* none */) {
return std::string("<impactx.elements.None>");
[](Empty const & /* none */) {
return std::string("<impactx.elements.Empty>");
}
)
.def(py::init<>(),
Expand Down

0 comments on commit a6915b5

Please sign in to comment.