import math


def _neq_per_residue(row_freq):
    """
    Compute the Neq of a vector of frequencies coresponding to one residue.
    The vector is a row of the frequency matrix.
    This function is intended to be called from the `numpy.apply_along_axis` function.

    Parameters
    ----------
    row_freq : 1D numpy array
        vector of frequencies

    Return
    ------
        The value of the Neq
    """

    H = sum([math.log(freq)*freq for freq in row_freq if freq != 0])

    return math.exp(-H)