"""Module interpolating mathematical functions out of support points"""

from scipy.interpolate import interp1d, lagrange, CubicSpline


def interpolator(x_sup, y_sup, method):
    """Interpolates a mathematical function from a given set of
    points using either linear, polynomial or cubic spline for the
    interpolation.

    Args:
        x_sup (list): x-coordinates of the function
        y_sup (list): y-coordinates of the function
        method (string): name of the interpolation method to be used

    Returns:
        intfunc: interpolated function
    """

    if method == "linear":
        intfunc = interp1d(x_sup, y_sup, kind="linear")
        return intfunc
    elif method == "polynomial":
        intfunc = lagrange(x_sup, y_sup)
        return intfunc
    elif method == "cspline":
        intfunc = CubicSpline(x_sup, y_sup, bc_type="natural")
        return intfunc

    return None

[((21, 18, 21, 55), 'scipy.interpolate.interp1d', 'interp1d', (), '', False, 'from scipy.interpolate import interp1d, lagrange, CubicSpline\n'), ((24, 18, 24, 40), 'scipy.interpolate.lagrange', 'lagrange', ({(24, 27, 24, 32): 'x_sup', (24, 34, 24, 39): 'y_sup'}, {}), '(x_sup, y_sup)', False, 'from scipy.interpolate import interp1d, lagrange, CubicSpline\n'), ((27, 18, 27, 62), 'scipy.interpolate.CubicSpline', 'CubicSpline', (), '', False, 'from scipy.interpolate import interp1d, lagrange, CubicSpline\n')]