From 5d067e870ab828083cf8b9eec5ff73fade4b3e8b Mon Sep 17 00:00:00 2001 From: Lishen1 Date: Mon, 22 Nov 2021 23:27:00 +0300 Subject: [PATCH 1/3] fix: remove redundant copy operation to fix warning (#3486) * fix compiler warning: deprecated implicit copy constructor * take care of the bug http://eigen.tuxfamily.org/bz/show_bug.cgi?id=747 * add parenthesis for better reading * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update include/pybind11/eigen.h Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner --- include/pybind11/eigen.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/include/pybind11/eigen.h b/include/pybind11/eigen.h index 97b1d96b0..e43e484c6 100644 --- a/include/pybind11/eigen.h +++ b/include/pybind11/eigen.h @@ -80,14 +80,12 @@ template struct EigenConformable { // Matrix type: EigenConformable(EigenIndex r, EigenIndex c, EigenIndex rstride, EigenIndex cstride) : - conformable{true}, rows{r}, cols{c} { - // TODO: when Eigen bug #747 is fixed, remove the tests for non-negativity. http://eigen.tuxfamily.org/bz/show_bug.cgi?id=747 - if (rstride < 0 || cstride < 0) { - negativestrides = true; - } else { - stride = {EigenRowMajor ? rstride : cstride /* outer stride */, - EigenRowMajor ? cstride : rstride /* inner stride */ }; - } + conformable{true}, rows{r}, cols{c}, + //TODO: when Eigen bug #747 is fixed, remove the tests for non-negativity. http://eigen.tuxfamily.org/bz/show_bug.cgi?id=747 + stride{EigenRowMajor ? (rstride > 0 ? rstride : 0) : (cstride > 0 ? cstride : 0) /* outer stride */, + EigenRowMajor ? (cstride > 0 ? cstride : 0) : (rstride > 0 ? rstride : 0) /* inner stride */ }, + negativestrides{rstride < 0 || cstride < 0} { + } // Vector type: EigenConformable(EigenIndex r, EigenIndex c, EigenIndex stride) From fe65693c720ca1e859f9734355bf271a1342cbf7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Nov 2021 16:25:35 -0500 Subject: [PATCH 2/3] [pre-commit.ci] pre-commit autoupdate (#3500) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/asottile/pyupgrade: v2.29.0 → v2.29.1](https://github.com/asottile/pyupgrade/compare/v2.29.0...v2.29.1) - [github.com/psf/black: 21.10b0 → 21.11b1](https://github.com/psf/black/compare/21.10b0...21.11b1) - [github.com/asottile/blacken-docs: v1.11.0 → v1.12.0](https://github.com/asottile/blacken-docs/compare/v1.11.0...v1.12.0) * Keep blacken-docs and black in sync. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Aaron Gokaslan --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 357e2a84b..601031243 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: exclude: ^noxfile.py$ - repo: https://github.com/asottile/pyupgrade - rev: v2.29.0 + rev: v2.29.1 hooks: - id: pyupgrade @@ -44,16 +44,16 @@ repos: # Black, the code formatter, natively supports pre-commit - repo: https://github.com/psf/black - rev: 21.10b0 # Keep in sync with blacken-docs + rev: 21.11b1 # Keep in sync with blacken-docs hooks: - id: black - repo: https://github.com/asottile/blacken-docs - rev: v1.11.0 + rev: v1.12.0 hooks: - id: blacken-docs additional_dependencies: - - black==21.10b0 # keep in sync with black hook + - black==21.11b1 # keep in sync with black hook # Changes tabs to spaces - repo: https://github.com/Lucas-C/pre-commit-hooks From 70a58c577eaf067748c2ec31bfd0b0a614cffba6 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Mon, 22 Nov 2021 17:01:35 -0800 Subject: [PATCH 3/3] Replace usage of deprecated Eigen class MappedSparseMatrix. (#3499) * Replace usage of deprecated Eigen class Eigen::MappedSparseMatrix has been deprecated since Eigen 3.3 from 2016. Use the equivalent modern syntax Eigen::Map>. * Update eigen.h * Update eigen.h --- include/pybind11/eigen.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/pybind11/eigen.h b/include/pybind11/eigen.h index e43e484c6..965d66e8a 100644 --- a/include/pybind11/eigen.h +++ b/include/pybind11/eigen.h @@ -50,8 +50,12 @@ PYBIND11_NAMESPACE_BEGIN(detail) #if EIGEN_VERSION_AT_LEAST(3,3,0) using EigenIndex = Eigen::Index; +template +using EigenMapSparseMatrix = Eigen::Map>; #else using EigenIndex = EIGEN_DEFAULT_DENSE_INDEX_TYPE; +template +using EigenMapSparseMatrix = Eigen::MappedSparseMatrix; #endif // Matches Eigen::Map, Eigen::Ref, blocks, etc: @@ -571,9 +575,9 @@ struct type_caster::value>> { if (!values || !innerIndices || !outerIndices) return false; - value = Eigen::MappedSparseMatrix( + value = EigenMapSparseMatrix( shape[0].cast(), shape[1].cast(), nnz, outerIndices.mutable_data(), innerIndices.mutable_data(), values.mutable_data());