diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2012-11-13 00:20:24 +0100 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2013-01-06 16:14:00 +0100 |
commit | cde76b4d11a580e6d25eebdcce373bc5d8c850f5 (patch) | |
tree | f7e2f8a91738ad2faacd36ccf5e85ec2345f5ea9 /numpy/core/fromnumeric.py | |
parent | 161bfe73e006af7c71db373aa99bdecce32f9e2a (diff) | |
download | numpy-cde76b4d11a580e6d25eebdcce373bc5d8c850f5.tar.gz |
ENH: Allow 0-d indexes in np.take
The TakeFrom already supported this. This removes the check which
made it not possible and adds some tests for take.
Also add documentation and information to the release notes.
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index d73f1313c..7596e3707 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -57,6 +57,10 @@ def take(a, indices, axis=None, out=None, mode='raise'): The source array. indices : array_like The indices of the values to extract. + + .. versionadded:: 1.8.0 + + Also allow scalars for indices. axis : int, optional The axis over which to select values. By default, the flattened input array is used. @@ -96,6 +100,11 @@ def take(a, indices, axis=None, out=None, mode='raise'): >>> a[indices] array([4, 3, 6]) + If `indices` is not one dimensional, the output also has these dimensions. + + >>> np.take(a, [[0, 1], [2, 3]]) + array([[4, 3], + [5, 7]]) """ try: take = a.take |