summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-03-13 13:31:43 -0600
committerCharles Harris <charlesr.harris@gmail.com>2016-03-13 13:31:43 -0600
commitfa107fe361520ceac09131f96a8715473078801e (patch)
treea1d34244fa6f96b0162c993114f7f7f55db41511 /numpy/lib/function_base.py
parentf98b59e427f26c699de9412a528be685cbcde405 (diff)
downloadnumpy-fa107fe361520ceac09131f96a8715473078801e.tar.gz
ENH: Check array dimensionality in cov function.
The input arrays are documented to have ndim <=2, so check for that and raise a ValueError on failure.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index efa51173a..91034ef37 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -2389,11 +2389,17 @@ def cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None,
# Handles complex arrays too
m = np.asarray(m)
+ if m.ndim > 2:
+ raise ValueError("m has more than 2 dimensions")
+
if y is None:
dtype = np.result_type(m, np.float64)
else:
y = np.asarray(y)
+ if y.ndim > 2:
+ raise ValueError("y has more than 2 dimensions")
dtype = np.result_type(m, y, np.float64)
+
X = array(m, ndmin=2, dtype=dtype)
if rowvar == 0 and X.shape[0] != 1:
X = X.T