NUMPY_API * Mean */
| 715 | * Mean |
| 716 | */ |
| 717 | NPY_NO_EXPORT PyObject * |
| 718 | PyArray_Mean(PyArrayObject *self, int axis, int rtype, PyArrayObject *out) |
| 719 | { |
| 720 | PyObject *obj1 = NULL, *obj2 = NULL, *ret; |
| 721 | PyArrayObject *arr; |
| 722 | |
| 723 | arr = (PyArrayObject *)PyArray_CheckAxis(self, &axis, 0); |
| 724 | if (arr == NULL) { |
| 725 | return NULL; |
| 726 | } |
| 727 | obj1 = PyArray_GenericReduceFunction(arr, n_ops.add, axis, |
| 728 | rtype, out); |
| 729 | obj2 = PyFloat_FromDouble((double)PyArray_DIM(arr,axis)); |
| 730 | Py_DECREF(arr); |
| 731 | if (obj1 == NULL || obj2 == NULL) { |
| 732 | Py_XDECREF(obj1); |
| 733 | Py_XDECREF(obj2); |
| 734 | return NULL; |
| 735 | } |
| 736 | if (!out) { |
| 737 | ret = PyNumber_TrueDivide(obj1, obj2); |
| 738 | } |
| 739 | else { |
| 740 | ret = PyObject_CallFunction(n_ops.divide, "OOO", out, obj2, out); |
| 741 | } |
| 742 | Py_DECREF(obj1); |
| 743 | Py_DECREF(obj2); |
| 744 | return ret; |
| 745 | } |
| 746 | |
| 747 | /*NUMPY_API |
| 748 | * Any |
no test coverage detected