File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments