peng/wave_functions.py
def wvalue(wave, indep_var):
    r"""
    Return the dependent variable value at a given independent variable point.

    If the independent variable point is not in the independent variable vector
    the dependent variable value is obtained by linear interpolation

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param indep_var: Independent variable point for which the dependent
                      variable is to be obtained
    :type  indep_var: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.wvalue

    :raises:
     * RuntimeError (Argument \`indep_var\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * ValueError (Argument \`indep_var\` is not in the independent
       variable vector range)

    .. [[[end]]]
    """
    close_min = np.isclose(indep_var, wave._indep_vector[0], FP_RTOL, FP_ATOL)
    close_max = np.isclose(indep_var, wave._indep_vector[-1], FP_RTOL, FP_ATOL)
    pexdoc.exh.addex(
        ValueError,
        "Argument `indep_var` is not in the independent variable vector range",
        bool(
            ((indep_var < wave._indep_vector[0]) and (not close_min))
            or ((indep_var > wave._indep_vector[-1]) and (not close_max))
        ),
    )
    if close_min:
        return wave._dep_vector[0]
    if close_max:
        return wave._dep_vector[-1]
    idx = np.searchsorted(wave._indep_vector, indep_var)
    xdelta = wave._indep_vector[idx] - wave._indep_vector[idx - 1]
    ydelta = wave._dep_vector[idx] - wave._dep_vector[idx - 1]
    slope = ydelta / float(xdelta)
    return wave._dep_vector[idx - 1] + slope * (indep_var - wave._indep_vector[idx - 1])
def wvalue(wave, indep_var):
    r"""
    Return the dependent variable value at a given independent variable point.

    If the independent variable point is not in the independent variable vector
    the dependent variable value is obtained by linear interpolation

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param indep_var: Independent variable point for which the dependent
                      variable is to be obtained
    :type  indep_var: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.wvalue

    :raises:
     * RuntimeError (Argument \`indep_var\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * ValueError (Argument \`indep_var\` is not in the independent
       variable vector range)

    .. [[[end]]]
    """
    close_min = np.isclose(indep_var, wave._indep_vector[0], FP_RTOL, FP_ATOL)
    close_max = np.isclose(indep_var, wave._indep_vector[-1], FP_RTOL, FP_ATOL)
    pexdoc.exh.addex(
        ValueError,
        "Argument `indep_var` is not in the independent variable vector range",
        bool(
            ((indep_var < wave._indep_vector[0]) and (not close_min))
            or ((indep_var > wave._indep_vector[-1]) and (not close_max))
        ),
    )
    if close_min:
        return wave._dep_vector[0]
    if close_max:
        return wave._dep_vector[-1]
    idx = np.searchsorted(wave._indep_vector, indep_var)
    xdelta = wave._indep_vector[idx] - wave._indep_vector[idx - 1]
    ydelta = wave._dep_vector[idx] - wave._dep_vector[idx - 1]
    slope = ydelta / float(xdelta)
    return wave._dep_vector[idx - 1] + slope * (indep_var - wave._indep_vector[idx - 1])
r"""
    Return the dependent variable value at a given independent variable point.

    If the independent variable point is not in the independent variable vector
    the dependent variable value is obtained by linear interpolation

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param indep_var: Independent variable point for which the dependent
                      variable is to be obtained
    :type  indep_var: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.wvalue

    :raises:
     * RuntimeError (Argument \`indep_var\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * ValueError (Argument \`indep_var\` is not in the independent
       variable vector range)

    .. [[[end]]]