summaryrefslogtreecommitdiff
path: root/numpy/lib/shape_base.py
diff options
context:
space:
mode:
authorDavid Linke <dalito@users.noreply.github.com>2017-10-28 13:52:15 +0200
committerDavid Linke <dalito@users.noreply.github.com>2017-10-28 14:01:27 +0200
commit21de6c1b946e2a714a045ec8ab5e28e36f7e4977 (patch)
treec8c03f2a463915ceba8cfa9f6a397ac4810e3c42 /numpy/lib/shape_base.py
parent1e494f1e283340d545b1c7c15dded04a4aaae939 (diff)
downloadnumpy-21de6c1b946e2a714a045ec8ab5e28e36f7e4977.tar.gz
Clarify docstring for numpy.array_split
Before this addition, people could expect that only the last sub-array would have a different size. The added documentation and example make clear what the function really does.
Diffstat (limited to 'numpy/lib/shape_base.py')
-rw-r--r--numpy/lib/shape_base.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index deab938ea..a8977bd4c 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -421,7 +421,9 @@ def array_split(ary, indices_or_sections, axis=0):
Please refer to the ``split`` documentation. The only difference
between these functions is that ``array_split`` allows
`indices_or_sections` to be an integer that does *not* equally
- divide the axis.
+ divide the axis. For an array of length l that should be split
+ into n sections, it returns l % n sub-arrays of size l//n + 1
+ and the rest of size l//n.
See Also
--------
@@ -433,6 +435,10 @@ def array_split(ary, indices_or_sections, axis=0):
>>> np.array_split(x, 3)
[array([ 0., 1., 2.]), array([ 3., 4., 5.]), array([ 6., 7.])]
+ >>> x = np.arange(7.0)
+ >>> np.array_split(x, 3)
+ [array([ 0., 1., 2.]), array([ 3., 4.]), array([ 5., 6.])]
+
"""
try:
Ntotal = ary.shape[axis]