You have already computed `std_dev == 0` above, so this line could be `std_dev[zero_std_mask] = 1.0`.