Skip to content

Commit

Permalink
Add missing imports to pybind11 wrappers
Browse files Browse the repository at this point in the history
pybind11 2.2 appears to be much pickier than 2.1 about requiring
wrapper modules to import what they need.
  • Loading branch information
r-owen committed Jul 18, 2018
1 parent d350bd7 commit 4c7bb7d
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/lsst/afw/cameraGeom/orientation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ namespace cameraGeom {
PYBIND11_PLUGIN(orientation) {
py::module mod("orientation");

py::module::import("lsst.geom");

/* Module level */
py::class_<Orientation> cls(mod, "Orientation");

Expand Down
2 changes: 2 additions & 0 deletions python/lsst/afw/fits/fits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ using namespace pybind11::literals;
void declareImageCompression(py::module & mod) {
py::class_<ImageCompressionOptions> cls(mod, "ImageCompressionOptions");

py::module::import("lsst.pex.exceptions");

py::enum_<ImageCompressionOptions::CompressionAlgorithm>(cls, "CompressionAlgorithm").
value("NONE", ImageCompressionOptions::CompressionAlgorithm::NONE).
value("GZIP", ImageCompressionOptions::CompressionAlgorithm::GZIP).
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/afw/geom/ellipses/ellipse/ellipse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ PYBIND11_PLUGIN(ellipse) {
// clsEllipseGridTransform.def("getDeterminant", &Ellipse::GridTransform::getDeterminant);
// clsEllipseGridTransform.def("invert", &Ellipse::GridTransform::invert);

py::module::import("lsst.geom");

/* Constructors */
clsEllipse.def(py::init<BaseCore const &, lsst::geom::Point2D const &>(), "core"_a, "center"_a = lsst::geom::Point2D());
clsEllipse.def(py::init<Ellipse const &>());
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/afw/geom/polygon/polygon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace polygon {
PYBIND11_PLUGIN(polygon) {
py::module mod("polygon");

py::module::import("lsst.pex.exceptions");

// TODO: Commented-out code is waiting until needed and is untested.
// Add tests for it and enable it or remove it before the final pybind11 merge.

Expand Down
1 change: 1 addition & 0 deletions python/lsst/afw/geom/skyWcs/skyWcs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace {
PYBIND11_PLUGIN(skyWcs) {
py::module mod("skyWcs");

py::module::import("lsst.geom");
py::module::import("lsst.afw.geom.transform");

mod.def("makeCdMatrix", makeCdMatrix, "scale"_a, "orientation"_a = 0 * lsst::geom::degrees,
Expand Down
1 change: 1 addition & 0 deletions python/lsst/afw/geom/spanSet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ PYBIND11_PLUGIN(spanSet) {
py::module mod("spanSet");
using MaskPixel = image::MaskPixel;

py::module::import("lsst.geom");
py::module::import("lsst.afw.geom.span");

py::enum_<Stencil>(mod, "Stencil")
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/afw/image/exposureInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ PYBIND11_PLUGIN(exposureInfo) {

py::module::import("lsst.daf.base");
py::module::import("lsst.afw.geom.skyWcs");
py::module::import("lsst.afw.cameraGeom.detector");
py::module::import("lsst.afw.detection.psf");
py::module::import("lsst.afw.image.calib");
py::module::import("lsst.afw.image.apCorrMap");
py::module::import("lsst.afw.image.coaddInputs");
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/afw/image/image/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ static void addGeneralizedCopyConstructors(PyClass &cls) {
PYBIND11_PLUGIN(image) {
py::module mod("image");

py::module::import("lsst.daf.base");

py::enum_<ImageOrigin>(mod, "ImageOrigin")
.value("PARENT", ImageOrigin::PARENT)
.value("LOCAL", ImageOrigin::LOCAL)
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/afw/image/imageSlice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ template <typename PixelT>
static void declareImageSlice(py::module &mod, std::string const &suffix) {
using Class = ImageSlice<PixelT>;

py::module::import("lsst.afw.image.image");

py::class_<Class, std::shared_ptr<Class>, Image<PixelT>> cls(mod, ("ImageSlice" + suffix).c_str());

cls.def(py::init<Image<PixelT> const &>(), "img"_a);
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/afw/image/maskedImage/maskedImage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ template <typename ImagePixelT>
PyMaskedImage<ImagePixelT> declareMaskedImage(py::module &mod, const std::string &suffix) {
using MI = MaskedImage<ImagePixelT>;

py::module::import("lsst.daf.base");

PyMaskedImage<ImagePixelT> cls(mod, ("MaskedImage" + suffix).c_str());

mod.def("makeMaskedImage", &makeMaskedImage<ImagePixelT, MaskPixel, VariancePixel>, "image"_a,
Expand Down
5 changes: 4 additions & 1 deletion python/lsst/afw/image/visitInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ static lsst::geom::Angle const nanAngle(nan);
PYBIND11_PLUGIN(visitInfo) {
py::module mod("visitInfo");

py::module::import("lsst.afw.geom");
py::module::import("lsst.daf.base");
py::module::import("lsst.geom");
py::module::import("lsst.afw.coord.observatory");
py::module::import("lsst.afw.coord.weather");

/* Module level */
py::class_<VisitInfo, std::shared_ptr<VisitInfo>> cls(mod, "VisitInfo");
Expand Down

0 comments on commit 4c7bb7d

Please sign in to comment.