make sure numpy.nonzero returns tuples with length > 0 before numpy.vstack