Repository: scipy/scipy
File: scipy/interpolate/_fitpack2.py (Python)

Code before:
    RectBivariateSpline :
        a bivariate spline over a rectangular mesh
    bisplrep :
        a function to find a bivariate B-spline representation of a surface
    bisplev :
        a function to evaluate a bivariate B-spline and its derivatives

    Notes
    -----
    The length of `x`, `y` and `z` should be at least ``(kx+1) * (ky+1)``.

    If the input data is such that input dimensions have incommensurate
    units and differ by many orders of magnitude, the interpolant may have
    numerical artifacts. Consider rescaling the data before interpolating.

    This routine constructs spline knot vectors automatically via the FITPACK
    algorithm. The spline knots may be placed away from the data points. For
    some data sets, this routine may fail to construct an interpolating spline,
    even if one is requested via ``s=0`` parameter. In such situations, it is
    recommended to use `bisplrep` / `bisplev` directly instead of this routine
    and, if needed, increase the values of ``nxest`` and ``nyest`` parameters
    of `bisplrep`.

    For linear interpolation, `LinearNDInterpolator` is preferred.
    See `here
    <https://gist.github.com/ev-br/8544371b40f414b7eaf3fe6217209bff>`_
    for discussion.

    """

    def __init__(self, x, y, z, w=None, bbox=[None] * 4, kx=3, ky=3, s=None,
                 eps=1e-16):

        x, y, z, w = self._validate_input(x, y, z, w, kx, ky, eps)
        bbox = ravel(bbox)
        if not bbox.shape == (4,):
            raise ValueError('bbox shape should be (4,)')
        if s is not None and not s >= 0.0:
            raise ValueError("s should be s >= 0.0")

        xb, xe, yb, ye = bbox
        with FITPACK_LOCK:
            nx, tx, ny, ty, c, fp, wrk1, ier = dfitpack.surfit_smth(
                x, y, z, w, xb, xe, yb, ye, kx, ky, s=s, eps=eps, lwrk2=1)
            if ier > 10:          # lwrk2 was to small, re-run
                nx, tx, ny, ty, c, fp, wrk1, ier = dfitpack.surfit_smth(
                    x, y, z, w, xb, xe, yb, ye, kx, ky, s=s, eps=eps,
                    lwrk2=ier)
        if ier in [0, -1, -2]:  # normal return
            pass
        else:

Review comment (suggestion):
Can you change this to point to this page instead please 
https://docs.scipy.org/doc/scipy/tutorial/interpolate/interp_transition_guide.html

Code after:
    RectBivariateSpline :
        a bivariate spline over a rectangular mesh
    bisplrep :
        a function to find a bivariate B-spline representation of a surface
    bisplev :
        a function to evaluate a bivariate B-spline and its derivatives

    Notes
    -----
    The length of `x`, `y` and `z` should be at least ``(kx+1) * (ky+1)``.

    If the input data is such that input dimensions have incommensurate
    units and differ by many orders of magnitude, the interpolant may have
    numerical artifacts. Consider rescaling the data before interpolating.

    This routine constructs spline knot vectors automatically via the FITPACK
    algorithm. The spline knots may be placed away from the data points. For
    some data sets, this routine may fail to construct an interpolating spline,
    even if one is requested via ``s=0`` parameter. In such situations, it is
    recommended to use `bisplrep` / `bisplev` directly instead of this routine
    and, if needed, increase the values of ``nxest`` and ``nyest`` parameters
    of `bisplrep`.

    For linear interpolation, `LinearNDInterpolator` is preferred.
    Consult the :ref:`interp-transition-guide` for discussion.

    """

    def __init__(self, x, y, z, w=None, bbox=[None] * 4, kx=3, ky=3, s=None,
                 eps=1e-16):

        x, y, z, w = self._validate_input(x, y, z, w, kx, ky, eps)
        bbox = ravel(bbox)
        if not bbox.shape == (4,):
            raise ValueError('bbox shape should be (4,)')
        if s is not None and not s >= 0.0:
            raise ValueError("s should be s >= 0.0")

        xb, xe, yb, ye = bbox
        with FITPACK_LOCK:
            nx, tx, ny, ty, c, fp, wrk1, ier = dfitpack.surfit_smth(
                x, y, z, w, xb, xe, yb, ye, kx, ky, s=s, eps=eps, lwrk2=1)
            if ier > 10:          # lwrk2 was to small, re-run
                nx, tx, ny, ty, c, fp, wrk1, ier = dfitpack.surfit_smth(
                    x, y, z, w, xb, xe, yb, ye, kx, ky, s=s, eps=eps,
                    lwrk2=ier)
        if ier in [0, -1, -2]:  # normal return
            pass
        else:
            message = _surfit_messages.get(ier, f'ier={ier}')
            warnings.warn(message, stacklevel=2)