[Numpy-discussion] array indexing question

Nathaniel Smith njs at pobox.com
Tue Oct 14 15:44:00 EDT 2014


For this to work at all you have to know a priori that there are the same
number of non-zero entries in each row of your mask. Given that you know
that, isn't it just a matter of calling reshape on the second array?
On 14 Oct 2014 20:37, "Neal Becker" <ndbecker2 at gmail.com> wrote:

> I'm using np.nonzero to construct the tuple:
> (array([0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]), array([1, 3, 5, 7, 2, 3, 6,
> 7, 4,
> 5, 6, 7]))
>
> Now what I want is the 2-D index array:
>
> [1,3,5,7,
> 2,3,6,7,
> 4,5,6,7]
>
> Any ideas?
>
> --
> -- Those who don't understand recursion are doomed to repeat it
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141014/0fad9e5b/attachment.html>


More information about the NumPy-Discussion mailing list