Skip to content

Commit

Permalink
Merge pull request #120 from lsst/tickets/DM-14834
Browse files Browse the repository at this point in the history
DM-14834: Use pybind11's native Eigen wrapping instead of ndarray EigenView
  • Loading branch information
r-owen committed Jun 29, 2018
2 parents 0fc3614 + 50ef7e0 commit c13a37e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions python/lsst/meas/base/centroidUtilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include "pybind11/pybind11.h"
#include "pybind11/eigen.h"

#include <memory>

Expand Down
1 change: 1 addition & 0 deletions python/lsst/meas/base/shapeUtilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include "pybind11/pybind11.h"
#include "pybind11/eigen.h"

#include <memory>

Expand Down
17 changes: 8 additions & 9 deletions src/ApertureFlux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,8 @@ ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux(
CONST_PTR(afw::image::Image<T>) cImage = getSincCoeffs<T>(image.getBBox(), ellipse, result, ctrl);
if (result.getFlag(APERTURE_TRUNCATED.number)) return result;
afw::image::Image<T> subImage(image, cImage->getBBox());
result.flux = (subImage.getArray().template asEigen<Eigen::ArrayXpr>() *
cImage->getArray().template asEigen<Eigen::ArrayXpr>())
.sum();
result.flux =
(ndarray::asEigenArray(subImage.getArray()) * ndarray::asEigenArray(cImage->getArray())).sum();
return result;
}

Expand All @@ -161,13 +160,13 @@ ApertureFluxAlgorithm::Result ApertureFluxAlgorithm::computeSincFlux(
CONST_PTR(afw::image::Image<T>) cImage = getSincCoeffs<T>(image.getBBox(), ellipse, result, ctrl);
if (result.getFlag(APERTURE_TRUNCATED.number)) return result;
afw::image::MaskedImage<T> subImage(image, cImage->getBBox(afw::image::PARENT), afw::image::PARENT);
result.flux = (subImage.getImage()->getArray().template asEigen<Eigen::ArrayXpr>() *
cImage->getArray().template asEigen<Eigen::ArrayXpr>())
result.flux = (ndarray::asEigenArray(subImage.getImage()->getArray()) *
ndarray::asEigenArray(cImage->getArray()))
.sum();
result.fluxSigma = std::sqrt(
(subImage.getVariance()->getArray().template asEigen<Eigen::ArrayXpr>().template cast<T>() *
cImage->getArray().template asEigen<Eigen::ArrayXpr>().square())
.sum());
result.fluxSigma =
std::sqrt((ndarray::asEigenArray(subImage.getVariance()->getArray()).template cast<T>() *
ndarray::asEigenArray(cImage->getArray()).square())
.sum());
return result;
}

Expand Down

0 comments on commit c13a37e

Please sign in to comment.