Return unit vectors.
    Any null vectors are mapped to a uniformly picked unit vector.

    Parameters
    ----------
    v: array, shape (a1, a2, ..., d)
        Cartesian vectors, with last axis indexing the dimension.

    Returns
    -------
    v_new: array, shape of v

def vector_unit_nullrand(v, rng=None):
    """Return unit vectors.
    Any null vectors are mapped to a uniformly picked unit vector.

    Parameters
    ----------
    v: array, shape (a1, a2, ..., d)
        Cartesian vectors, with last axis indexing the dimension.

    Returns
    -------
    v_new: array, shape of v
    """
    if v.size == 0:
        return v
    mag = vector_mag(v)
    v_new = v.copy()
    v_new[mag == 0.0] = sphere_pick(v.shape[-1], (mag == 0.0).sum(), rng)
    v_new[mag > 0.0] /= mag[mag > 0.0][..., np.newaxis]
    return v_new