[Numpy-discussion] nonzero() behaviour has changed
Ed Schofield
schofield at ftw.at
Thu May 18 10:17:15 EDT 2006
Bill Baxter wrote:
> On 5/18/06, *Ed Schofield* <schofield at ftw.at
> <mailto:schofield at ftw.at>> wrote:
>
> Bill Baxter wrote:
> > Sure would be nice if all you had to type was a.nonzero().T,
> though... ;-P
>
> No, this wouldn't be possible -- the output of the nonzero method is a
> tuple, not an array. Perhaps this is why it's not _that_ obvious ;)
>
>
> Oh, I see. I did miss that bit. I think I may have even done
> something recently myself like
> vstack(where(a > val)).transpose()
> not realizing that plain old transpose() would work in place of
> vstack(xxx).transpose().
>
> If you feel like copy-pasting your doc addition for nonzero() over to
> where() also, that would be nice.
Okay, done.
> What other functions work like that? ... <me rummages around a
> little> ... actually it looks like most other functions similar to
> nonzero() return a boolean array, then you use where() if you need an
> index list. isnan(), iscomplex(), isinf(), isreal(), isneginf(), etc
> and of course all the boolean operators like a>0. So nonzero() is
> kind of an oddball. Is it actually any different from where(a!=0)?
I think it's equivalent, only slightly more efficient...
-- Ed
More information about the NumPy-Discussion
mailing list