[Numpy-discussion] Numpy where

Charles R Harris charlesr.harris at gmail.com
Fri Mar 13 16:09:48 EDT 2015

On Fri, Mar 13, 2015 at 1:26 PM, Nathaniel Smith <njs at pobox.com> wrote:

> On Thu, Mar 12, 2015 at 9:35 PM, Benjamin Root <ben.root at ou.edu> wrote:
> > I think the question is if scalars should be acceptable for the first
> > argument, not if it should be for the 2nd and 3rd argument.
> >
> > If scalar can be given for the first argument, the the first three makes
> > sense. Although, I have no clue why we would allow that.
> Why wouldn't we? The where function takes three arguments which are
> broadcast against each other, so disallowing scalars would require
> adding a special case.

I'm coming to the conclusion that only #4 is incorrect. The process seems
to go: cast scalars to 1-D arrays (hence #1 and #3), and indexing results
in #2.

The oddity is that the second and third arguments are optional, and the
action of the function depends on that. I would have made those arguments
required as omitting them gives the same as a call to nonzero. But things
are as they are...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150313/4c11154c/attachment.html>

More information about the NumPy-Discussion mailing list