Skip to content

Commit

Permalink
[Fix] slicing BinnedSpikeTrain with scipy>=1.15.0 (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz-Alexander-Kern authored Jan 8, 2025
1 parent 7fa7bc9 commit 3d54e99
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion elephant/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,17 @@ def __getitem__(self, item):
the returned binned sparse matrix will affect the original data.
"""
# taken from csr_matrix.__getitem__
row, col = self.sparse_matrix._validate_indices(item)
valid_indices = self.sparse_matrix._validate_indices(item)
# TODO: The following is a hot fix to compensate an API change in SciPy 1.15 (#653)
# Currently, we cannot set scipy>=1.15 since this would not allow for Python 3.9.
# Once we phase out support for Python 3.9, remove the if statement and the else
# branch and require scipy>=1.15.
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 3d54e99

Please sign in to comment.