[Numpy-discussion] Use-case for np.choose
Sat Nov 7 18:53:13 CST 2009
On Sat, Nov 7, 2009 at 1:32 PM, Anne Archibald <firstname.lastname@example.org>wrote:
> 2009/11/7 David Goldsmith <email@example.com>:
> > Also, my experimenting suggests that the index array ('a', the first
> > argument in the func. sig.) *must* have shape (choices.shape[-1],) -
> > please let me know ASAP if this is not the case, and please furnish me w/
> > 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?
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
> 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
> > Thanks,
> > DG
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion@scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion