mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 08:03:55 +00:00
Compare commits
2 Commits
f3d970ec3f
...
964de932bf
Author | SHA1 | Date | |
---|---|---|---|
|
964de932bf | ||
|
d222055544 |
@ -650,7 +650,7 @@ struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
|
|||||||
using Index = typename Type::Index;
|
using Index = typename Type::Index;
|
||||||
static constexpr bool rowMajor = Type::IsRowMajor;
|
static constexpr bool rowMajor = Type::IsRowMajor;
|
||||||
|
|
||||||
bool load(handle src, bool) {
|
bool load(handle src, bool convert) {
|
||||||
if (!src) {
|
if (!src) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -660,6 +660,9 @@ struct type_caster<Type, enable_if_t<is_eigen_sparse<Type>::value>> {
|
|||||||
object matrix_type = sparse_module.attr(rowMajor ? "csr_matrix" : "csc_matrix");
|
object matrix_type = sparse_module.attr(rowMajor ? "csr_matrix" : "csc_matrix");
|
||||||
|
|
||||||
if (!type::handle_of(obj).is(matrix_type)) {
|
if (!type::handle_of(obj).is(matrix_type)) {
|
||||||
|
if (!convert) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
obj = matrix_type(obj);
|
obj = matrix_type(obj);
|
||||||
} catch (const error_already_set &) {
|
} catch (const error_already_set &) {
|
||||||
|
Loading…
Reference in New Issue
Block a user