mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 15:12:01 +00:00
Merge branch 'master' into smart_holder
This commit is contained in:
commit
e94b98fd76
@ -34,7 +34,7 @@ repos:
|
|||||||
exclude: ^noxfile.py$
|
exclude: ^noxfile.py$
|
||||||
|
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v2.29.0
|
rev: v2.29.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
|
|
||||||
@ -45,16 +45,16 @@ repos:
|
|||||||
|
|
||||||
# Black, the code formatter, natively supports pre-commit
|
# Black, the code formatter, natively supports pre-commit
|
||||||
- repo: https://github.com/psf/black
|
- 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:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
|
|
||||||
- repo: https://github.com/asottile/blacken-docs
|
- repo: https://github.com/asottile/blacken-docs
|
||||||
rev: v1.11.0
|
rev: v1.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: blacken-docs
|
- id: blacken-docs
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- black==21.10b0 # keep in sync with black hook
|
- black==21.11b1 # keep in sync with black hook
|
||||||
|
|
||||||
# Changes tabs to spaces
|
# Changes tabs to spaces
|
||||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||||
|
@ -50,8 +50,12 @@ PYBIND11_NAMESPACE_BEGIN(detail)
|
|||||||
|
|
||||||
#if EIGEN_VERSION_AT_LEAST(3,3,0)
|
#if EIGEN_VERSION_AT_LEAST(3,3,0)
|
||||||
using EigenIndex = Eigen::Index;
|
using EigenIndex = Eigen::Index;
|
||||||
|
template<typename Scalar, int Flags, typename StorageIndex>
|
||||||
|
using EigenMapSparseMatrix = Eigen::Map<Eigen::SparseMatrix<Scalar, Flags, StorageIndex>>;
|
||||||
#else
|
#else
|
||||||
using EigenIndex = EIGEN_DEFAULT_DENSE_INDEX_TYPE;
|
using EigenIndex = EIGEN_DEFAULT_DENSE_INDEX_TYPE;
|
||||||
|
template<typename Scalar, int Flags, typename StorageIndex>
|
||||||
|
using EigenMapSparseMatrix = Eigen::MappedSparseMatrix<Scalar, Flags, StorageIndex>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Matches Eigen::Map, Eigen::Ref, blocks, etc:
|
// Matches Eigen::Map, Eigen::Ref, blocks, etc:
|
||||||
@ -80,14 +84,12 @@ template <bool EigenRowMajor> struct EigenConformable {
|
|||||||
// Matrix type:
|
// Matrix type:
|
||||||
EigenConformable(EigenIndex r, EigenIndex c,
|
EigenConformable(EigenIndex r, EigenIndex c,
|
||||||
EigenIndex rstride, EigenIndex cstride) :
|
EigenIndex rstride, EigenIndex cstride) :
|
||||||
conformable{true}, rows{r}, cols{c} {
|
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
|
//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) {
|
stride{EigenRowMajor ? (rstride > 0 ? rstride : 0) : (cstride > 0 ? cstride : 0) /* outer stride */,
|
||||||
negativestrides = true;
|
EigenRowMajor ? (cstride > 0 ? cstride : 0) : (rstride > 0 ? rstride : 0) /* inner stride */ },
|
||||||
} else {
|
negativestrides{rstride < 0 || cstride < 0} {
|
||||||
stride = {EigenRowMajor ? rstride : cstride /* outer stride */,
|
|
||||||
EigenRowMajor ? cstride : rstride /* inner stride */ };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Vector type:
|
// Vector type:
|
||||||
EigenConformable(EigenIndex r, EigenIndex c, EigenIndex stride)
|
EigenConformable(EigenIndex r, EigenIndex c, EigenIndex stride)
|
||||||
@ -573,9 +575,9 @@ struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
|
|||||||
if (!values || !innerIndices || !outerIndices)
|
if (!values || !innerIndices || !outerIndices)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
value = Eigen::MappedSparseMatrix<Scalar,
|
value = EigenMapSparseMatrix<Scalar,
|
||||||
Type::Flags & (Eigen::RowMajor | Eigen::ColMajor),
|
Type::Flags & (Eigen::RowMajor | Eigen::ColMajor),
|
||||||
StorageIndex>(
|
StorageIndex>(
|
||||||
shape[0].cast<Index>(), shape[1].cast<Index>(), nnz,
|
shape[0].cast<Index>(), shape[1].cast<Index>(), nnz,
|
||||||
outerIndices.mutable_data(), innerIndices.mutable_data(), values.mutable_data());
|
outerIndices.mutable_data(), innerIndices.mutable_data(), values.mutable_data());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user