diff options
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 8ee6a54dd..1418baa77 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1321,16 +1321,8 @@ def piecewise(x, condlist, funclist, *args, **kw): x = x[None] zerod = True if n == n2 - 1: # compute the "otherwise" condition. - totlist = np.logical_or.reduce(condlist, axis=0) - # Only able to stack vertically if the array is 1d or less - if x.ndim <= 1: - condlist = np.vstack([condlist, ~totlist]) - else: - condlist = [asarray(c, dtype=bool) for c in condlist] - totlist = condlist[0] - for k in range(1, n): - totlist |= condlist[k] - condlist.append(~totlist) + condelse = ~np.any(condlist, axis=0, keepdims=True) + condlist = np.concatenate([condlist, condelse], axis=0) n += 1 y = zeros(x.shape, x.dtype) @@ -2982,7 +2974,7 @@ def cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, >>> x = [-2.1, -1, 4.3] >>> y = [3, 1.1, 0.12] - >>> X = np.vstack((x,y)) + >>> X = np.stack((x, y), axis=0) >>> print(np.cov(X)) [[ 11.71 -4.286 ] [ -4.286 2.14413333]] @@ -3020,7 +3012,7 @@ def cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, y = array(y, copy=False, ndmin=2, dtype=dtype) if not rowvar and y.shape[0] != 1: y = y.T - X = np.vstack((X, y)) + X = np.concatenate((X, y), axis=0) if ddof is None: if bias == 0: |