Numpy/scipy deprecation warning for "rank"

I have some python code which uses numpy and have run this successfully for a year or more. I suddenly got the following error last week:

/usr/local/lib/python2.7/dist-packages/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)

I can't find much on this online, but I found a suggestion that this was due to a bug in old versions of scipy (although my code doesn't actually use scipy directly). I've upgraded to python 2.7.9 with numpy 1.9.2 and scipy 0.15.1, however I'm still getting the same error. I'm not sure what's causing this, or how I fix this.


From the release notes of NumPy 1.9.1:

rank function

The rank function has been deprecated to avoid confusion with numpy.linalg.matrix_rank .

It seems the developers saw fit to reserve the word "rank" to mean the number of linearly independent rows an array has, and not use it to also mean the number of dimensions.

This function won't be present in major future releases of NumPy. Therefore, instead of using np.rank to find the number of dimensions in an array, follow the suggestion in the warning and use the ndim attribute of an array or the function np.ndim instead.

If you simply want to suppress the warning for now, the warnings module allows you to ignore the messages.

链接地址: http://www.djcxy.com/p/87178.html

上一篇: 安装Anaconda2.4.0后无法导入scipy

下一篇: “排名”的Numpy / scipy弃用警告