can't all this be done with ``numpy.where``?