From 8bb282307481e208f972a72c5745c63e2404cd66 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 7 Jul 2010 04:32:00 +0000 Subject: ENH: Add ddof keyword to masked versions of cov and corrcoef. --- numpy/lib/function_base.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 3f49af5f1..b2ec9bb5a 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1846,8 +1846,8 @@ def cov(m, y=None, rowvar=1, bias=0, ddof=None): ddof : int, optional .. versionadded:: 1.5 If not ``None`` normalization is by ``(N - ddof)``, where ``N`` is - the number of observations. When defined, ``ddof`` overrides the - value implied by ``bias``. The default value is ``None``. + the number of observations; this overrides the value implied by + ``bias``. The default value is ``None``. Returns ------- @@ -1893,6 +1893,10 @@ def cov(m, y=None, rowvar=1, bias=0, ddof=None): 11.71 """ + # Check inputs + if ddof is not None and ddof != int(ddof): + raise ValueError("ddof must be integer") + X = array(m, ndmin=2, dtype=float) if X.shape[0] == 1: rowvar = 1 @@ -1961,8 +1965,8 @@ def corrcoef(x, y=None, rowvar=1, bias=0, ddof=None): ddof : {None, int}, optional .. versionadded:: 1.5 If not ``None`` normalization is by ``(N - ddof)``, where ``N`` is - the number of observations. When defined, ``ddof`` overrides the - value implied by ``bias``. The default value is ``None``. + the number of observations; this overrides the value implied by + ``bias``. The default value is ``None``. Returns ------- -- cgit v1.2.1