Skip to content

Commit df29f7a

Browse files
committed
Native_Enum
pybind11-stubgen needs location hint for default arguments that are enums, even if defined early enough.
1 parent 37cbe14 commit df29f7a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.github/update_stub.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ set -eu -o pipefail
1313
# we are in the source directory, .github/
1414
this_dir=$(cd $(dirname $0) && pwd)
1515

16-
pybind11-stubgen --exit-code -o ${this_dir}/../src/ amrex.space1d
17-
pybind11-stubgen --exit-code -o ${this_dir}/../src/ amrex.space2d
18-
pybind11-stubgen --exit-code -o ${this_dir}/../src/ amrex.space3d
16+
pybind11-stubgen --exit-code --enum-class-locations="GrowthStrategy:amrex.space3d" -o ${this_dir}/../src/ amrex.space1d
17+
pybind11-stubgen --exit-code --enum-class-locations="GrowthStrategy:amrex.space3d" -o ${this_dir}/../src/ amrex.space2d
18+
pybind11-stubgen --exit-code --enum-class-locations="GrowthStrategy:amrex.space3d" -o ${this_dir}/../src/ amrex.space3d

src/Base/PODVector.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,14 @@ void make_PODVector(py::module &m, std::string typestr)
150150
#endif
151151
}
152152

153-
void init_PODVector(py::module& m) {
154-
py::enum_<GrowthStrategy>(m, "GrowthStrategy")
153+
void init_PODVector(py::module& m)
154+
{
155+
py::native_enum<GrowthStrategy>(m, "GrowthStrategy", "enum.IntEnum")
155156
.value("Poisson", GrowthStrategy::Poisson)
156157
.value("Exact", GrowthStrategy::Exact)
157158
.value("Geometric", GrowthStrategy::Geometric)
159+
.export_values()
160+
.finalize()
158161
;
159162

160163
make_PODVector<ParticleReal> (m, "real");

0 commit comments

Comments
 (0)