[Numpy-discussion] Use-case for np.choose
David Goldsmith
d.l.goldsmith@gmail....
Sat Nov 7 18:53:13 CST 2009
Thanks, Anne.
On Sat, Nov 7, 2009 at 1:32 PM, Anne Archibald <peridot.faceted@gmail.com>wrote:
> 2009/11/7 David Goldsmith <d.l.goldsmith@gmail.com>:
<snip>
> > Also, my experimenting suggests that the index array ('a', the first
> > argument in the func. sig.) *must* have shape (choices.shape[-1],) -
> someone
> > please let me know ASAP if this is not the case, and please furnish me w/
> a
> > counterexample because I was unable to generate one myself.
>
> It seems like a and each of the choices must have the same shape
So in essence, at least as it presently functions, the shape of 'a'
*defines* what the individual choices are within 'choices`, and if 'choices'
can't be parsed into an integer number of such individual choices, that's
when an exception is raised?
> (with
>
the exception that choices acn be scalars), but I would consider this
> a bug.
OK, then we definitely need more people to opine on this, because, if the
the two don't match, our established policy is to document *desired*
behavior, not extant behavior (and file a bug ticket).
> Really, a and all the choices should be broadcast to the same
> shape. Or maybe it doesn't make sense to broadcast a - it could be
>
Thus begging the question: does anyone actually have an extant, specific
use-case?
> valuable to know that the result is always exactly the same shape as a
> - but broadcasting all the choice arrays presents an important
> improvement of choose over fancy indexing.
Then perhaps we need either another function, or a flag specifying which
behavior this one should exhibit.
> There's a reason choose
> accepts a sequence of arrays as its second argument, rather than a
> higher-dimensional array.
>
And that reason is probably supposed to be transparent above, but I've
confused it by this point, so can you please reiterate it here, in so many
words. :-)
Thanks again,
DG
>
> Anne
>
> > Thanks,
> >
> > DG
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion@scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> >
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091107/d3a6cda3/attachment.html
More information about the NumPy-Discussion
mailing list