From 775a47de7e2f4b039592d614e7ac3fda464975a8 Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Tue, 29 Aug 2006 10:28:11 +0000 Subject: Add axis arguments to various functions so as not to rely on the defaults. --- numpy/lib/function_base.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index d8cd30f2c..a202f67cb 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -108,17 +108,16 @@ def average(a, axis=None, weights=None, returned=False): """average(a, axis=None weights=None, returned=False) Average the array over the given axis. If the axis is None, average - over all dimensions of the array. Equivalent to a.mean(axis), but - with a default axis of 0 instead of None. + over all dimensions of the array. Equivalent to a.mean(axis) If an integer axis is given, this equals: a.sum(axis) * 1.0 / len(a) If axis is None, this equals: - a.sum(axis) * 1.0 / product(a.shape) + a.sum(axis) * 1.0 / product(a.shape,axis=0) If weights are given, result is: - sum(a * weights) / sum(weights), + sum(a * weights,axis) / sum(weights,axis), where the weights must have a's shape or be 1D with length the size of a in the given axis. Integer weights are converted to Float. Not specifying weights is equivalent to specifying @@ -541,9 +540,9 @@ def extract(condition, arr): """Return the elements of ravel(arr) where ravel(condition) is True (in 1D). - Equivalent to compress(ravel(condition), ravel(arr)). + Equivalent to compress(ravel(condition), ravel(arr),0). """ - return _nx.take(ravel(arr), nonzero(ravel(condition))[0]) + return _nx.take(ravel(arr), nonzero(ravel(condition))[0],axis=0) def place(arr, mask, vals): """Similar to putmask arr[mask] = vals but the 1D array vals has the -- cgit v1.2.1