can np.where(cond, x, y) be implemented as select?
might be worth it as np.where is rather slow and this function becomes blazingly fast if we vectorize count_nonzero_booleans in the fancy indexing below.