[PYTHON MATRIX-SIG] Find/where function
Jim Hugunin
hugunin@mit.edu
Mon, 28 Oct 1996 13:05:37 -0500
> I would like to see the following convenience function added for
> returning the indices of nonzero array elements. I would prefer to
> call this "where" instead of "find" but "where" is already taken.
>
> def find(a):
> return compress(a.flat,arange(product(a.shape)))
>
> Example,
>
> b = reshape(arange(24),(2,3,4))
> find(b%2)
This is almost equivalent to the current behavior of nonzero (the only
difference is that your version works on non-flattened arrays). I'm a
little bit confused as to how this can possibly make sense for
multi-dimensional arrays, but if it does, I think it should involve an
extension of the existing nonzero function, rather than adding a new
function.
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================