Skip to content

Commit

Permalink
Modernize placement-new custom constructors
Browse files Browse the repository at this point in the history
There was one: for CoaddBoundedFieldElement
  • Loading branch information
r-owen committed Jul 18, 2018
1 parent d5dafd7 commit f3755a5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions python/lsst/meas/algorithms/coaddBoundedField.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ PYBIND11_MODULE(coaddBoundedField, mod) {
py::class_<CoaddBoundedFieldElement> clsCoaddBoundedFieldElement(mod, "CoaddBoundedFieldElement");

clsCoaddBoundedFieldElement.def(
"__init__",
[](CoaddBoundedFieldElement &instance, std::shared_ptr<afw::math::BoundedField> field,
std::shared_ptr<afw::geom::SkyWcs const> wcs, py::object polygon, double weight) {
py::init([](std::shared_ptr<afw::math::BoundedField> field,
std::shared_ptr<afw::geom::SkyWcs const> wcs, py::object polygon, double weight) {
if (polygon == py::none()) {
new (&instance) CoaddBoundedFieldElement(field, wcs, nullptr, weight);
return new CoaddBoundedFieldElement(field, wcs, nullptr, weight);
} else {
auto pgon = py::cast<std::shared_ptr<afw::geom::polygon::Polygon const>>(polygon);
new (&instance) CoaddBoundedFieldElement(field, wcs, pgon, weight);
return new CoaddBoundedFieldElement(field, wcs, pgon, weight);
}
},
}),
"field"_a, "wcs"_a, "validPolygon"_a, "weight"_a = 1.0);

clsCoaddBoundedFieldElement.def_readwrite("field", &CoaddBoundedFieldElement::field);
Expand Down

0 comments on commit f3755a5

Please sign in to comment.