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 | |
| 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')
| -rw-r--r-- | numpy/lib/function_base.py | 8 | ||||
| -rw-r--r-- | numpy/lib/nanfunctions.py | 5 |
2 files changed, 4 insertions, 9 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 diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py index 1e342b932..6bd949b34 100644 --- a/numpy/lib/nanfunctions.py +++ b/numpy/lib/nanfunctions.py @@ -1123,10 +1123,7 @@ def nanpercentile(a, q, axis=None, out=None, overwrite_input=False, overwrite_input=overwrite_input, interpolation=interpolation) if keepdims and keepdims is not np._NoValue: - if q.ndim == 0: - return r.reshape(k) - else: - return r.reshape([len(q)] + k) + return r.reshape(q.shape + k) else: return r |
