summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime <jaime.frio@gmail.com>2018-03-15 15:43:41 (GMT)
committerGitHub <noreply@github.com>2018-03-15 15:43:41 (GMT)
commit63d50a6516b5209164561cf91afc4944c88e0bf0 (patch)
tree7db411b2fb514ab74a5a08441a2a12f58352aafe
parent020f2ad4e133b7500c7062d89368d38f19e836fd (diff)
parent626d20ed537b333e39b62c337de431f8d3ee4df5 (diff)
downloadpython-numpy-63d50a6516b5209164561cf91afc4944c88e0bf0.zip
python-numpy-63d50a6516b5209164561cf91afc4944c88e0bf0.tar.gz
python-numpy-63d50a6516b5209164561cf91afc4944c88e0bf0.tar.bz2
Merge pull request #10748 from jonasrauber/patch-1
DOC: a.size and np.prod(a.shape) are not equivalent
-rw-r--r--numpy/add_newdocs.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
index 38da1f0..316b38e 100644
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -3060,9 +3060,17 @@ 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
+ Equal to ``np.prod(a.shape)``, i.e., the product of the array's
dimensions.
+ 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.
+
Examples
--------
>>> x = np.zeros((3, 5, 2), dtype=np.complex128)