无法在scipy中创建非空的csr.matrix()



我需要稀疏矩阵来解决问题,根据scipy中scr.matrix()的描述http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html#scipy.sparse.csr_matrix它非常适合我的问题。然而,我甚至无法初始化它。当我使用此文档中的空矩阵示例时http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.sparse.csr_matrix.html它运行良好,与文档完全一样

>>> import numpy as np
>>> from scipy.sparse import csr_matrix
>>> csr_matrix((3, 4), dtype=np.int8).toarray()
array([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]], dtype=int8)

但是当我使用非空martix的例子或者尝试用我自己的数据填充它时

>>> row = np.array([0, 0, 1, 2, 2, 2])
>>> col = np.array([0, 2, 2, 0, 1, 2])
>>> data = np.array([1, 2, 3, 4, 5, 6])
>>> csr_matrix((data, (row, col)), shape=(3, 3)).toarray()

我总是收到这个消息

/Library/Python/2.7/site-packages/numpy-1.9.2-py2.7-macosx-10.10-
intel.egg/numpy/core/fromnumeric.py:2507: VisibleDeprecationWarning: 
`rank` is deprecated; use the `ndim` attribute or function instead. 
To find the rank of a matrix see `numpy.linalg.matrix_rank`.
VisibleDeprecationWarning)

这是什么意思?我完全卡住了。抱歉问这个问题,我刚接触到scipy,需要帮助。

这只是一个警告,我希望创建您的矩阵。Scipy正在校准一个旧的numpy函数。它于2014年4月在scipy中修复。

突变发生在:https://github.com/scipy/scipy/commit/fa1782e04fdab91f672ccf7a4ebfb887de50f01c