Yeah, I suspect this change is probably fine but I haven't wrapped my head
around that complex conditional...


On Sun, Aug 18, 2013 at 5:01 PM, Charles Harris <notifications@github.com>wrote:

> In numpy/lib/function_base.py:
>
> > @@ -674,20 +674,13 @@ def piecewise(x, condlist, funclist, *args, **kw):
> >      x = asanyarray(x)
> >      n2 = len(funclist)
> >      if isscalar(condlist) or \
> > -           not (isinstance(condlist[0], list) or
> > -                isinstance(condlist[0], ndarray)):
> > +            (isinstance(condlist, np.ndarray) and condlist.ndim == 0) or \
>
> This changes the behavior and needs to be documented. I've also looked at
> the following version:
>
>     def isscalarlike(a):
>         return isscalar(a) or (isinstance(a, np.ndarray) and a.ndim == 0)
>
>     x = asanyarray(x)
>     n2 = len(funclist)
>     if isscalarlike(condlist) or (x.ndim > 0 and isscalarlike(a[0])):
>         condlist = [condlist]
>
> Which is a bit different again, but clearer I think.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/numpy/numpy/pull/331/files#r5831760>
> .
>