From 37327f3cb970eeedce33bdbd6efc0d35ee0856b6 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Thu, 15 Mar 2018 13:04:40 +0100 Subject: fixes #10747 --- numpy/add_newdocs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 38da1f0b3..535b372f9 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3060,8 +3060,10 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('size', """ Number of elements in the array. - Equivalent to ``np.prod(a.shape)``, i.e., the product of the array's - dimensions. + Equal to ``np.prod(a.shape)``, i.e., the product of the array's + dimensions, except that ``size`` returns an instance of ``int`` + whereas ``np.prod(a.shape)`` returns an instance of ``np.int_`` + (e.g. ``np.int64``). Examples -------- -- cgit v1.2.1 From 4bbf48255a3cbd8a4c707867818d0277437bf202 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Thu, 15 Mar 2018 14:13:07 +0100 Subject: Update add_newdocs.py --- numpy/add_newdocs.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 535b372f9..6d0cfb594 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3061,9 +3061,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('size', Number of elements in the array. Equal to ``np.prod(a.shape)``, i.e., the product of the array's - dimensions, except that ``size`` returns an instance of ``int`` - whereas ``np.prod(a.shape)`` returns an instance of ``np.int_`` - (e.g. ``np.int64``). + dimensions. Examples -------- @@ -3072,6 +3070,14 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('size', 30 >>> np.prod(x.shape) 30 + + Notes + ----- + `a.size` returns a standard arbitrary precision Python integer. This + may not be the case with other methods of obtaining the same value + (like the suggested ``np.prod(a.shape)``, which returns an instance + of ``np.int_``), and may be relevant if the value is used further in + calculations that may overflow a fixed size integer type. """)) -- cgit v1.2.1 From 626d20ed537b333e39b62c337de431f8d3ee4df5 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Thu, 15 Mar 2018 15:00:43 +0100 Subject: fixed order of notes and examples --- numpy/add_newdocs.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 6d0cfb594..316b38e77 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3063,14 +3063,6 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('size', Equal to ``np.prod(a.shape)``, i.e., the product of the array's dimensions. - Examples - -------- - >>> x = np.zeros((3, 5, 2), dtype=np.complex128) - >>> x.size - 30 - >>> np.prod(x.shape) - 30 - Notes ----- `a.size` returns a standard arbitrary precision Python integer. This @@ -3079,6 +3071,14 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('size', of ``np.int_``), and may be relevant if the value is used further in calculations that may overflow a fixed size integer type. + Examples + -------- + >>> x = np.zeros((3, 5, 2), dtype=np.complex128) + >>> x.size + 30 + >>> np.prod(x.shape) + 30 + """)) -- cgit v1.2.1