DEP: Replace np.rank by np.ndim.

The rank function is going to be deprecated as folks new to numpy
tend to confuse it with matrix rank.
Merge pull request #3543 from charris/replace-rank-by-ndim

DEP: Replace np.rank by np.ndim.