Skip to content

Commit

Permalink
handle both cases for return of _validate_indices
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz-Alexander-Kern committed Jan 6, 2025
1 parent 6283051 commit dae1a81
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions elephant/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,13 @@ def __getitem__(self, item):
the returned binned sparse matrix will affect the original data.
"""
# taken from csr_matrix.__getitem__
row_col, idx_shape = self.sparse_matrix._validate_indices(item)
# _validate_indices returns two tuples since 1.15 , previously it was one tuple with row col
row, col = row_col
valid_indices = self.sparse_matrix._validate_indices(item)
if isinstance(valid_indices[0], tuple):
# New version of SciPy (1.15 and later)
row, col = valid_indices[0]
else:
# Previous version of SciPy
row, col = valid_indices
spmat = self.sparse_matrix[item]
if np.isscalar(spmat):
# data with one element
Expand Down

0 comments on commit dae1a81

Please sign in to comment.