From df10b674f4266658aa9eaaafb10d9e76f2fc7744 Mon Sep 17 00:00:00 2001 From: amice Date: Thu, 13 Jun 2024 15:34:49 -0400 Subject: [PATCH] sparse vector fix --- include/pybind11/eigen/matrix.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/pybind11/eigen/matrix.h b/include/pybind11/eigen/matrix.h index 2f2d2cb2c0..47483def69 100644 --- a/include/pybind11/eigen/matrix.h +++ b/include/pybind11/eigen/matrix.h @@ -880,7 +880,11 @@ struct type_caster::value>> { } static handle cast(const Type &src, return_value_policy /* policy */, handle /* parent */) { - const_cast(src).makeCompressed(); + if constexpr (!std::is_same_v(src).makeCompressed(); + // use type specific operations... + } + object matrix_type = module_::import("scipy.sparse").attr(rowMajor ? "csr_matrix" : "csc_matrix");