Skip to content

Commit 3d54e99

Browse files
[Fix] slicing BinnedSpikeTrain with scipy>=1.15.0 (#653)
1 parent 7fa7bc9 commit 3d54e99

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

elephant/conversion.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,17 @@ 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 = self.sparse_matrix._validate_indices(item)
695+
valid_indices = self.sparse_matrix._validate_indices(item)
696+
# TODO: The following is a hot fix to compensate an API change in SciPy 1.15 (#653)
697+
# Currently, we cannot set scipy>=1.15 since this would not allow for Python 3.9.
698+
# Once we phase out support for Python 3.9, remove the if statement and the else
699+
# branch and require scipy>=1.15.
700+
if isinstance(valid_indices[0], tuple):
701+
# New version of SciPy (1.15 and later)
702+
row, col = valid_indices[0]
703+
else:
704+
# Previous version of SciPy
705+
row, col = valid_indices
696706
spmat = self.sparse_matrix[item]
697707
if np.isscalar(spmat):
698708
# data with one element

0 commit comments

Comments
 (0)