(x, xp, fp, left=None, right=None)
return fx
Like numpy.interp except for handling of running sequences of
    same values in `xp`.
Like numpy.interp except for handling of running sequences of
    same values in `xp`.
Like numpy . interp except for handling of running sequences of same values in xp .
def interp(x, xp, fp, left=None, right=None):
    """
    Like numpy.interp except for handling of running sequences of
    same values in `xp`.
    """
    x = np.asanyarray(x)
    xp = np.asanyarray(xp)
    fp = np.asanyarray(fp)

    if xp.shape != fp.shape:
        raise ValueError("xp and fp must have the same shape")

    ind = np.searchsorted(xp, x, side="right")
    fx = np.zeros(len(x))

    under = ind == 0
    over = ind == len(xp)
    between = ~under & ~over

    fx[under] = left if left is not None else fp[0]
    fx[over] = right if right is not None else fp[-1]

    if right is not None:
        # Fix points exactly on the right boundary.
        fx[x == xp[-1]] = fp[-1]

    ind = ind[between]

    df = (fp[ind] - fp[ind - 1]) / (xp[ind] - xp[ind - 1])

    fx[between] = df * (x[between] - xp[ind]) + fp[ind]

    return fx
def interp ( x , xp , fp , left = None , right = None ) : x = np . asanyarray ( x ) xp = np . asanyarray ( xp ) fp = np . asanyarray ( fp ) if xp . shape != fp . shape : raise ValueError ( "xp and fp must have the same shape" ) ind = np . searchsorted ( xp , x , side = "right" ) fx = np . zeros ( len ( x ) ) under = ind == 0 over = ind == len ( xp ) between = ~ under & ~ over fx [ under ] = left if left is not None else fp [ 0 ] fx [ over ] = right if right is not None else fp [ - 1 ] if right is not None : # Fix points exactly on the right boundary. fx [ x == xp [ - 1 ] ] = fp [ - 1 ] ind = ind [ between ] df = ( fp [ ind ] - fp [ ind - 1 ] ) / ( xp [ ind ] - xp [ ind - 1 ] ) fx [ between ] = df * ( x [ between ] - xp [ ind ] ) + fp [ ind ] return fx