Skip to content

Commit cb9486a

Browse files
committed
[eigen] sparse.h : use scipy's API to sort indices for Eigen<3.4.90
1 parent 00b1a07 commit cb9486a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/nanobind/eigen/sparse.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ template <typename T> struct type_caster<T, enable_if_t<is_eigen_sparse_matrix_v
6262
return false;
6363
}
6464

65+
#if !EIGEN_VERSION_AT_LEAST(3, 4, 90)
66+
bool indices_sorted = cast<bool>(obj.attr("has_sorted_indices"));
67+
if (!indices_sorted)
68+
obj.attr("sort_indices")();
69+
#endif
70+
6571
if (object data_o = obj.attr("data"); !data_caster.from_python(data_o, flags, cleanup))
6672
return false;
6773
ScalarNDArray& values = data_caster.value;

0 commit comments

Comments
 (0)