def _get_interpolator(method, vectorizeable_only=False, **kwargs):
    '''helper function to select the appropriate interpolator class

    returns interpolator class and keyword arguments for the class
    '''
    interp1d_methods = ['linear', 'nearest', 'zero', 'slinear', 'quadratic',
                        'cubic', 'polynomial']
    valid_methods = interp1d_methods + ['barycentric', 'krog', 'pchip',
                                        'spline', 'akima']

    has_scipy = True
    try:
        from scipy import interpolate
    except ImportError:
        has_scipy = False

    # prioritize scipy.interpolate
    if (method == 'linear' and not
            kwargs.get('fill_value', None) == 'extrapolate' and
            not vectorizeable_only):
        kwargs.update(method=method)
        interp_class = NumpyInterpolator

    elif method in valid_methods:
        if not has_scipy:
            raise ImportError(
                'Interpolation with method `%s` requires scipy' % method)

        if method in interp1d_methods:
            kwargs.update(method=method)
            interp_class = ScipyInterpolator
        elif vectorizeable_only:
            raise ValueError('{} is not a vectorizeable interpolator. '
                             'Available methods are {}'.format(
                                 method, interp1d_methods))
        elif method == 'barycentric':
            interp_class = interpolate.BarycentricInterpolator
        elif method == 'krog':
            interp_class = interpolate.KroghInterpolator
        elif method == 'pchip':
            interp_class = interpolate.PchipInterpolator
        elif method == 'spline':
            kwargs.update(method=method)
            interp_class = SplineInterpolator
        elif method == 'akima':
            interp_class = interpolate.Akima1DInterpolator
        else:
            raise ValueError('%s is not a valid scipy interpolator' % method)
    else:
        raise ValueError('%s is not a valid interpolator' % method)

    return interp_class, kwargs
def _get_interpolator ( method , vectorizeable_only = False , ** kwargs ) : interp1d_methods = [ 'linear' , 'nearest' , 'zero' , 'slinear' , 'quadratic' , 'cubic' , 'polynomial' ] valid_methods = interp1d_methods + [ 'barycentric' , 'krog' , 'pchip' , 'spline' , 'akima' ] has_scipy = True try : from scipy import interpolate except ImportError : has_scipy = False if ( method == 'linear' and not kwargs . get ( 'fill_value' , None ) == 'extrapolate' and not vectorizeable_only ) : kwargs . update ( method = method ) interp_class = NumpyInterpolator elif method in valid_methods : if not has_scipy : raise ImportError ( 'Interpolation with method `%s` requires scipy' % method ) if method in interp1d_methods : kwargs . update ( method = method ) interp_class = ScipyInterpolator elif vectorizeable_only : raise ValueError ( '{} is not a vectorizeable interpolator. ' 'Available methods are {}' . format ( method , interp1d_methods ) ) elif method == 'barycentric' : interp_class = interpolate . BarycentricInterpolator elif method == 'krog' : interp_class = interpolate . KroghInterpolator elif method == 'pchip' : interp_class = interpolate . PchipInterpolator elif method == 'spline' : kwargs . update ( method = method ) interp_class = SplineInterpolator elif method == 'akima' : interp_class = interpolate . Akima1DInterpolator else : raise ValueError ( '%s is not a valid scipy interpolator' % method ) else : raise ValueError ( '%s is not a valid interpolator' % method ) return interp_class , kwargs
helper function to select the appropriate interpolator class

    returns interpolator class and keyword arguments for the class