Skip to content

Commit b5d7ced

Browse files
author
Martin D. Weinberg
committed
Expose the field basis label list for pybind11; this adds previously missing functionality
1 parent 1e8d981 commit b5d7ced

3 files changed

Lines changed: 31 additions & 10 deletions

File tree

expui/BasisFactory.H

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ namespace BasisClasses
259259
if (Naccel > 0) pseudo = currentAccel(time);
260260
}
261261

262+
//! Get the field label vector
263+
std::vector<std::string> getFieldLabels(void)
264+
{ return getFieldLabels(coordinates); }
265+
262266
};
263267

264268
using BasisPtr = std::shared_ptr<Basis>;

expui/FieldBasis.H

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,13 @@ namespace BasisClasses
9898
virtual std::vector<double>
9999
crt_eval(double x, double y, double z);
100100

101+
//! Get the field labels
102+
std::vector<std::string> getFieldLabels(const Coord ctype)
103+
{ return fieldLabels; }
104+
101105
public:
102106

103-
//! Constructor from YAML node
107+
//! Constructor from YAML node
104108
FieldBasis(const YAML::Node& conf,
105109
const std::string& name="FieldBasis") : Basis(conf, name)
106110
{ configure(); }
@@ -158,10 +162,6 @@ namespace BasisClasses
158162
{
159163
}
160164

161-
//! Get the field labels
162-
std::vector<std::string> getFieldLabels(const Coord ctype)
163-
{ return fieldLabels; }
164-
165165
//! Return current maximum harmonic order in expansion
166166
int getLmax() { return lmax; }
167167

pyEXP/BasisWrappers.cc

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,25 @@ void BasisFactoryClasses(py::module &m)
928928
Returns
929929
-------
930930
None
931-
)");
931+
)")
932+
.def("getFieldLabels",
933+
[](BasisClasses::Basis& A)
934+
{
935+
return A.getFieldLabels();
936+
},
937+
R"(
938+
Provide the field labels for the basis functions
932939
940+
Parameters
941+
----------
942+
None
943+
944+
Returns
945+
-------
946+
list: str
947+
list of basis function labels
948+
)"
949+
);
933950

934951
py::class_<BasisClasses::BiorthBasis, std::shared_ptr<BasisClasses::BiorthBasis>, PyBiorthBasis, BasisClasses::Basis>
935952
(m, "BiorthBasis")
@@ -2044,11 +2061,11 @@ void BasisFactoryClasses(py::module &m)
20442061
// orthoCheck is not in the base class and needs to have
20452062
// different parameters depending on the basis type. Here the
20462063
// user can and will often need to specify a quadrature value.
2047-
.def("orthoCheck", [](BasisClasses::FieldBasis& A)
2064+
.def("orthoCheck", [](BasisClasses::FieldBasis& A)
20482065
{
20492066
return A.orthoCheck();
20502067
},
2051-
R"(
2068+
R"(
20522069
Check orthgonality of basis functions by quadrature
20532070
20542071
Inner-product matrix of orthogonal functions
@@ -2062,10 +2079,10 @@ void BasisFactoryClasses(py::module &m)
20622079
numpy.ndarray
20632080
orthogonality matrix
20642081
)"
2065-
);
2082+
);
20662083

20672084
py::class_<BasisClasses::VelocityBasis, std::shared_ptr<BasisClasses::VelocityBasis>, BasisClasses::FieldBasis>(m, "VelocityBasis")
2068-
.def(py::init<const std::string&>(),
2085+
.def(py::init<const std::string&>(),
20692086
R"(
20702087
Create a orthogonal velocity-field basis
20712088

0 commit comments

Comments
 (0)