[Numpy-discussion] Non-Zero Sub-Matrix

Pauli Virtanen pav@iki...
Fri Sep 10 07:38:12 CDT 2010


Fri, 10 Sep 2010 14:35:46 +0200, Radek Machulka wrote:

> Thanks, but...
> 
>>>> x = array([[0,0,0,0],[0,1,0,0],[0,0,1,1],[0,0,0,0]]) x
> array([[0, 0, 0, 0],
>        [0, 1, 0, 0],
>        [0, 0, 1, 1],
>        [0, 0, 0, 0]])
>>>> i, j = x.any(0).nonzero()[0], x.any(1).nonzero()[0] 

Should be 

>>> j, i = x.any(0).nonzero()[0], x.any(1).nonzero()[0] 



More information about the NumPy-Discussion mailing list