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-14834: Use pybind11's native Eigen wrapping instead of ndarray EigenView #362

Merged
merged 3 commits into from
Jun 29, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ core.*
.pytest_cache/
.sconf_temp
.sconsign.dblite
.coverage
config.log
memleak.fits
pytest_session.txt
Expand Down
5 changes: 3 additions & 2 deletions python/lsst/afw/geom/ellipses/baseCore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
* see <https://www.lsstcorp.org/LegalNotices/>.
*/

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "pybind11/pybind11.h"
#include "pybind11/eigen.h"
#include "pybind11/stl.h"

#include "ndarray/pybind11.h"

Expand Down
6 changes: 3 additions & 3 deletions python/lsst/afw/geom/ellipses/ellipse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* see <https://www.lsstcorp.org/LegalNotices/>.
*/

#include <pybind11/pybind11.h>
//#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include "pybind11/pybind11.h"
#include "pybind11/eigen.h"
#include "pybind11/stl.h"

#include "ndarray/pybind11.h"

Expand Down
6 changes: 3 additions & 3 deletions python/lsst/afw/geom/ellipses/quadrupole.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* see <https://www.lsstcorp.org/LegalNotices/>.
*/

#include <pybind11/pybind11.h>
//#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include "pybind11/pybind11.h"
#include "pybind11/eigen.h"
#include "pybind11/stl.h"

#include "lsst/afw/geom/ellipses/BaseCore.h"
#include "lsst/afw/geom/ellipses/Quadrupole.h"
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 @@ -20,6 +20,7 @@
* see <http://www.lsstcorp.org/LegalNotices/>.
*/
#include "pybind11/pybind11.h"
#include "pybind11/eigen.h"

#include <utility>
#include <memory>
Expand Down
1 change: 1 addition & 0 deletions python/lsst/afw/geom/transform/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* see <http://www.lsstcorp.org/LegalNotices/>.
*/
#include "pybind11/pybind11.h"
#include "pybind11/eigen.h"

#include <memory>

Expand Down
1 change: 1 addition & 0 deletions python/lsst/afw/geom/wcsUtils/wcsUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* see <http://www.lsstcorp.org/LegalNotices/>.
*/
#include "pybind11/pybind11.h"
#include "pybind11/eigen.h"

#include <memory>

Expand Down
1 change: 1 addition & 0 deletions python/lsst/afw/table/aggregates/aggregates.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 "pybind11/stl.h"

#include "ndarray/pybind11.h"
Expand Down
1 change: 1 addition & 0 deletions python/lsst/afw/table/slots.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 "lsst/afw/table/slots.h"

Expand Down
1 change: 1 addition & 0 deletions python/lsst/afw/table/source/source.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
4 changes: 2 additions & 2 deletions src/math/ChebyshevBoundedField.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ std::shared_ptr<ChebyshevBoundedField> ChebyshevBoundedField::fit(lsst::geom::Bo
ndarray::Array<double, 2, 2> matrix = makeMatrix(x, y, result->_toChebyshevRange, packer, ctrl);
// We want to do weighted least squares, so we multiply both the data vector 'b' and the
// matrix 'A' by the weights.
matrix.asEigen<Eigen::ArrayXpr>().colwise() *= w.asEigen<Eigen::ArrayXpr>();
ndarray::asEigenArray(matrix).colwise() *= ndarray::asEigenArray(w);
ndarray::Array<double, 1, 1> wz = ndarray::copy(z);
wz.asEigen<Eigen::ArrayXpr>() *= w.asEigen<Eigen::ArrayXpr>();
ndarray::asEigenArray(wz) *= ndarray::asEigenArray(w);
// Solve the linear least squares problem.
LeastSquares lstsq = LeastSquares::fromDesignMatrix(matrix, wz, LeastSquares::NORMAL_EIGENSYSTEM);
// Unpack the solution into a 2-d matrix, with zeros for values we didn't fit.
Expand Down
4 changes: 2 additions & 2 deletions src/math/LeastSquares.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class EigensystemSolver : public LeastSquares::Impl {
ndarray::asEigenMatrix(diagnostic) = _svd.singularValues();
}
if (whichDiagnostic == LeastSquares::DIRECT_SVD) {
diagnostic.asEigen<Eigen::ArrayXpr>() = diagnostic.asEigen<Eigen::ArrayXpr>().sqrt();
ndarray::asEigenArray(diagnostic) = ndarray::asEigenArray(diagnostic).sqrt();
}
}

Expand Down Expand Up @@ -265,7 +265,7 @@ class SvdSolver : public LeastSquares::Impl {
virtual void updateDiagnostic() {
switch (whichDiagnostic) {
case LeastSquares::NORMAL_EIGENSYSTEM:
diagnostic.asEigen<Eigen::ArrayXpr>() = _svd.singularValues().array().square();
ndarray::asEigenArray(diagnostic) = _svd.singularValues().array().square();
break;
case LeastSquares::NORMAL_CHOLESKY:
throw LSST_EXCEPT(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_trapezoidalPacker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typedef lsst::afw::math::ChebyshevBoundedFieldControl Control;

ndarray::Array<double, 1, 1> makeRandomArray(int n) {
ndarray::Array<double, 1, 1> result = ndarray::allocate(n);
result.asEigen<Eigen::ArrayXpr>().setRandom();
ndarray::asEigenArray(result).setRandom();
return result;
}

Expand Down