diff --git a/elephant/conversion.py b/elephant/conversion.py index a80b51ee0..338555738 100644 --- a/elephant/conversion.py +++ b/elephant/conversion.py @@ -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