diff options
author | Travis Oliphant <oliphant@enthought.com> | 2008-03-07 21:32:04 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2008-03-07 21:32:04 +0000 |
commit | 62e994938e1549b28117684efcff58d6c6adbc77 (patch) | |
tree | 00d1dd47dea5c0e431401ffaa14738cc59fd2b7e /numpy/core/src/arraymethods.c | |
parent | 0ef3f8b15dd80e95f1d85298bab7954d61419ac4 (diff) | |
download | numpy-62e994938e1549b28117684efcff58d6c6adbc77.tar.gz |
Add ddof parameter to std and var computations.
Diffstat (limited to 'numpy/core/src/arraymethods.c')
-rw-r--r-- | numpy/core/src/arraymethods.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c index 57c879426..79f207756 100644 --- a/numpy/core/src/arraymethods.c +++ b/numpy/core/src/arraymethods.c @@ -1554,23 +1554,27 @@ array_all(PyArrayObject *self, PyObject *args, PyObject *kwds) static PyObject * +__New_PyArray_Std(PyArrayObject *self, int axis, int rtype, PyArrayObject *out, + int variance, int num); +static PyObject * array_stddev(PyArrayObject *self, PyObject *args, PyObject *kwds) { int axis=MAX_DIMS; PyArray_Descr *dtype=NULL; PyArrayObject *out=NULL; int num; - static char *kwlist[] = {"axis", "dtype", "out", NULL}; + int ddof = 0; + static char *kwlist[] = {"axis", "dtype", "out", "ddof", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&O&O&", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&O&O&i", kwlist, PyArray_AxisConverter, &axis, PyArray_DescrConverter2, &dtype, PyArray_OutputConverter, - &out)) return NULL; + &out, &ddof)) return NULL; num = _get_type_num_double(self->descr, dtype); - return PyArray_Std(self, axis, num, out, 0); + return __New_PyArray_Std(self, axis, num, out, 0, ddof); } @@ -1581,17 +1585,18 @@ array_variance(PyArrayObject *self, PyObject *args, PyObject *kwds) PyArray_Descr *dtype=NULL; PyArrayObject *out=NULL; int num; - static char *kwlist[] = {"axis", "dtype", "out", NULL}; + int ddof = 0; + static char *kwlist[] = {"axis", "dtype", "out", "ddof", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&O&O&", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&O&O&i", kwlist, PyArray_AxisConverter, &axis, PyArray_DescrConverter2, &dtype, PyArray_OutputConverter, - &out)) return NULL; + &out, &ddof)) return NULL; num = _get_type_num_double(self->descr, dtype); - return PyArray_Std(self, axis, num, out, 1); + return __New_PyArray_Std(self, axis, num, out, 1, ddof); } |