diff options
author | Bharat Raghunathan <bharatraghunthan9767@gmail.com> | 2020-02-02 08:25:02 +0530 |
---|---|---|
committer | Bharat Raghunathan <bharatraghunthan9767@gmail.com> | 2020-02-02 08:25:02 +0530 |
commit | ef5675b04d159e3446a4f68785a435d72931ea15 (patch) | |
tree | 2a1fed78f41608f829de9f7b83739afaac9f9be3 /numpy/core/fromnumeric.py | |
parent | a77e4a0b9f42bcc414a3e5bfae1ab5eaae42c3f2 (diff) | |
download | numpy-ef5675b04d159e3446a4f68785a435d72931ea15.tar.gz |
Updated statement and example according to review comments
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 2c011c2a7..13ae532c5 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1438,16 +1438,15 @@ def squeeze(a, axis=None): Selects a subset of the single-dimensional entries in the shape. If an axis is selected with shape entry greater than - one, an error is raised. Note that when applied to an array - `a` with one element and no axis argument, it returns a - wrapped scalar of no shape containing the element in `a`. + one, an error is raised. Returns ------- squeezed : ndarray The input array, but with all or a subset of the dimensions of length 1 removed. This is always `a` itself - or a view into `a`. + or a view into `a`.Note that if all axes are squeezed, + the result is a 0d array and not a scalar. Raises ------ @@ -1481,10 +1480,8 @@ def squeeze(a, axis=None): array(1234) # 0d array >>> np.squeeze(x).shape () - >>> np.squeeze(x)[0] - Traceback (most recent call last): - ... - IndexError: too many indices for array + >>> np.squeeze(x)[()] + 1234 """ try: |