“Carelessness” / “Stinginess Warning” for “Rank”

I have python code that uses numpy and successfully runs for a year or more. Last week, I unexpectedly received the following error:

/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 cannot find much in this online, but I found the assumption that this was due to a bug in older versions of scipy (although my code does not actually use scipy directly). I upgraded to python 2.7.9 with numpy 1.9.2 and scipy 0.15.1, however I still get the same error. I'm not sure what causes this, or how I fix it.

+6
source share
1 answer

From the release notes for NumPy 1.9.1:

rank function

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

It seems that the developers considered it necessary to reserve the word "rank" to indicate the number of linearly independent rows that the array has, and not use it to also mean the number of dimensions.

This feature will not be featured in major future releases of NumPy. Therefore, instead of using np.rank to find the number of dimensions in an array, follow the recommendations in the warning and use the ndim attribute for the array or the np.ndim function.

If you just want to suppress a warning at the moment, the warnings module allows warnings to ignore messages.

+5
source

Source: https://habr.com/ru/post/985538/


All Articles