From cde76b4d11a580e6d25eebdcce373bc5d8c850f5 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Tue, 13 Nov 2012 00:20:24 +0100 Subject: 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. --- numpy/core/fromnumeric.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'numpy/core/fromnumeric.py') 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 -- cgit v1.2.1