@pexdoc.pcontracts.contract(<EOL>wave=Waveform,<EOL>dep_var="<STR_LIT>",<EOL>der="<STR_LIT>",<EOL>inst="<STR_LIT>",<EOL>indep_min="<STR_LIT>",<EOL>indep_max="<STR_LIT>",<EOL>)<EOL>def find(wave, dep_var, der=None, inst=<NUM_LIT:1>, indep_min=None, indep_max=None):
<EOL>ret = copy.copy(wave)<EOL>_bound_waveform(ret, indep_min, indep_max)<EOL>close_min = np.isclose(min(ret._dep_vector), dep_var, FP_RTOL, FP_ATOL)<EOL>close_max = np.isclose(max(ret._dep_vector), dep_var, FP_RTOL, FP_ATOL)<EOL>if ((np.amin(ret._dep_vector) > dep_var) and (not close_min)) or (<EOL>(np.amax(ret._dep_vector) < dep_var) and (not close_max)<EOL>):<EOL><INDENT>return None<EOL><DEDENT>cross_wave = ret._dep_vector - dep_var<EOL>sign_wave = np.sign(cross_wave)<EOL>exact_idx = np.where(np.isclose(ret._dep_vector, dep_var, FP_RTOL, FP_ATOL))[<NUM_LIT:0>]<EOL>left_idx = np.where(np.diff(sign_wave))[<NUM_LIT:0>]<EOL>left_idx = np.setdiff1d(left_idx, exact_idx)<EOL>left_idx = np.setdiff1d(left_idx, exact_idx - <NUM_LIT:1>)<EOL>right_idx = left_idx + <NUM_LIT:1> if left_idx.size else np.array([])<EOL>indep_var = ret._indep_vector[exact_idx] if exact_idx.size else np.array([])<EOL>dvector = np.zeros(exact_idx.size).astype(int) if exact_idx.size else np.array([])<EOL>if left_idx.size and (ret.interp == "<STR_LIT>"):<EOL><INDENT>idvector = (<EOL><NUM_LIT> * (ret._dep_vector[right_idx] > ret._dep_vector[left_idx]).astype(int)<EOL>- <NUM_LIT:1><EOL>)<EOL>if indep_var.size:<EOL><INDENT>indep_var = np.concatenate((indep_var, ret._indep_vector[right_idx]))<EOL>dvector = np.concatenate((dvector, idvector))<EOL>sidx = np.argsort(indep_var)<EOL>indep_var = indep_var[sidx]<EOL>dvector = dvector[sidx]<EOL><DEDENT>else:<EOL><INDENT>indep_var = ret._indep_vector[right_idx]<EOL>dvector = idvector<EOL><DEDENT><DEDENT>elif left_idx.size:<EOL><INDENT>y_left = ret._dep_vector[left_idx]<EOL>y_right = ret._dep_vector[right_idx]<EOL>x_left = ret._indep_vector[left_idx]<EOL>x_right = ret._indep_vector[right_idx]<EOL>slope = ((y_left - y_right) / (x_left - x_right)).astype(float)<EOL>if indep_var.size:<EOL><INDENT>indep_var = np.concatenate(<EOL>(indep_var, x_left + ((dep_var - y_left) / slope))<EOL>)<EOL>dvector = np.concatenate((dvector, np.where(slope > <NUM_LIT:0>, <NUM_LIT:1>, -<NUM_LIT:1>)))<EOL>sidx = np.argsort(indep_var)<EOL>indep_var = indep_var[sidx]<EOL>dvector = dvector[sidx]<EOL><DEDENT>else:<EOL><INDENT>indep_var = x_left + ((dep_var - y_left) / slope)<EOL>dvector = np.where(slope > <NUM_LIT:0>, +<NUM_LIT:1>, -<NUM_LIT:1>)<EOL><DEDENT><DEDENT>if der is not None:<EOL><INDENT>indep_var = np.extract(dvector == der, indep_var)<EOL><DEDENT>return indep_var[inst - <NUM_LIT:1>] if inst <= indep_var.size else None<EOL>
r"""
    Return the independent variable point associated with a dependent variable point.

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

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

    :param dep_var: Dependent vector value to search for
    :type  dep_var: integer, float or complex

    :param der: Dependent vector derivative filter. If +1 only independent
                vector points that have positive derivatives when crossing
                the requested dependent vector point are returned; if -1 only
                independent vector points that have negative derivatives when
                crossing the requested dependent vector point are returned;
                if 0 only independent vector points that have null derivatives
                when crossing the requested dependent vector point are
                returned; otherwise if None all independent vector points are
                returned regardless of the dependent vector derivative. The
                derivative of the first and last point of the waveform is
                assumed to be null
    :type  der: integer, float or complex

    :param inst: Instance number filter. If, for example, **inst** equals 3,
                 then the independent variable vector point at which the
                 dependent variable vector equals the requested value for the
                 third time is returned
    :type  inst: positive integer

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :rtype: integer, float or None if the dependent variable point is not found

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.find

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

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

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

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

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

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

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

    .. [[[end]]]