Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-14828: Update pybind11 wrappers for 2.2 #22

Merged
merged 1 commit into from
Jul 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions examples/timeModels.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,9 @@ void buildModelsD(
}
}

PYBIND11_PLUGIN(_timeModels) {
py::module mod("_timeModels", "");

PYBIND11_MODULE(_timeModels, mod) {
mod.def("buildModelsF", buildModelsF);
mod.def("buildModelsD", buildModelsD);

return mod.ptr();
}

}} // lsst::shapelet
6 changes: 1 addition & 5 deletions python/lsst/shapelet/basisEvaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ using namespace pybind11::literals;
namespace lsst {
namespace shapelet {

PYBIND11_PLUGIN(basisEvaluator) {
PYBIND11_MODULE(basisEvaluator, mod) {
py::module::import("lsst.afw.geom");

py::module mod("basisEvaluator");

py::class_<BasisEvaluator, std::shared_ptr<BasisEvaluator>> clsBasisEvaluator(mod, "BasisEvaluator");

/* Constructors */
Expand Down Expand Up @@ -81,8 +79,6 @@ PYBIND11_PLUGIN(basisEvaluator) {
"array"_a, "extent"_a, "dx"_a, "dy"_a);
clsBasisEvaluator.def("fillIntegration", &BasisEvaluator::fillIntegration, "array"_a, "xMoment"_a = 0,
"yMoment"_a = 0);

return mod.ptr();
}

} // shapelet
Expand Down
12 changes: 4 additions & 8 deletions python/lsst/shapelet/constants/constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,17 @@ using namespace pybind11::literals;
namespace lsst {
namespace shapelet {

PYBIND11_PLUGIN(constants) {
py::module mod("constants");

PYBIND11_MODULE(constants, mod) {
py::enum_<BasisTypeEnum>(mod, "BasisTypeEnum")
.value("HERMITE", BasisTypeEnum::HERMITE)
.value("LAGUERRE", BasisTypeEnum::LAGUERRE)
.export_values();
.value("HERMITE", BasisTypeEnum::HERMITE)
.value("LAGUERRE", BasisTypeEnum::LAGUERRE)
.export_values();

mod.def("computeOffset", computeOffset);
mod.def("computeSize", computeSize);
mod.def("computeOrder", computeOrder);
mod.def("intSqrt", intSqrt);
mod.def("rationalSqrt", rationalSqrt);

return mod.ptr();
}

} // shapelet
Expand Down
7 changes: 2 additions & 5 deletions python/lsst/shapelet/functorKeys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ using namespace pybind11::literals;
namespace lsst {
namespace shapelet {

PYBIND11_PLUGIN(functorKeys) {
PYBIND11_MODULE(functorKeys, mod) {
py::module::import("lsst.afw.table");
py::module mod("functorKeys");

py::class_<ShapeletFunctionKey, std::shared_ptr<ShapeletFunctionKey>> clsShapeletFunctionKey(
mod, "ShapeletFunctionKey");
mod, "ShapeletFunctionKey");

clsShapeletFunctionKey.def(py::init<>());
clsShapeletFunctionKey.def(
Expand Down Expand Up @@ -81,8 +80,6 @@ PYBIND11_PLUGIN(functorKeys) {
clsMultiShapeletFunctionKey.def("get", &MultiShapeletFunctionKey::get);
clsMultiShapeletFunctionKey.def("set", &MultiShapeletFunctionKey::set);
clsMultiShapeletFunctionKey.def("isValid", &MultiShapeletFunctionKey::isValid);

return mod.ptr();
}

} // shapelet
Expand Down
8 changes: 2 additions & 6 deletions python/lsst/shapelet/gaussHermiteConvolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,16 @@ using namespace pybind11::literals;
namespace lsst {
namespace shapelet {

PYBIND11_PLUGIN(gaussHermiteConvolution) {
py::module mod("gaussHermiteConvolution");

PYBIND11_MODULE(gaussHermiteConvolution, mod) {
py::class_<GaussHermiteConvolution, std::shared_ptr<GaussHermiteConvolution>> clsGaussHermiteConvolution(
mod, "GaussHermiteConvolution");
mod, "GaussHermiteConvolution");

clsGaussHermiteConvolution.def(py::init<int, ShapeletFunction const &>(), "colOrder"_a, "psf"_a);

clsGaussHermiteConvolution.def("computeRowOrder", &GaussHermiteConvolution::computeRowOrder);
clsGaussHermiteConvolution.def("evaluate", &GaussHermiteConvolution::evaluate);
clsGaussHermiteConvolution.def("getColOrder", &GaussHermiteConvolution::getColOrder);
clsGaussHermiteConvolution.def("getRowOrder", &GaussHermiteConvolution::getRowOrder);

return mod.ptr();
}

} // shapelet
Expand Down
8 changes: 2 additions & 6 deletions python/lsst/shapelet/gaussHermiteProjection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ using namespace pybind11::literals;
namespace lsst {
namespace shapelet {

PYBIND11_PLUGIN(gaussHermiteProjection) {
PYBIND11_MODULE(gaussHermiteProjection, mod) {
py::module::import("lsst.afw.geom");
py::module mod("gaussHermiteProjection");

py::class_<GaussHermiteProjection, std::shared_ptr<GaussHermiteProjection>> clsGaussHermiteProjection(
py::class_<GaussHermiteProjection, std::shared_ptr<GaussHermiteProjection>> clsGaussHermiteProjection(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

mod, "GaussHermiteProjection");

clsGaussHermiteProjection.def(py::init<int>(), "maxOrder"_a);
Expand All @@ -56,8 +54,6 @@ PYBIND11_PLUGIN(gaussHermiteProjection) {
GaussHermiteProjection::compute);

clsGaussHermiteProjection.def("getMaxOrder", &GaussHermiteProjection::getMaxOrder);

return mod.ptr();
}

} // shapelet
Expand Down
8 changes: 2 additions & 6 deletions python/lsst/shapelet/hermiteTransformMatrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ using namespace pybind11::literals;
namespace lsst {
namespace shapelet {

PYBIND11_PLUGIN(hermiteTransformMatrix) {
PYBIND11_MODULE(hermiteTransformMatrix, mod) {
py::module::import("lsst.afw.geom");

py::module mod("hermiteTransformMatrix");

py::class_<HermiteTransformMatrix, std::shared_ptr<HermiteTransformMatrix>> clsHermiteTransformMatrix(
mod, "HermiteTransformMatrix");
mod, "HermiteTransformMatrix");

clsHermiteTransformMatrix.def(py::init<int>(), "order"_a);

Expand All @@ -63,8 +61,6 @@ PYBIND11_PLUGIN(hermiteTransformMatrix) {
clsHermiteTransformMatrix.def("getInverseCoefficientMatrix",
&HermiteTransformMatrix::getInverseCoefficientMatrix);
clsHermiteTransformMatrix.def("getOrder", &HermiteTransformMatrix::getOrder);

return mod.ptr();
}

} // shapelet
Expand Down
8 changes: 2 additions & 6 deletions python/lsst/shapelet/matrixBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,10 @@ void declareMatrixBuilderTemplates(py::module &mod, std::string const &suffix) {

} // <anonymous>

PYBIND11_PLUGIN(matrixBuilder) {
PYBIND11_MODULE(matrixBuilder, mod) {
py::module::import("lsst.afw.geom");
py::module mod("matrixBuilder");

declareMatrixBuilderTemplates<float>(mod, "F");
declareMatrixBuilderTemplates<float>(mod, "F");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

declareMatrixBuilderTemplates<double>(mod, "D");

return mod.ptr();
}

} // shapelet
Expand Down
8 changes: 2 additions & 6 deletions python/lsst/shapelet/multiShapeletBasis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ using namespace pybind11::literals;
namespace lsst {
namespace shapelet {

PYBIND11_PLUGIN(multiShapeletBasis) {
py::module mod("multiShapeletBasis");

PYBIND11_MODULE(multiShapeletBasis, mod) {
py::class_<MultiShapeletBasisComponent, std::shared_ptr<MultiShapeletBasisComponent>>
clsMultiShapeletBasisComponent(mod, "MultiShapeletBasisComponent");
clsMultiShapeletBasisComponent(mod, "MultiShapeletBasisComponent");

clsMultiShapeletBasisComponent.def(py::init<double, int, ndarray::Array<double const, 2, 2> const &>(),
"radius"_a, "order"_a, "matrix"_a);
Expand All @@ -59,8 +57,6 @@ PYBIND11_PLUGIN(multiShapeletBasis) {
clsMultiShapeletBasis.def("normalize", &MultiShapeletBasis::normalize);
clsMultiShapeletBasis.def("merge", &MultiShapeletBasis::merge);
clsMultiShapeletBasis.def("makeFunction", &MultiShapeletBasis::makeFunction);

return mod.ptr();
}

} // shapelet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,17 @@ void declareMultiShapeletFunctionEvaluatorMembers(PyClass &cls) {

} // <anonymous>

PYBIND11_PLUGIN(multiShapeletFunction) {
PYBIND11_MODULE(multiShapeletFunction, mod) {
py::module::import("lsst.afw.geom");
py::module::import("lsst.afw.image");

py::module mod("multiShapeletFunction");

py::class_<MultiShapeletFunction, std::shared_ptr<MultiShapeletFunction>> clsMultiShapeletFunction(
py::class_<MultiShapeletFunction, std::shared_ptr<MultiShapeletFunction>> clsMultiShapeletFunction(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

mod, "MultiShapeletFunction");
py::class_<MultiShapeletFunctionEvaluator, std::shared_ptr<MultiShapeletFunctionEvaluator>>
clsMultiShapeletFunctionEvaluator(mod, "MultiShapeletFunctionEvaluator");

declareMultiShapeletFunctionMembers(clsMultiShapeletFunction);
declareMultiShapeletFunctionEvaluatorMembers(clsMultiShapeletFunctionEvaluator);

return mod.ptr();
}

} // shapelet
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/shapelet/radialProfile/radialProfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ using namespace pybind11::literals;
namespace lsst {
namespace shapelet {

PYBIND11_PLUGIN(radialProfile) {
py::module mod("radialProfile");

PYBIND11_MODULE(radialProfile, mod) {
py::class_<RadialProfile, std::shared_ptr<RadialProfile>> clsRadialProfile(mod, "RadialProfile");

clsRadialProfile.def_static("get", &RadialProfile::get, py::return_value_policy::reference);
Expand All @@ -45,8 +43,6 @@ PYBIND11_PLUGIN(radialProfile) {
clsRadialProfile.def("getMomentsRadiusFactor", &RadialProfile::getMomentsRadiusFactor);
clsRadialProfile.def("getBasis", &RadialProfile::getBasis, "nComponents"_a, "maxRadius"_a = 0);
clsRadialProfile.def("registerBasis", &RadialProfile::registerBasis);

return mod.ptr();
}

} // shapelet
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/shapelet/shapeletFunction/shapeletFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ using namespace pybind11::literals;
namespace lsst {
namespace shapelet {

PYBIND11_PLUGIN(shapeletFunction) {
PYBIND11_MODULE(shapeletFunction, mod) {
py::module::import("lsst.afw.geom");
py::module::import("lsst.afw.image");

py::module mod("shapeletFunction");

py::class_<ShapeletFunction, std::shared_ptr<ShapeletFunction>> clsShapeletFunction(mod,
"ShapeletFunction");

Expand Down Expand Up @@ -103,8 +101,6 @@ PYBIND11_PLUGIN(shapeletFunction) {
clsShapeletFunctionEvaluator.def("integrate", &ShapeletFunctionEvaluator::integrate);
clsShapeletFunctionEvaluator.def("computeMoments", &ShapeletFunctionEvaluator::computeMoments);
clsShapeletFunctionEvaluator.def("update", &ShapeletFunctionEvaluator::update);

return mod.ptr();
}

} // shapelet
Expand Down