We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
griddata docstring doesn't make any sense
The docstring for `griddata` refers to many different integers:

`D`, `n`, `ndim`, `M`:

```
Interpolate unstructured D-dimensional data.

Parameters
----------
points : ndarray of floats, shape (n, D)
    Data point coordinates. Can either be an array of
    shape (n, D), or a tuple of `ndim` arrays.
values : ndarray of float or complex, shape (n,)
    Data values.
xi : ndarray of float, shape (M, D)
    Points at which to interpolate data.
```

The only one that is defined is `D`, so users have no idea what the others are.

Furthermore the example provided contradicts the docstring as xi is passed as a tuple but the docstring says it must be a ndarray.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scipy/interpolate/ndgriddata.py`
Content:
```
1 """
2 Convenience interface to N-D interpolation
3 
4 .. versionadded:: 0.9
5 
6 """
7 from __future__ import division, print_function, absolute_import
8 
9 import numpy as np
10 from .interpnd import LinearNDInterpolator, NDInterpolatorBase, \
11      CloughTocher2DInterpolator, _ndim_coords_from_arrays
12 from scipy.spatial import cKDTree
13 
14 __all__ = ['griddata', 'NearestNDInterpolator', 'LinearNDInterpolator',
15            'CloughTocher2DInterpolator']
16 
17 #------------------------------------------------------------------------------
18 # Nearest-neighbour interpolation
19 #------------------------------------------------------------------------------
20 
21 
22 class NearestNDInterpolator(NDInterpolatorBase):
23     """
24     NearestNDInterpolator(points, values)
25 
26     Nearest-neighbour interpolation in N dimensions.
27 
28     .. versionadded:: 0.9
29 
30     Methods
31     -------
32     __call__
33 
34     Parameters
35     ----------
36     x : (Npoints, Ndims) ndarray of floats
37         Data point coordinates.
38     y : (Npoints,) ndarray of float or complex
39         Data values.
40     rescale : boolean, optional
41         Rescale points to unit cube before performing interpolation.
42         This is useful if some of the input dimensions have
43         incommensurable units and differ by many orders of magnitude.
44 
45         .. versionadded:: 0.14.0
46     tree_options : dict, optional
47         Options passed to the underlying ``cKDTree``.
48 
49         .. versionadded:: 0.17.0
50 
51 
52     Notes
53     -----
54     Uses ``scipy.spatial.cKDTree``
55 
56     """
57 
58     def __init__(self, x, y, rescale=False, tree_options=None):
59         NDInterpolatorBase.__init__(self, x, y, rescale=rescale,
60                                     need_contiguous=False,
61                                     need_values=False)
62         if tree_options is None:
63             tree_options = dict()
64         self.tree = cKDTree(self.points, **tree_options)
65         self.values = y
66 
67     def __call__(self, *args):
68         """
69         Evaluate interpolator at given points.
70 
71         Parameters
72         ----------
73         xi : ndarray of float, shape (..., ndim)
74             Points where to interpolate data at.
75 
76         """
77         xi = _ndim_coords_from_arrays(args, ndim=self.points.shape[1])
78         xi = self._check_call_shape(xi)
79         xi = self._scale_x(xi)
80         dist, i = self.tree.query(xi)
81         return self.values[i]
82 
83 
84 #------------------------------------------------------------------------------
85 # Convenience interface function
86 #------------------------------------------------------------------------------
87 
88 def griddata(points, values, xi, method='linear', fill_value=np.nan,
89              rescale=False):
90     """
91     Interpolate unstructured D-dimensional data.
92 
93     Parameters
94     ----------
95     points : ndarray of floats, shape (n, D)
96         Data point coordinates. Can either be an array of
97         shape (n, D), or a tuple of `ndim` arrays.
98     values : ndarray of float or complex, shape (n,)
99         Data values.
100     xi : ndarray of float, shape (M, D)
101         Points at which to interpolate data.
102     method : {'linear', 'nearest', 'cubic'}, optional
103         Method of interpolation. One of
104 
105         ``nearest``
106           return the value at the data point closest to
107           the point of interpolation.  See `NearestNDInterpolator` for
108           more details.
109 
110         ``linear``
111           tesselate the input point set to n-dimensional
112           simplices, and interpolate linearly on each simplex.  See
113           `LinearNDInterpolator` for more details.
114 
115         ``cubic`` (1-D)
116           return the value determined from a cubic
117           spline.
118 
119         ``cubic`` (2-D)
120           return the value determined from a
121           piecewise cubic, continuously differentiable (C1), and
122           approximately curvature-minimizing polynomial surface. See
123           `CloughTocher2DInterpolator` for more details.
124     fill_value : float, optional
125         Value used to fill in for requested points outside of the
126         convex hull of the input points.  If not provided, then the
127         default is ``nan``. This option has no effect for the
128         'nearest' method.
129     rescale : bool, optional
130         Rescale points to unit cube before performing interpolation.
131         This is useful if some of the input dimensions have
132         incommensurable units and differ by many orders of magnitude.
133 
134         .. versionadded:: 0.14.0
135 
136     Notes
137     -----
138 
139     .. versionadded:: 0.9
140 
141     Examples
142     --------
143 
144     Suppose we want to interpolate the 2-D function
145 
146     >>> def func(x, y):
147     ...     return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2
148 
149     on a grid in [0, 1]x[0, 1]
150 
151     >>> grid_x, grid_y = np.mgrid[0:1:100j, 0:1:200j]
152 
153     but we only know its values at 1000 data points:
154 
155     >>> points = np.random.rand(1000, 2)
156     >>> values = func(points[:,0], points[:,1])
157 
158     This can be done with `griddata` -- below we try out all of the
159     interpolation methods:
160 
161     >>> from scipy.interpolate import griddata
162     >>> grid_z0 = griddata(points, values, (grid_x, grid_y), method='nearest')
163     >>> grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')
164     >>> grid_z2 = griddata(points, values, (grid_x, grid_y), method='cubic')
165 
166     One can see that the exact result is reproduced by all of the
167     methods to some degree, but for this smooth function the piecewise
168     cubic interpolant gives the best results:
169 
170     >>> import matplotlib.pyplot as plt
171     >>> plt.subplot(221)
172     >>> plt.imshow(func(grid_x, grid_y).T, extent=(0,1,0,1), origin='lower')
173     >>> plt.plot(points[:,0], points[:,1], 'k.', ms=1)
174     >>> plt.title('Original')
175     >>> plt.subplot(222)
176     >>> plt.imshow(grid_z0.T, extent=(0,1,0,1), origin='lower')
177     >>> plt.title('Nearest')
178     >>> plt.subplot(223)
179     >>> plt.imshow(grid_z1.T, extent=(0,1,0,1), origin='lower')
180     >>> plt.title('Linear')
181     >>> plt.subplot(224)
182     >>> plt.imshow(grid_z2.T, extent=(0,1,0,1), origin='lower')
183     >>> plt.title('Cubic')
184     >>> plt.gcf().set_size_inches(6, 6)
185     >>> plt.show()
186 
187     """
188 
189     points = _ndim_coords_from_arrays(points)
190 
191     if points.ndim < 2:
192         ndim = points.ndim
193     else:
194         ndim = points.shape[-1]
195 
196     if ndim == 1 and method in ('nearest', 'linear', 'cubic'):
197         from .interpolate import interp1d
198         points = points.ravel()
199         if isinstance(xi, tuple):
200             if len(xi) != 1:
201                 raise ValueError("invalid number of dimensions in xi")
202             xi, = xi
203         # Sort points/values together, necessary as input for interp1d
204         idx = np.argsort(points)
205         points = points[idx]
206         values = values[idx]
207         if method == 'nearest':
208             fill_value = 'extrapolate'
209         ip = interp1d(points, values, kind=method, axis=0, bounds_error=False,
210                       fill_value=fill_value)
211         return ip(xi)
212     elif method == 'nearest':
213         ip = NearestNDInterpolator(points, values, rescale=rescale)
214         return ip(xi)
215     elif method == 'linear':
216         ip = LinearNDInterpolator(points, values, fill_value=fill_value,
217                                   rescale=rescale)
218         return ip(xi)
219     elif method == 'cubic' and ndim == 2:
220         ip = CloughTocher2DInterpolator(points, values, fill_value=fill_value,
221                                         rescale=rescale)
222         return ip(xi)
223     else:
224         raise ValueError("Unknown interpolation method %r for "
225                          "%d dimensional data" % (method, ndim))
226
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scipy/interpolate/ndgriddata.py b/scipy/interpolate/ndgriddata.py
--- a/scipy/interpolate/ndgriddata.py
+++ b/scipy/interpolate/ndgriddata.py
@@ -97,7 +97,7 @@
         shape (n, D), or a tuple of `ndim` arrays.
     values : ndarray of float or complex, shape (n,)
         Data values.
-    xi : ndarray of float, shape (M, D)
+    xi : 2-D ndarray of float or tuple of 1-D array, shape (M, D)
         Points at which to interpolate data.
     method : {'linear', 'nearest', 'cubic'}, optional
         Method of interpolation. One of

{"golden_diff": "diff --git a/scipy/interpolate/ndgriddata.py b/scipy/interpolate/ndgriddata.py\n--- a/scipy/interpolate/ndgriddata.py\n+++ b/scipy/interpolate/ndgriddata.py\n@@ -97,7 +97,7 @@\n         shape (n, D), or a tuple of `ndim` arrays.\n     values : ndarray of float or complex, shape (n,)\n         Data values.\n-    xi : ndarray of float, shape (M, D)\n+    xi : 2-D ndarray of float or tuple of 1-D array, shape (M, D)\n         Points at which to interpolate data.\n     method : {'linear', 'nearest', 'cubic'}, optional\n         Method of interpolation. One of\n", "issue": "griddata docstring doesn't make any sense\nThe docstring for `griddata` refers to many different integers:\n\n`D`, `n`, `ndim`, `M`:\n\n```\nInterpolate unstructured D-dimensional data.\n\nParameters\n----------\npoints : ndarray of floats, shape (n, D)\n    Data point coordinates. Can either be an array of\n    shape (n, D), or a tuple of `ndim` arrays.\nvalues : ndarray of float or complex, shape (n,)\n    Data values.\nxi : ndarray of float, shape (M, D)\n    Points at which to interpolate data.\n```\n\nThe only one that is defined is `D`, so users have no idea what the others are.\n\nFurthermore the example provided contradicts the docstring as xi is passed as a tuple but the docstring says it must be a ndarray.\n\n", "before_files": [{"content": "\"\"\"\nConvenience interface to N-D interpolation\n\n.. versionadded:: 0.9\n\n\"\"\"\nfrom __future__ import division, print_function, absolute_import\n\nimport numpy as np\nfrom .interpnd import LinearNDInterpolator, NDInterpolatorBase, \\\n     CloughTocher2DInterpolator, _ndim_coords_from_arrays\nfrom scipy.spatial import cKDTree\n\n__all__ = ['griddata', 'NearestNDInterpolator', 'LinearNDInterpolator',\n           'CloughTocher2DInterpolator']\n\n#------------------------------------------------------------------------------\n# Nearest-neighbour interpolation\n#------------------------------------------------------------------------------\n\n\nclass NearestNDInterpolator(NDInterpolatorBase):\n    \"\"\"\n    NearestNDInterpolator(points, values)\n\n    Nearest-neighbour interpolation in N dimensions.\n\n    .. versionadded:: 0.9\n\n    Methods\n    -------\n    __call__\n\n    Parameters\n    ----------\n    x : (Npoints, Ndims) ndarray of floats\n        Data point coordinates.\n    y : (Npoints,) ndarray of float or complex\n        Data values.\n    rescale : boolean, optional\n        Rescale points to unit cube before performing interpolation.\n        This is useful if some of the input dimensions have\n        incommensurable units and differ by many orders of magnitude.\n\n        .. versionadded:: 0.14.0\n    tree_options : dict, optional\n        Options passed to the underlying ``cKDTree``.\n\n        .. versionadded:: 0.17.0\n\n\n    Notes\n    -----\n    Uses ``scipy.spatial.cKDTree``\n\n    \"\"\"\n\n    def __init__(self, x, y, rescale=False, tree_options=None):\n        NDInterpolatorBase.__init__(self, x, y, rescale=rescale,\n                                    need_contiguous=False,\n                                    need_values=False)\n        if tree_options is None:\n            tree_options = dict()\n        self.tree = cKDTree(self.points, **tree_options)\n        self.values = y\n\n    def __call__(self, *args):\n        \"\"\"\n        Evaluate interpolator at given points.\n\n        Parameters\n        ----------\n        xi : ndarray of float, shape (..., ndim)\n            Points where to interpolate data at.\n\n        \"\"\"\n        xi = _ndim_coords_from_arrays(args, ndim=self.points.shape[1])\n        xi = self._check_call_shape(xi)\n        xi = self._scale_x(xi)\n        dist, i = self.tree.query(xi)\n        return self.values[i]\n\n\n#------------------------------------------------------------------------------\n# Convenience interface function\n#------------------------------------------------------------------------------\n\ndef griddata(points, values, xi, method='linear', fill_value=np.nan,\n             rescale=False):\n    \"\"\"\n    Interpolate unstructured D-dimensional data.\n\n    Parameters\n    ----------\n    points : ndarray of floats, shape (n, D)\n        Data point coordinates. Can either be an array of\n        shape (n, D), or a tuple of `ndim` arrays.\n    values : ndarray of float or complex, shape (n,)\n        Data values.\n    xi : ndarray of float, shape (M, D)\n        Points at which to interpolate data.\n    method : {'linear', 'nearest', 'cubic'}, optional\n        Method of interpolation. One of\n\n        ``nearest``\n          return the value at the data point closest to\n          the point of interpolation.  See `NearestNDInterpolator` for\n          more details.\n\n        ``linear``\n          tesselate the input point set to n-dimensional\n          simplices, and interpolate linearly on each simplex.  See\n          `LinearNDInterpolator` for more details.\n\n        ``cubic`` (1-D)\n          return the value determined from a cubic\n          spline.\n\n        ``cubic`` (2-D)\n          return the value determined from a\n          piecewise cubic, continuously differentiable (C1), and\n          approximately curvature-minimizing polynomial surface. See\n          `CloughTocher2DInterpolator` for more details.\n    fill_value : float, optional\n        Value used to fill in for requested points outside of the\n        convex hull of the input points.  If not provided, then the\n        default is ``nan``. This option has no effect for the\n        'nearest' method.\n    rescale : bool, optional\n        Rescale points to unit cube before performing interpolation.\n        This is useful if some of the input dimensions have\n        incommensurable units and differ by many orders of magnitude.\n\n        .. versionadded:: 0.14.0\n\n    Notes\n    -----\n\n    .. versionadded:: 0.9\n\n    Examples\n    --------\n\n    Suppose we want to interpolate the 2-D function\n\n    >>> def func(x, y):\n    ...     return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2\n\n    on a grid in [0, 1]x[0, 1]\n\n    >>> grid_x, grid_y = np.mgrid[0:1:100j, 0:1:200j]\n\n    but we only know its values at 1000 data points:\n\n    >>> points = np.random.rand(1000, 2)\n    >>> values = func(points[:,0], points[:,1])\n\n    This can be done with `griddata` -- below we try out all of the\n    interpolation methods:\n\n    >>> from scipy.interpolate import griddata\n    >>> grid_z0 = griddata(points, values, (grid_x, grid_y), method='nearest')\n    >>> grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')\n    >>> grid_z2 = griddata(points, values, (grid_x, grid_y), method='cubic')\n\n    One can see that the exact result is reproduced by all of the\n    methods to some degree, but for this smooth function the piecewise\n    cubic interpolant gives the best results:\n\n    >>> import matplotlib.pyplot as plt\n    >>> plt.subplot(221)\n    >>> plt.imshow(func(grid_x, grid_y).T, extent=(0,1,0,1), origin='lower')\n    >>> plt.plot(points[:,0], points[:,1], 'k.', ms=1)\n    >>> plt.title('Original')\n    >>> plt.subplot(222)\n    >>> plt.imshow(grid_z0.T, extent=(0,1,0,1), origin='lower')\n    >>> plt.title('Nearest')\n    >>> plt.subplot(223)\n    >>> plt.imshow(grid_z1.T, extent=(0,1,0,1), origin='lower')\n    >>> plt.title('Linear')\n    >>> plt.subplot(224)\n    >>> plt.imshow(grid_z2.T, extent=(0,1,0,1), origin='lower')\n    >>> plt.title('Cubic')\n    >>> plt.gcf().set_size_inches(6, 6)\n    >>> plt.show()\n\n    \"\"\"\n\n    points = _ndim_coords_from_arrays(points)\n\n    if points.ndim < 2:\n        ndim = points.ndim\n    else:\n        ndim = points.shape[-1]\n\n    if ndim == 1 and method in ('nearest', 'linear', 'cubic'):\n        from .interpolate import interp1d\n        points = points.ravel()\n        if isinstance(xi, tuple):\n            if len(xi) != 1:\n                raise ValueError(\"invalid number of dimensions in xi\")\n            xi, = xi\n        # Sort points/values together, necessary as input for interp1d\n        idx = np.argsort(points)\n        points = points[idx]\n        values = values[idx]\n        if method == 'nearest':\n            fill_value = 'extrapolate'\n        ip = interp1d(points, values, kind=method, axis=0, bounds_error=False,\n                      fill_value=fill_value)\n        return ip(xi)\n    elif method == 'nearest':\n        ip = NearestNDInterpolator(points, values, rescale=rescale)\n        return ip(xi)\n    elif method == 'linear':\n        ip = LinearNDInterpolator(points, values, fill_value=fill_value,\n                                  rescale=rescale)\n        return ip(xi)\n    elif method == 'cubic' and ndim == 2:\n        ip = CloughTocher2DInterpolator(points, values, fill_value=fill_value,\n                                        rescale=rescale)\n        return ip(xi)\n    else:\n        raise ValueError(\"Unknown interpolation method %r for \"\n                         \"%d dimensional data\" % (method, ndim))\n", "path": "scipy/interpolate/ndgriddata.py"}], "after_files": [{"content": "\"\"\"\nConvenience interface to N-D interpolation\n\n.. versionadded:: 0.9\n\n\"\"\"\nfrom __future__ import division, print_function, absolute_import\n\nimport numpy as np\nfrom .interpnd import LinearNDInterpolator, NDInterpolatorBase, \\\n     CloughTocher2DInterpolator, _ndim_coords_from_arrays\nfrom scipy.spatial import cKDTree\n\n__all__ = ['griddata', 'NearestNDInterpolator', 'LinearNDInterpolator',\n           'CloughTocher2DInterpolator']\n\n#------------------------------------------------------------------------------\n# Nearest-neighbour interpolation\n#------------------------------------------------------------------------------\n\n\nclass NearestNDInterpolator(NDInterpolatorBase):\n    \"\"\"\n    NearestNDInterpolator(points, values)\n\n    Nearest-neighbour interpolation in N dimensions.\n\n    .. versionadded:: 0.9\n\n    Methods\n    -------\n    __call__\n\n    Parameters\n    ----------\n    x : (Npoints, Ndims) ndarray of floats\n        Data point coordinates.\n    y : (Npoints,) ndarray of float or complex\n        Data values.\n    rescale : boolean, optional\n        Rescale points to unit cube before performing interpolation.\n        This is useful if some of the input dimensions have\n        incommensurable units and differ by many orders of magnitude.\n\n        .. versionadded:: 0.14.0\n    tree_options : dict, optional\n        Options passed to the underlying ``cKDTree``.\n\n        .. versionadded:: 0.17.0\n\n\n    Notes\n    -----\n    Uses ``scipy.spatial.cKDTree``\n\n    \"\"\"\n\n    def __init__(self, x, y, rescale=False, tree_options=None):\n        NDInterpolatorBase.__init__(self, x, y, rescale=rescale,\n                                    need_contiguous=False,\n                                    need_values=False)\n        if tree_options is None:\n            tree_options = dict()\n        self.tree = cKDTree(self.points, **tree_options)\n        self.values = y\n\n    def __call__(self, *args):\n        \"\"\"\n        Evaluate interpolator at given points.\n\n        Parameters\n        ----------\n        xi : ndarray of float, shape (..., ndim)\n            Points where to interpolate data at.\n\n        \"\"\"\n        xi = _ndim_coords_from_arrays(args, ndim=self.points.shape[1])\n        xi = self._check_call_shape(xi)\n        xi = self._scale_x(xi)\n        dist, i = self.tree.query(xi)\n        return self.values[i]\n\n\n#------------------------------------------------------------------------------\n# Convenience interface function\n#------------------------------------------------------------------------------\n\ndef griddata(points, values, xi, method='linear', fill_value=np.nan,\n             rescale=False):\n    \"\"\"\n    Interpolate unstructured D-dimensional data.\n\n    Parameters\n    ----------\n    points : ndarray of floats, shape (n, D)\n        Data point coordinates. Can either be an array of\n        shape (n, D), or a tuple of `ndim` arrays.\n    values : ndarray of float or complex, shape (n,)\n        Data values.\n    xi : 2-D ndarray of float or tuple of 1-D array, shape (M, D)\n        Points at which to interpolate data.\n    method : {'linear', 'nearest', 'cubic'}, optional\n        Method of interpolation. One of\n\n        ``nearest``\n          return the value at the data point closest to\n          the point of interpolation.  See `NearestNDInterpolator` for\n          more details.\n\n        ``linear``\n          tesselate the input point set to n-dimensional\n          simplices, and interpolate linearly on each simplex.  See\n          `LinearNDInterpolator` for more details.\n\n        ``cubic`` (1-D)\n          return the value determined from a cubic\n          spline.\n\n        ``cubic`` (2-D)\n          return the value determined from a\n          piecewise cubic, continuously differentiable (C1), and\n          approximately curvature-minimizing polynomial surface. See\n          `CloughTocher2DInterpolator` for more details.\n    fill_value : float, optional\n        Value used to fill in for requested points outside of the\n        convex hull of the input points.  If not provided, then the\n        default is ``nan``. This option has no effect for the\n        'nearest' method.\n    rescale : bool, optional\n        Rescale points to unit cube before performing interpolation.\n        This is useful if some of the input dimensions have\n        incommensurable units and differ by many orders of magnitude.\n\n        .. versionadded:: 0.14.0\n\n    Notes\n    -----\n\n    .. versionadded:: 0.9\n\n    Examples\n    --------\n\n    Suppose we want to interpolate the 2-D function\n\n    >>> def func(x, y):\n    ...     return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2\n\n    on a grid in [0, 1]x[0, 1]\n\n    >>> grid_x, grid_y = np.mgrid[0:1:100j, 0:1:200j]\n\n    but we only know its values at 1000 data points:\n\n    >>> points = np.random.rand(1000, 2)\n    >>> values = func(points[:,0], points[:,1])\n\n    This can be done with `griddata` -- below we try out all of the\n    interpolation methods:\n\n    >>> from scipy.interpolate import griddata\n    >>> grid_z0 = griddata(points, values, (grid_x, grid_y), method='nearest')\n    >>> grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')\n    >>> grid_z2 = griddata(points, values, (grid_x, grid_y), method='cubic')\n\n    One can see that the exact result is reproduced by all of the\n    methods to some degree, but for this smooth function the piecewise\n    cubic interpolant gives the best results:\n\n    >>> import matplotlib.pyplot as plt\n    >>> plt.subplot(221)\n    >>> plt.imshow(func(grid_x, grid_y).T, extent=(0,1,0,1), origin='lower')\n    >>> plt.plot(points[:,0], points[:,1], 'k.', ms=1)\n    >>> plt.title('Original')\n    >>> plt.subplot(222)\n    >>> plt.imshow(grid_z0.T, extent=(0,1,0,1), origin='lower')\n    >>> plt.title('Nearest')\n    >>> plt.subplot(223)\n    >>> plt.imshow(grid_z1.T, extent=(0,1,0,1), origin='lower')\n    >>> plt.title('Linear')\n    >>> plt.subplot(224)\n    >>> plt.imshow(grid_z2.T, extent=(0,1,0,1), origin='lower')\n    >>> plt.title('Cubic')\n    >>> plt.gcf().set_size_inches(6, 6)\n    >>> plt.show()\n\n    \"\"\"\n\n    points = _ndim_coords_from_arrays(points)\n\n    if points.ndim < 2:\n        ndim = points.ndim\n    else:\n        ndim = points.shape[-1]\n\n    if ndim == 1 and method in ('nearest', 'linear', 'cubic'):\n        from .interpolate import interp1d\n        points = points.ravel()\n        if isinstance(xi, tuple):\n            if len(xi) != 1:\n                raise ValueError(\"invalid number of dimensions in xi\")\n            xi, = xi\n        # Sort points/values together, necessary as input for interp1d\n        idx = np.argsort(points)\n        points = points[idx]\n        values = values[idx]\n        if method == 'nearest':\n            fill_value = 'extrapolate'\n        ip = interp1d(points, values, kind=method, axis=0, bounds_error=False,\n                      fill_value=fill_value)\n        return ip(xi)\n    elif method == 'nearest':\n        ip = NearestNDInterpolator(points, values, rescale=rescale)\n        return ip(xi)\n    elif method == 'linear':\n        ip = LinearNDInterpolator(points, values, fill_value=fill_value,\n                                  rescale=rescale)\n        return ip(xi)\n    elif method == 'cubic' and ndim == 2:\n        ip = CloughTocher2DInterpolator(points, values, fill_value=fill_value,\n                                        rescale=rescale)\n        return ip(xi)\n    else:\n        raise ValueError(\"Unknown interpolation method %r for \"\n                         \"%d dimensional data\" % (method, ndim))\n", "path": "scipy/interpolate/ndgriddata.py"}]}