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 #16

Merged
merged 3 commits 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
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -8,6 +8,10 @@ _build.*
core.*
.sconf_temp
.sconsign.dblite
.cache
.pytest_cache
pytest_session.txt
.coverage
config.log
doc/doxygen.conf
doc/html
Expand Down
14 changes: 5 additions & 9 deletions python/lsst/sphgeom/angle.cc
Expand Up @@ -31,9 +31,7 @@ namespace lsst {
namespace sphgeom {
namespace {

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

PYBIND11_MODULE(angle, mod) {
py::class_<Angle> cls(mod, "Angle");

cls.def_static("nan", &Angle::nan);
Expand All @@ -46,10 +44,10 @@ PYBIND11_PLUGIN(angle) {
// Construct an Angle from a NormalizedAngle, enabling implicit
// conversion from NormalizedAngle to Angle in python via
// py::implicitly_convertible
cls.def("__init__",
[](Angle &self, NormalizedAngle &a) {
new (&self) Angle(a.asRadians());
},
cls.def(py::init(
[](NormalizedAngle &a) {
return new Angle(a.asRadians());
}),
"normalizedAngle"_a);

cls.def("__eq__", &Angle::operator==, py::is_operator());
Expand Down Expand Up @@ -92,8 +90,6 @@ PYBIND11_PLUGIN(angle) {
cls.def("__reduce__", [cls](Angle const &self) {
return py::make_tuple(cls, py::make_tuple(self.asRadians()));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/angleInterval.cc
Expand Up @@ -34,8 +34,7 @@ namespace lsst {
namespace sphgeom {
namespace {

PYBIND11_PLUGIN(angleInterval) {
py::module mod("angleInterval");
PYBIND11_MODULE(angleInterval, mod) {
py::module::import("lsst.sphgeom.angle");

py::class_<AngleInterval, std::shared_ptr<AngleInterval>> cls(
Expand All @@ -61,8 +60,6 @@ PYBIND11_PLUGIN(angleInterval) {
return py::str("AngleInterval.fromRadians({!r}, {!r})")
.format(self.getA().asRadians(), self.getB().asRadians());
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/box.cc
Expand Up @@ -50,8 +50,7 @@ std::unique_ptr<Box> decode(py::bytes bytes) {
return Box::decode(buffer, n);
}

PYBIND11_PLUGIN(box) {
py::module mod("box");
PYBIND11_MODULE(box, mod) {
py::module::import("lsst.sphgeom.region");

py::class_<Box, std::shared_ptr<Box>, Region> cls(mod, "Box");
Expand Down Expand Up @@ -165,8 +164,6 @@ PYBIND11_PLUGIN(box) {
cls.def("__setstate__", [](Box &self, py::bytes bytes) {
new (&self) Box(*decode(bytes));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/box3d.cc
Expand Up @@ -34,8 +34,7 @@ namespace lsst {
namespace sphgeom {
namespace {

PYBIND11_PLUGIN(box3d) {
py::module mod("box3d");
PYBIND11_MODULE(box3d, mod) {
py::module::import("lsst.sphgeom.interval1d");
py::module::import("lsst.sphgeom.vector3d");

Expand Down Expand Up @@ -162,8 +161,6 @@ PYBIND11_PLUGIN(box3d) {
return py::make_tuple(cls,
py::make_tuple(self.x(), self.y(), self.z()));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/sphgeom/chunker.cc
Expand Up @@ -39,9 +39,7 @@ py::str toString(Chunker const & self) {
}


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

PYBIND11_MODULE(chunker, mod) {
py::class_<Chunker, std::shared_ptr<Chunker>> cls(mod, "Chunker");

cls.def(py::init<int32_t, int32_t>(), "numStripes"_a,
Expand Down Expand Up @@ -76,8 +74,6 @@ PYBIND11_PLUGIN(chunker) {
py::make_tuple(self.getNumStripes(),
self.getNumSubStripesPerStripe()));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/circle.cc
Expand Up @@ -46,8 +46,7 @@ std::unique_ptr<Circle> decode(py::bytes bytes) {
return Circle::decode(buffer, n);
}

PYBIND11_PLUGIN(circle) {
py::module mod("circle");
PYBIND11_MODULE(circle, mod) {
py::module::import("lsst.sphgeom.region");

py::class_<Circle, std::shared_ptr<Circle>, Region> cls(mod, "Circle");
Expand Down Expand Up @@ -147,8 +146,6 @@ PYBIND11_PLUGIN(circle) {
cls.def("__setstate__", [](Circle &self, py::bytes bytes) {
new (&self) Circle(*decode(bytes));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/convexPolygon.cc
Expand Up @@ -48,8 +48,7 @@ std::unique_ptr<ConvexPolygon> decode(py::bytes bytes) {
return ConvexPolygon::decode(buffer, n);
}

PYBIND11_PLUGIN(convexPolygon) {
py::module mod("convexPolygon");
PYBIND11_MODULE(convexPolygon, mod) {
py::module::import("lsst.sphgeom.region");

py::class_<ConvexPolygon, std::shared_ptr<ConvexPolygon>, Region> cls(
Expand Down Expand Up @@ -88,8 +87,6 @@ PYBIND11_PLUGIN(convexPolygon) {
cls.def("__setstate__", [](ConvexPolygon &self, py::bytes bytes) {
new (&self) ConvexPolygon(*decode(bytes));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/sphgeom/curve.cc
Expand Up @@ -30,9 +30,7 @@ namespace lsst {
namespace sphgeom {
namespace {

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

PYBIND11_MODULE(curve, mod) {
mod.def("log2", (uint8_t(*)(uint64_t)) & log2);
mod.def("mortonIndex", (uint64_t(*)(uint32_t, uint32_t)) & mortonIndex,
"x"_a, "y"_a);
Expand All @@ -48,8 +46,6 @@ PYBIND11_PLUGIN(curve) {
(std::tuple<uint32_t, uint32_t>(*)(uint64_t, int)) &
hilbertIndexInverse,
"h"_a, "m"_a);

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/ellipse.cc
Expand Up @@ -48,8 +48,7 @@ std::unique_ptr<Ellipse> decode(py::bytes bytes) {
return Ellipse::decode(buffer, n);
}

PYBIND11_PLUGIN(ellipse) {
py::module mod("ellipse");
PYBIND11_MODULE(ellipse, mod) {
py::module::import("lsst.sphgeom.region");

py::class_<Ellipse, std::shared_ptr<Ellipse>, Region> cls(mod, "Ellipse");
Expand Down Expand Up @@ -105,8 +104,6 @@ PYBIND11_PLUGIN(ellipse) {
cls.def("__setstate__", [](Ellipse &self, py::bytes bytes) {
new (&self) Ellipse(*decode(bytes));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/htmPixelization.cc
Expand Up @@ -30,8 +30,7 @@ namespace lsst {
namespace sphgeom {
namespace {

PYBIND11_PLUGIN(htmPixelization) {
py::module mod("htmPixelization");
PYBIND11_MODULE(htmPixelization, mod) {
py::module::import("lsst.sphgeom.pixelization");
py::module::import("lsst.sphgeom.region");

Expand Down Expand Up @@ -62,8 +61,6 @@ PYBIND11_PLUGIN(htmPixelization) {
cls.def("__reduce__", [cls](HtmPixelization const &self) {
return py::make_tuple(cls, py::make_tuple(self.getLevel()));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/sphgeom/interval1d.cc
Expand Up @@ -34,9 +34,7 @@ namespace lsst {
namespace sphgeom {
namespace {

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

PYBIND11_MODULE(interval1d, mod) {
py::class_<Interval1d, std::shared_ptr<Interval1d>> cls(mod, "Interval1d");

python::defineInterval<decltype(cls), Interval1d, double>(cls);
Expand All @@ -58,8 +56,6 @@ PYBIND11_PLUGIN(interval1d) {
return py::str("Interval1d({!r}, {!r})")
.format(self.getA(), self.getB());
});

return mod.ptr();
}

} // <anonymous>
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/sphgeom/lonLat.cc
Expand Up @@ -33,9 +33,7 @@ namespace lsst {
namespace sphgeom {
namespace {

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

PYBIND11_MODULE(lonLat, mod) {
py::class_<LonLat, std::shared_ptr<LonLat>> cls(mod, "LonLat");

cls.def_static("fromDegrees", &LonLat::fromDegrees);
Expand Down Expand Up @@ -76,8 +74,6 @@ PYBIND11_PLUGIN(lonLat) {
return py::make_tuple(cls,
py::make_tuple(self.getLon(), self.getLat()));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/matrix3d.cc
Expand Up @@ -37,8 +37,7 @@ Vector3d getRow(Matrix3d const &self, py::int_ row) {
return self.getRow(static_cast<int>(python::convertIndex(3, row)));
}

PYBIND11_PLUGIN(matrix3d) {
py::module mod("matrix3d");
PYBIND11_MODULE(matrix3d, mod) {
py::module::import("lsst.sphgeom.vector3d");

py::class_<Matrix3d, std::shared_ptr<Matrix3d>> cls(mod, "Matrix3d");
Expand Down Expand Up @@ -122,8 +121,6 @@ PYBIND11_PLUGIN(matrix3d) {
self(2, 0), self(2, 1), self(2, 2));
return py::make_tuple(cls, args);
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/mq3cPixelization.cc
Expand Up @@ -30,8 +30,7 @@ namespace lsst {
namespace sphgeom {
namespace {

PYBIND11_PLUGIN(mq3cPixelization) {
py::module mod("mq3cPixelization");
PYBIND11_MODULE(mq3cPixelization, mod) {
py::module::import("lsst.sphgeom.pixelization");
py::module::import("lsst.sphgeom.region");

Expand Down Expand Up @@ -63,8 +62,6 @@ PYBIND11_PLUGIN(mq3cPixelization) {
cls.def("__reduce__", [cls](Mq3cPixelization const &self) {
return py::make_tuple(cls, py::make_tuple(self.getLevel()));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/normalizedAngle.cc
Expand Up @@ -32,8 +32,7 @@ namespace lsst {
namespace sphgeom {
namespace {

PYBIND11_PLUGIN(normalizedAngle) {
py::module mod("normalizedAngle");
PYBIND11_MODULE(normalizedAngle, mod) {
py::module::import("lsst.sphgeom.angle");

py::class_<NormalizedAngle> cls(mod, "NormalizedAngle");
Expand Down Expand Up @@ -94,8 +93,6 @@ PYBIND11_PLUGIN(normalizedAngle) {
cls.def("__reduce__", [cls](NormalizedAngle const &self) {
return py::make_tuple(cls, py::make_tuple(self.asRadians()));
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/normalizedAngleInterval.cc
Expand Up @@ -34,8 +34,7 @@ namespace lsst {
namespace sphgeom {
namespace {

PYBIND11_PLUGIN(normalizedAngleInterval) {
py::module mod("normalizedAngleInterval");
PYBIND11_MODULE(normalizedAngleInterval, mod) {
py::module::import("lsst.sphgeom.normalizedAngle");

py::class_<NormalizedAngleInterval,
Expand Down Expand Up @@ -72,8 +71,6 @@ PYBIND11_PLUGIN(normalizedAngleInterval) {
" {!r})")
.format(self.getA().asRadians(), self.getB().asRadians());
});

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/orientation.cc
Expand Up @@ -30,8 +30,7 @@ namespace lsst {
namespace sphgeom {
namespace {

PYBIND11_PLUGIN(orientation) {
py::module mod("orientation");
PYBIND11_MODULE(orientation, mod) {
py::module::import("lsst.sphgeom.vector3d");
py::module::import("lsst.sphgeom.unitVector3d");

Expand All @@ -40,8 +39,6 @@ PYBIND11_PLUGIN(orientation) {
mod.def("orientationX", &orientationX, "b"_a, "c"_a);
mod.def("orientationY", &orientationY, "b"_a, "c"_a);
mod.def("orientationZ", &orientationZ, "b"_a, "c"_a);

return mod.ptr();
}

} // <anonymous>
Expand Down
6 changes: 1 addition & 5 deletions python/lsst/sphgeom/pixelization.cc
Expand Up @@ -32,9 +32,7 @@ namespace lsst {
namespace sphgeom {
namespace {

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

PYBIND11_MODULE(pixelization, mod) {
py::class_<Pixelization> cls(mod, "Pixelization");

cls.def("universe", &Pixelization::universe);
Expand All @@ -43,8 +41,6 @@ PYBIND11_PLUGIN(pixelization) {
cls.def("toString", &Pixelization::toString, "i"_a);
cls.def("envelope", &Pixelization::envelope, "region"_a, "maxRanges"_a = 0);
cls.def("interior", &Pixelization::interior, "region"_a, "maxRanges"_a = 0);

return mod.ptr();
}

} // <anonymous>
Expand Down
5 changes: 1 addition & 4 deletions python/lsst/sphgeom/q3cPixelization.cc
Expand Up @@ -30,8 +30,7 @@ namespace lsst {
namespace sphgeom {
namespace {

PYBIND11_PLUGIN(q3cPixelization) {
py::module mod("q3cPixelization");
PYBIND11_MODULE(q3cPixelization, mod) {
py::module::import("lsst.sphgeom.pixelization");
py::module::import("lsst.sphgeom.region");

Expand Down Expand Up @@ -60,8 +59,6 @@ PYBIND11_PLUGIN(q3cPixelization) {
cls.def("__reduce__", [cls](Q3cPixelization const &self) {
return py::make_tuple(cls, py::make_tuple(self.getLevel()));
});

return mod.ptr();
}

} // <anonymous>
Expand Down