Skip to content

Commit dae1a81

Browse files
handle both cases for return of _validate_indices
1 parent 6283051 commit dae1a81

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

elephant/conversion.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,13 @@ def __getitem__(self, item):
692692
the returned binned sparse matrix will affect the original data.
693693
"""
694694
# taken from csr_matrix.__getitem__
695-
row_col, idx_shape = self.sparse_matrix._validate_indices(item)
696-
# _validate_indices returns two tuples since 1.15 , previously it was one tuple with row col
697-
row, col = row_col
695+
valid_indices = self.sparse_matrix._validate_indices(item)
696+
if isinstance(valid_indices[0], tuple):
697+
# New version of SciPy (1.15 and later)
698+
row, col = valid_indices[0]
699+
else:
700+
# Previous version of SciPy
701+
row, col = valid_indices
698702
spmat = self.sparse_matrix[item]
699703
if np.isscalar(spmat):
700704
# data with one element

0 commit comments

Comments
 (0)