Would like to build a list of indices into a 2 dimensional bool_ array, where True.
import numpy
arr = numpy.zeros((6,6), numpy.bool_)
arr[2,3] = True
arr[5,1] = True
results1 = [[(x,y) for (y,cell) in enumerate(arr[x].flat) if cell] for x in xrange(6)]
results2 = [(x,y) for (y,cell) in enumerate(arr[x].flat) if cell for x in xrange(6)]
results 1:
[[], [], [(2, 3)], [], [], [(5, 1)]]
results 2 is completely wrong
Goal:
[(2, 3),(5, 1)]
Any way to do this without flattening the list afterwards, or any better way to do this in general?