From 8284c9cfdf153e6f51cad48b4abdb7519e5e5274 Mon Sep 17 00:00:00 2001 From: Stefan Otte Date: Sun, 10 May 2015 14:21:26 +0200 Subject: DOC: sum/prod & empty array returns neutral elment --- numpy/core/fromnumeric.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'numpy/core/fromnumeric.py') diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 549647df2..778cef204 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1770,6 +1770,11 @@ def sum(a, axis=None, dtype=None, out=None, keepdims=False): Arithmetic is modular when using integer types, and no error is raised on overflow. + The sum of an empty array is the neutral element 0: + + >>> np.sum([]) + 0.0 + Examples -------- >>> np.sum([0.5, 1.5]) @@ -2413,6 +2418,11 @@ def prod(a, axis=None, dtype=None, out=None, keepdims=False): >>> np.prod(x) #random 16 + The product of an empty array is the neutral element 1: + + >>> np.prod([]) + 1.0 + Examples -------- By default, calculate the product of all elements: -- cgit v1.2.1