def interpn(points, values, xi, method="<STR_LIT>", bounds_error=True,<EOL>fill_value=np.nan):
<EOL>if method not in ["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" %<EOL>method)<EOL><DEDENT>if not hasattr(values, '<STR_LIT>'):<EOL><INDENT>values = np.asarray(values)<EOL><DEDENT>ndim = values.ndim<EOL>if ndim > <NUM_LIT:2> and method == "<STR_LIT>":<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if not bounds_error and fill_value is None and method == "<STR_LIT>":<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if len(points) > ndim:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % (len(points), ndim))<EOL><DEDENT>if len(points) != ndim and method == '<STR_LIT>':<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>for i, p in enumerate(points):<EOL><INDENT>if not np.all(np.diff(p) > <NUM_LIT:0.>):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % i)<EOL><DEDENT>if not np.asarray(p).ndim == <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % i)<EOL><DEDENT>if not values.shape[i] == len(p):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % (len(p), values.shape[i], i))<EOL><DEDENT><DEDENT>grid = tuple([np.asarray(p) for p in points])<EOL>xi = _ndim_coords_from_arrays(xi, ndim=len(grid))<EOL>if xi.shape[-<NUM_LIT:1>] != len(grid):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (xi.shape[<NUM_LIT:1>], len(grid)))<EOL><DEDENT>for i, p in enumerate(xi.T):<EOL><INDENT>if bounds_error and not np.logical_and(np.all(grid[i][<NUM_LIT:0>] <= p),<EOL>np.all(p <= grid[i][-<NUM_LIT:1>])):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % i)<EOL><DEDENT><DEDENT>if method == "<STR_LIT>":<EOL><INDENT>interp = RegularGridInterpolator(points, values, method="<STR_LIT>",<EOL>bounds_error=bounds_error,<EOL>fill_value=fill_value)<EOL>return interp(xi)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>interp = RegularGridInterpolator(points, values, method="<STR_LIT>",<EOL>bounds_error=bounds_error,<EOL>fill_value=fill_value)<EOL>return interp(xi)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>xi_shape = xi.shape<EOL>xi = xi.reshape(-<NUM_LIT:1>, xi.shape[-<NUM_LIT:1>])<EOL>idx_valid = np.all((grid[<NUM_LIT:0>][<NUM_LIT:0>] <= xi[:, <NUM_LIT:0>], xi[:, <NUM_LIT:0>] <= grid[<NUM_LIT:0>][-<NUM_LIT:1>],<EOL>grid[<NUM_LIT:1>][<NUM_LIT:0>] <= xi[:, <NUM_LIT:1>], xi[:, <NUM_LIT:1>] <= grid[<NUM_LIT:1>][-<NUM_LIT:1>]),<EOL>axis=<NUM_LIT:0>)<EOL>result = np.empty_like(xi[:, <NUM_LIT:0>])<EOL>interp = RectBivariateSpline(points[<NUM_LIT:0>], points[<NUM_LIT:1>], values[:])<EOL>result[idx_valid] = interp.ev(xi[idx_valid, <NUM_LIT:0>], xi[idx_valid, <NUM_LIT:1>])<EOL>result[np.logical_not(idx_valid)] = fill_value<EOL>return result.reshape(xi_shape[:-<NUM_LIT:1>])<EOL><DEDENT>
Multidimensional interpolation on regular grids.

Parameters
----------
points : tuple of ndarray of float, with shapes (m1, ), ..., (mn, )
    The points defining the regular grid in n dimensions.

values : array_like, shape (m1, ..., mn, ...)
    The data on the regular grid in n dimensions.

xi : ndarray of shape (..., ndim)
    The coordinates to sample the gridded data at

method : str
    The method of interpolation to perform. Supported are "linear" and
    "nearest", and "splinef2d". "splinef2d" is only supported for
    2-dimensional data.

bounds_error : bool, optional
    If True, when interpolated values are requested outside of the
    domain of the input data, a ValueError is raised.
    If False, then `fill_value` is used.

fill_value : number, optional
    If provided, the value to use for points outside of the
    interpolation domain. If None, values outside
    the domain are extrapolated.  Extrapolation is not supported by method
    "splinef2d".

Returns
-------
values_x : ndarray, shape xi.shape[:-1] + values.shape[ndim:]
    Interpolated values at input coordinates.

Notes
-----

.. versionadded:: 0.14

See also
--------
NearestNDInterpolator : Nearest neighbour interpolation on unstructured
                        data in N dimensions

LinearNDInterpolator : Piecewise linear interpolant on unstructured data
                       in N dimensions

RegularGridInterpolator : Linear and nearest-neighbor Interpolation on a
                          regular grid in arbitrary dimensions

RectBivariateSpline : Bivariate spline approximation over a rectangular mesh