diff options
author | Julian Taylor <juliantaylor108@gmail.com> | 2017-06-03 13:22:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-03 13:22:13 +0200 |
commit | 0e4610e30aabaf32c037fc94c869a20f2435a8f1 (patch) | |
tree | 5eae05250799d873fca5b8d1c0503ba1c204ff66 /numpy/lib/function_base.py | |
parent | ecab1ff2b77b06e0fcbbfafd26d80aef486f74b8 (diff) | |
parent | ad1e3c118f378fd62883655a9a983dd0c682f968 (diff) | |
download | numpy-0e4610e30aabaf32c037fc94c869a20f2435a8f1.tar.gz |
Merge pull request #9212 from eric-wieser/tidy-function_base
MAINT: Combine similar branches
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 1418baa77..6dddbc11b 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -3997,8 +3997,9 @@ def _ureduce(a, func, **kwargs): # merge reduced axis a = a.reshape(a.shape[:nkeep] + (-1,)) kwargs['axis'] = -1 + keepdim = tuple(keepdim) else: - keepdim = [1] * a.ndim + keepdim = (1,) * a.ndim r = func(a, **kwargs) return r, keepdim @@ -4260,10 +4261,7 @@ def percentile(a, q, axis=None, out=None, overwrite_input=overwrite_input, interpolation=interpolation) if keepdims: - if q.ndim == 0: - return r.reshape(k) - else: - return r.reshape([len(q)] + k) + return r.reshape(q.shape + k) else: return r |