Closed mailoszyarr closed 10 years ago
You want to use np.linalg.matrix_rank
, not np.rank
. For ndarray
s rank
returns the same as .ndim
.
In [1]: import numpy as np
In [2]: a = np.array([[1, 2], [-1, -2]])
In [3]: np.rank(a)
Out[3]: 2
In [4]: np.linalg.matrix_rank(a)
Out[4]: 1
Sounds indeed like you got the wrong function. A bit of a misnomer. Considering that rank is really a leftover from numeric and call it ndim we might want to consider deprecating it?
@seberg Probably a good idea, IIRC, there was recently another instance of this confusion.
I have seen it a couple times on StackOverflow.
rank(A)
in matlab is the matrix rank.
ndim
is surely a better name.
I vote for deprecation too.
I vote for deprecation too...it should be ndim
and not rank
I vote we immediately put in a user-visible warning that says "this is deprecated and also you probably wanted np.linalg.matrix_rank", to stem the confusion as soon as possible without actually breaking compatibility. On 12 Apr 2014 22:45, "Cimarron" notifications@github.com wrote:
I vote for deprecation too...it should be ndim and not rank
— Reply to this email directly or view it on GitHubhttps://github.com/numpy/numpy/issues/4616#issuecomment-40292643 .
Would be fine with me, too. But visible means we can't use DeprecationWarning...
It is a bit funky, but we could do both a DeprecationWarning and a UserWarning...
Hi, for matrix [[1, 2], [-1, -2]] rank() returns 2, but real value is 1. It is very big issue for Control Systems Engineers - we couldn't detect controlability and observabiliti of MIMO system.