summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2014-04-12 23:42:11 +0200
committerCharles Harris <charlesr.harris@gmail.com>2014-04-22 14:31:40 -0600
commita45df106b5e34ae60eca0cf9f630df1e39bc0491 (patch)
tree0563cf1549265c573c89f445876f84bd864cf2db /numpy/core/fromnumeric.py
parent51ca860b6f1a373a5a454d0142bdf30659133d54 (diff)
downloadnumpy-a45df106b5e34ae60eca0cf9f630df1e39bc0491.tar.gz
DEP: Deprecate numpy.rank
This function is commonly confused with numpy.linalg.matrix_rank and exists itself only for history reasons. Closes gh-4616
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 575df9628..a2d2f3100 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -4,7 +4,9 @@
from __future__ import division, absolute_import, print_function
import types
+import warnings
+from .. import VisibleDeprecationWarning
from . import multiarray as mu
from . import umath as um
from . import numerictypes as nt
@@ -2453,6 +2455,11 @@ def rank(a):
If `a` is not already an array, a conversion is attempted.
Scalars are zero dimensional.
+ .. note::
+ This function is deprecated in NumPy 1.9 to avoid confusion with
+ `numpy.linalg.matrix_rank`. The ``ndim`` attribute or function
+ should be used instead.
+
Parameters
----------
a : array_like
@@ -2486,6 +2493,10 @@ def rank(a):
0
"""
+ warnings.warn(
+ "`rank` is deprecated; use the `ndim` attribute or function instead. "
+ "To find the rank of a matrix see `numpy.linalg.matrix_rank`.",
+ VisibleDeprecationWarning)
try:
return a.ndim
except AttributeError: