def vector_unit_nullnull(v):
    """Return unit vectors.
    Any null vectors remain null vectors.

    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] /= mag[mag > 0.0][..., np.newaxis]
    return v_new
def vector_unit_nullnull ( v ) : if v . size == 0 : return v mag = vector_mag ( v ) v_new = v . copy ( ) v_new [ mag > 0.0 ] /= mag [ mag > 0.0 ] [ ... , np . newaxis ] return v_new
Return unit vectors.
    Any null vectors remain null vectors.

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

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