-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Closed
Description
Description
On 32 bit versions of Windows, when min_max_axis
is called on a csc matrix where indptr.dtype
is int64, an error is produced. This prevents this pull request passing tests (see here).
Steps/Code to Reproduce
import scipy.sparse as sp
from sklearn.utils.sparsefuncs import min_max_axis
X = sp.csc_matrix([[1,2],[3,4]])
X.indptr = X.indptr.astype('int64')
Y = sp.csr_matrix([[1,2],[3,4]])
Y.indptr = Y.indptr.astype('int64')
print(min_max_axis(Y, 0))
print(min_max_axis(X, 0))
Expected Results
(array([1, 2], dtype=int32), array([3, 4], dtype=int32))
(array([1, 2], dtype=int32), array([3, 4], dtype=int32))
Actual Results
(array([1, 2], dtype=int32), array([3, 4], dtype=int32))
Traceback (most recent call last):
File "C:\Users\rod\bug.py", line 12, in <module>
print(min_max_axis(X, 0))
File "C:\Users\rod\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\utils\sparsefuncs.py", line 434, in min_max_axis
return _sparse_min_max(X, axis=axis)
File "C:\Users\rod\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\utils\sparsefuncs.py", line 395, in _sparse_min_max
return (_sparse_min_or_max(X, axis, np.minimum),
File "C:\Users\rod\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\utils\sparsefuncs.py", line 389, in _sparse_min_or_max
return _min_or_max_axis(X, axis, min_or_max)
File "C:\Users\rod\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\utils\sparsefuncs.py", line 359, in _min_or_max_axis
major_index, value = _minor_reduce(mat, min_or_max)
File "C:\Users\rod\AppData\Local\Programs\Python\Python35-32\lib\site-packages\sklearn\utils\sparsefuncs.py", line 344, in _minor_reduce
value = ufunc.reduceat(X.data, X.indptr[major_index])
TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'
Versions
System:
python: 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:07:06) [MSC v.1900 32 bit (Intel)]
machine: Windows-10-10.0.17763-SP0
executable: C:\Users\rod\AppData\Local\Programs\Python\Python35-32\pythonw.exe
BLAS:
macros:
cblas_libs: cblas
lib_dirs:
Python deps:
Cython: 0.29.7
scipy: 1.2.1
setuptools: 28.8.0
numpy: 1.16.3
pip: 19.1
pandas: None
sklearn: 0.20.3
Metadata
Metadata
Assignees
Labels
No labels