Ë
    âQ(hy  ã                   ó¼   — d dgZ ddlZddlZddlmc mZ ddlm	Z	 ddl
mZ ddlmZmZ ddlmZ dd	lmZ dd
lmZ d„ Zd„ Z G d„ d «      Zddej0                  fd„Zy)ÚRegularGridInterpolatorÚinterpné    Né   )Ú_ndim_coords_from_arrays©ÚPchipInterpolator)Úevaluate_linear_2dÚfind_indices©Úmake_interp_spline)ÚRectBivariateSpline)Úmake_ndbsplc                 óÀ  — g }g }t        | «      D ]·  \  }}t        j                  |t        ¬«      }t        j                  |dd  |d d kD  «      sSt        j                  |dd  |d d k  «      r'|j                  |«       t        j                  |«      }nt        d|z  «      ‚t        j                  |«      }|j                  |«       Œ¹ t        |«      t        |«      fS )N©Údtyper   éÿÿÿÿzCThe points in dimension %d must be strictly ascending or descending)
Ú	enumerateÚnpÚasarrayÚfloatÚallÚappendÚflipÚ
ValueErrorÚascontiguousarrayÚtuple)ÚpointsÚdescending_dimensionsÚgridÚiÚps        úT/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/interpolate/_rgi.pyÚ_check_pointsr#      sØ   € ØÐØ€DÜ˜&Ó!ò ‰ˆˆ1ô �J‰J�q¤Ô&ˆÜ�v‰v�a˜˜�e˜a  ˜f‘nÔ%Ü�v‰v�a˜˜�e˜a  ˜f‘nÔ%à%×,Ñ,¨QÔ/Ü—G‘G˜A“J‘ä ð.Ø01ñ2ó3ð 3ô × Ñ  Ó#ˆØ�‰�A�ðô  �‹;œÐ3Ó4Ð4Ð4ó    c                 ó„  — t        | «      |j                  kD  r#t        dt        | «      |j                  fz  «      ‚t        | «      D ]w  \  }}t	        j
                  |«      j                  dk(  st        d|z  «      ‚|j                  |   t        |«      k(  rŒRt        dt        |«      |j                  |   |fz  «      ‚ y )Nú7There are %d point arrays, but values has %d dimensionsr   z0The points in dimension %d must be 1-dimensionalz1There are %d points and %d values in dimension %d)ÚlenÚndimr   r   r   r   Úshape)r   Úvaluesr    r!   s       r"   Ú_check_dimensionalityr+   '   sÊ   € Ü
ˆ6ƒ{�V—[‘[Ò Üð &Ü),¨V«°f·k±kÐ(BñCó Dð 	Dä˜&Ó!ò L‰ˆˆ1Ü�z‰z˜!‹}×!Ñ! QÒ&Üð -Ø/0ñ1ó 2ð 2à�|‰|˜A‰¤# a£&Ó(Üð ,Ü/2°1«v°v·|±|ÀA±ÈÐ.JñKó Lð LñLr$   c                   ó  — e Zd ZdZddddddddœZh d£Zh d£Z eej                  «       «      Z	dd	ge	z   Z
dd
ej                  fdddœd„Zdd„Zd„ Zd„ Zd„ Zd„ Zdddœd„Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ «       Zed„ «       Zd„ Zd„ Zy)r   a5  
    Interpolator on a regular or rectilinear grid in arbitrary dimensions.

    The data must be defined on a rectilinear grid; that is, a rectangular
    grid with even or uneven spacing. Linear, nearest-neighbor, spline
    interpolations are supported. After setting up the interpolator object,
    the interpolation method may be chosen at each evaluation.

    Parameters
    ----------
    points : tuple of ndarray of float, with shapes (m1, ), ..., (mn, )
        The points defining the regular grid in n dimensions. The points in
        each dimension (i.e. every elements of the points tuple) must be
        strictly ascending or descending.

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

    method : str, optional
        The method of interpolation to perform. Supported are "linear",
        "nearest", "slinear", "cubic", "quintic" and "pchip". This
        parameter will become the default for the object's ``__call__``
        method. Default is "linear".

    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.
        Default is True.

    fill_value : float or None, optional
        The value to use for points outside of the interpolation domain.
        If None, values outside the domain are extrapolated.
        Default is ``np.nan``.

    solver : callable, optional
        Only used for methods "slinear", "cubic" and "quintic".
        Sparse linear algebra solver for construction of the NdBSpline instance.
        Default is the iterative solver `scipy.sparse.linalg.gcrotmk`.

        .. versionadded:: 1.13

    solver_args: dict, optional
        Additional arguments to pass to `solver`, if any.

        .. versionadded:: 1.13

    Methods
    -------
    __call__

    Attributes
    ----------
    grid : tuple of ndarrays
        The points defining the regular grid in n dimensions.
        This tuple defines the full grid via
        ``np.meshgrid(*grid, indexing='ij')``
    values : ndarray
        Data values at the grid.
    method : str
        Interpolation method.
    fill_value : float or ``None``
        Use this value for out-of-bounds arguments to `__call__`.
    bounds_error : bool
        If ``True``, out-of-bounds argument raise a ``ValueError``.

    Notes
    -----
    Contrary to `LinearNDInterpolator` and `NearestNDInterpolator`, this class
    avoids expensive triangulation of the input data by taking advantage of the
    regular grid structure.

    In other words, this class assumes that the data is defined on a
    *rectilinear* grid.

    .. versionadded:: 0.14

    The 'slinear'(k=1), 'cubic'(k=3), and 'quintic'(k=5) methods are
    tensor-product spline interpolators, where `k` is the spline degree,
    If any dimension has fewer points than `k` + 1, an error will be raised.

    .. versionadded:: 1.9

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

    **Choosing a solver for spline methods**

    Spline methods, "slinear", "cubic" and "quintic" involve solving a
    large sparse linear system at instantiation time. Depending on data,
    the default solver may or may not be adequate. When it is not, you may
    need to experiment with an optional `solver` argument, where you may
    choose between the direct solver (`scipy.sparse.linalg.spsolve`) or
    iterative solvers from `scipy.sparse.linalg`. You may need to supply
    additional parameters via the optional `solver_args` parameter (for instance,
    you may supply the starting value or target tolerance). See the
    `scipy.sparse.linalg` documentation for the full list of available options.

    Alternatively, you may instead use the legacy methods, "slinear_legacy",
    "cubic_legacy" and "quintic_legacy". These methods allow faster construction
    but evaluations will be much slower.

    Examples
    --------
    **Evaluate a function on the points of a 3-D grid**

    As a first example, we evaluate a simple example function on the points of
    a 3-D grid:

    >>> from scipy.interpolate import RegularGridInterpolator
    >>> import numpy as np
    >>> def f(x, y, z):
    ...     return 2 * x**3 + 3 * y**2 - z
    >>> x = np.linspace(1, 4, 11)
    >>> y = np.linspace(4, 7, 22)
    >>> z = np.linspace(7, 9, 33)
    >>> xg, yg ,zg = np.meshgrid(x, y, z, indexing='ij', sparse=True)
    >>> data = f(xg, yg, zg)

    ``data`` is now a 3-D array with ``data[i, j, k] = f(x[i], y[j], z[k])``.
    Next, define an interpolating function from this data:

    >>> interp = RegularGridInterpolator((x, y, z), data)

    Evaluate the interpolating function at the two points
    ``(x,y,z) = (2.1, 6.2, 8.3)`` and ``(3.3, 5.2, 7.1)``:

    >>> pts = np.array([[2.1, 6.2, 8.3],
    ...                 [3.3, 5.2, 7.1]])
    >>> interp(pts)
    array([ 125.80469388,  146.30069388])

    which is indeed a close approximation to

    >>> f(2.1, 6.2, 8.3), f(3.3, 5.2, 7.1)
    (125.54200000000002, 145.894)

    **Interpolate and extrapolate a 2D dataset**

    As a second example, we interpolate and extrapolate a 2D data set:

    >>> x, y = np.array([-2, 0, 4]), np.array([-2, 0, 2, 5])
    >>> def ff(x, y):
    ...     return x**2 + y**2

    >>> xg, yg = np.meshgrid(x, y, indexing='ij')
    >>> data = ff(xg, yg)
    >>> interp = RegularGridInterpolator((x, y), data,
    ...                                  bounds_error=False, fill_value=None)

    >>> import matplotlib.pyplot as plt
    >>> fig = plt.figure()
    >>> ax = fig.add_subplot(projection='3d')
    >>> ax.scatter(xg.ravel(), yg.ravel(), data.ravel(),
    ...            s=60, c='k', label='data')

    Evaluate and plot the interpolator on a finer grid

    >>> xx = np.linspace(-4, 9, 31)
    >>> yy = np.linspace(-4, 9, 31)
    >>> X, Y = np.meshgrid(xx, yy, indexing='ij')

    >>> # interpolator
    >>> ax.plot_wireframe(X, Y, interp((X, Y)), rstride=3, cstride=3,
    ...                   alpha=0.4, color='m', label='linear interp')

    >>> # ground truth
    >>> ax.plot_wireframe(X, Y, ff(X, Y), rstride=3, cstride=3,
    ...                   alpha=0.4, label='ground truth')
    >>> plt.legend()
    >>> plt.show()

    Other examples are given
    :ref:`in the tutorial <tutorial-interpolate_regular_grid_interpolator>`.

    See Also
    --------
    NearestNDInterpolator : Nearest neighbor interpolator on *unstructured*
                            data in N dimensions

    LinearNDInterpolator : Piecewise linear interpolator on *unstructured* data
                           in N dimensions

    interpn : a convenience function which wraps `RegularGridInterpolator`

    scipy.ndimage.map_coordinates : interpolation on grids with equal spacing
                                    (suitable for e.g., N-D image resampling)

    References
    ----------
    .. [1] Python package *regulargrid* by Johannes Buchner, see
           https://pypi.python.org/pypi/regulargrid/
    .. [2] Wikipedia, "Trilinear interpolation",
           https://en.wikipedia.org/wiki/Trilinear_interpolation
    .. [3] Weiser, Alan, and Sergio E. Zarantonello. "A note on piecewise linear
           and multilinear table interpolation in many dimensions." MATH.
           COMPUT. 50.181 (1988): 189-196.
           https://www.ams.org/journals/mcom/1988-50-181/S0025-5718-1988-0917826-0/S0025-5718-1988-0917826-0.pdf
           :doi:`10.1090/S0025-5718-1988-0917826-0`

    r   é   é   )ÚslinearÚcubicÚquinticÚpchipÚslinear_legacyÚcubic_legacyÚquintic_legacy>   r2   r4   r5   r3   >   r0   r1   r/   ÚlinearÚnearestTN)ÚsolverÚsolver_argsc          	      óö  — || j                   vrt        d|› d�«      ‚|| j                  v r| j                  ||«       || _        d | _        || _        t        |«      \  | _        | _	        | j                  |«      | _        | j                  | j                  | j                  «       | j                  | j                  |«      | _        | j                  r&t        j                   || j                  ¬«      | _        | j                  dk(  r,t        j"                  | j                  «      rd}t        |«      ‚|| j$                  v r|€i } | j&                  ||fi |¤Ž| _        y |€|rt        d|›d|›d|› d	�«      ‚y )
NúMethod 'ú' is not defined©Úaxisr2   zº`PchipInterpolator` only works with real values. If you are trying to use the real components of the passed array, use `np.real` on the array before passing to `RegularGridInterpolator`.zmethod =z6 does not accept the 'solver' argument. Got  solver = z and with arguments ú.)Ú_ALL_METHODSr   Ú_SPLINE_METHODSÚ_validate_grid_dimensionsÚmethodÚ_splineÚbounds_errorr#   r   Ú_descending_dimensionsÚ_check_valuesr*   r+   Ú_check_fill_valueÚ
fill_valuer   r   ÚiscomplexobjÚ_SPLINE_METHODS_ndbsplÚ_construct_spline)	Úselfr   r*   rC   rE   rI   r8   r9   Úmsgs	            r"   Ú__init__z RegularGridInterpolator.__init__  sm  € à˜×*Ñ*Ñ*Ü˜x¨ xÐ/?Ð@ÓAÐAØ�t×+Ñ+Ñ+Ø×*Ñ*¨6°6Ô:ØˆŒØˆŒØ(ˆÔÜ1>¸vÓ1FÑ.ˆŒ	�4Ô.Ø×(Ñ(¨Ó0ˆŒØ×"Ñ" 4§9¡9¨d¯k©kÔ:Ø×0Ñ0°·±¸jÓIˆŒØ×&Ò&ÜŸ'™' &¨t×/JÑ/JÔKˆDŒKØ�;‰;˜'Ò!¤b§o¡o°d·k±kÔ&BðLˆCô ˜S“/Ð!Ø�T×0Ñ0Ñ0ØÐ"Ø �Ø1˜4×1Ñ1°&¸&ÑPÀKÑPˆD�LàÐ!¡[Ü Ø�v�jð !"Ø�{Ð"6°{°mÀ1ðFóð ð &1r$   c                 óŒ   — |€t         j                  }t        | j                  | j                  | j
                  |   fd|i|¤Ž}|S )Nr8   )ÚsslÚgcrotmkr   r   r*   Ú_SPLINE_DEGREE_MAP)rM   rC   r8   r9   Úspls        r"   rL   z)RegularGridInterpolator._construct_spline*  sK   € Øˆ>Ü—[‘[ˆFÜØ—	‘	˜4Ÿ;™;¨×(?Ñ(?ÀÑ(Gñàðà!,ñˆð ˆ
r$   c                 ó   — t        ||«       y ©N)r+   )rM   r   r*   s      r"   r+   z-RegularGridInterpolator._check_dimensionality3  s   € Ü˜d FÕ+r$   c                 ó   — t        |«      S rV   )r#   )rM   r   s     r"   r#   z%RegularGridInterpolator._check_points6  s   € Ü˜VÓ$Ð$r$   c                 óþ   — t        |d«      st        j                  |«      }t        |d«      rOt        |d«      rCt        j                  |j                  t        j
                  «      s|j                  t        «      }|S )Nr(   r   Úastype)Úhasattrr   r   Ú
issubdtyper   ÚinexactrY   r   )rM   r*   s     r"   rG   z%RegularGridInterpolator._check_values9  sV   € Ü�v˜vÔ&ä—Z‘Z Ó'ˆFä�6˜7Ô#¬°¸Ô(AÜ—=‘= §¡¬r¯z©zÔ:ØŸ™¤uÓ-�àˆr$   c                 óº   — |�Xt        j                  |«      j                  }t        |d«      r-t        j                  ||j                  d¬«      st        d«      ‚|S )Nr   Ú	same_kind)ÚcastingzDfill_value must be either 'None' or of a type compatible with values)r   r   r   rZ   Úcan_castr   )rM   r*   rI   Úfill_value_dtypes       r"   rH   z)RegularGridInterpolator._check_fill_valueD  sZ   € ØÐ!Ü!Ÿz™z¨*Ó5×;Ñ;ÐÜ˜ Ô(Ü—K‘KÐ 0°&·,±,Ø(3õ5ä ð "Dó Eð EàÐr$   ©Únuc                óð  — | j                   }|€| j                  n|}| j                  |k7  }|| j                  vrt        d|› d�«      ‚|r|| j                  v r| j                  |«      }|�*|| j                  vrt        d| j                  › d|›d�«      ‚| j                  |«      \  }}}}}	|dk(  �r;| j                  |j                  «      \  }
}|dk(  �rt        | j                  d	«      rî| j                  j                  dk(  rÕ| j                  j                  j                  rµ| j                  j                  t        j                   t        j"                  fv r| j                  j                  j$                  d
k(  r\t        j&                  |
j(                  d   | j                  j                  ¬«      }t+        | j                  |
|| j,                  |«      }n | j/                  |
|«      }n�|dk(  r1| j                  |j                  «      \  }
}| j1                  |
|«      }nW|| j2                  v rI|r| j5                  | j,                  |«       || j6                  v r| j9                  ||«      }n
 |||¬«      }| j:                  s| j<                  �| j<                  |	<   t        j>                  |«      rt        j@                  |<   jC                  |dd | j                  j(                  |d z   «      S )a«  
        Interpolation at coordinates.

        Parameters
        ----------
        xi : ndarray of shape (..., ndim)
            The coordinates to evaluate the interpolator at.

        method : str, optional
            The method of interpolation to perform. Supported are "linear",
            "nearest", "slinear", "cubic", "quintic" and "pchip". Default is
            the method chosen when the interpolator was created.

        nu : sequence of ints, length ndim, optional
            If not None, the orders of the derivatives to evaluate.
            Each entry must be non-negative.
            Only allowed for methods "slinear", "cubic" and "quintic".

            .. versionadded:: 1.13

        Returns
        -------
        values_x : ndarray, shape xi.shape[:-1] + values.shape[ndim:]
            Interpolated values at `xi`. See notes for behaviour when
            ``xi.ndim == 1``.

        Notes
        -----
        In the case that ``xi.ndim == 1`` a new axis is inserted into
        the 0 position of the returned array, values_x, so its shape is
        instead ``(1,) + values.shape[ndim:]``.

        Examples
        --------
        Here we define a nearest-neighbor interpolator of a simple function

        >>> import numpy as np
        >>> x, y = np.array([0, 1, 2]), np.array([1, 3, 7])
        >>> def f(x, y):
        ...     return x**2 + y**2
        >>> data = f(*np.meshgrid(x, y, indexing='ij', sparse=True))
        >>> from scipy.interpolate import RegularGridInterpolator
        >>> interp = RegularGridInterpolator((x, y), data, method='nearest')

        By construction, the interpolator uses the nearest-neighbor
        interpolation

        >>> interp([[1.5, 1.3], [0.3, 4.5]])
        array([2., 9.])

        We can however evaluate the linear interpolant by overriding the
        `method` parameter

        >>> interp([[1.5, 1.3], [0.3, 4.5]], method='linear')
        array([ 4.7, 24.3])
        Nr;   r<   z)Can only compute derivatives for methods z, got method =r?   r6   é   r   ú=r   r   r7   rb   r   )"rD   rC   r@   r   rK   rL   Ú_prepare_xiÚ_find_indicesÚTrZ   r*   r(   ÚflagsÚ	writeabler   r   Úfloat64Ú
complex128Ú	byteorderÚemptyr)   r	   r   Ú_evaluate_linearÚ_evaluate_nearestrA   rB   Ú_SPLINE_METHODS_recursiveÚ_evaluate_splinerE   rI   ÚanyÚnanÚreshape)rM   ÚxirC   rc   rD   Úis_method_changedÚxi_shaper(   ÚnansÚout_of_boundsÚindicesÚnorm_distancesÚoutÚresults                 r"   Ú__call__z RegularGridInterpolator.__call__N  sš  € ðr —,‘,ˆØ & �—’°FˆØ ŸK™K¨6Ñ1ÐØ˜×*Ñ*Ñ*Ü˜x¨ xÐ/?Ð@ÓAÐAÙ ¨4×+FÑ+FÑ!FØ×,Ñ,¨VÓ4ˆGàˆ>˜f¨D×,GÑ,GÑGÜØ;Ø×.Ñ.Ð/¨°f°Z¸qðBóð ð
 37×2BÑ2BÀ2Ó2FÑ/ˆˆH�d˜D -à�XÓØ&*×&8Ñ&8¸¿¹Ó&>Ñ#ˆG�^Ø˜“	œg d§k¡k°7Ô;Ø—K‘K×$Ñ$¨Ò)¨d¯k©k×.?Ñ.?×.IÒ.IØ—K‘K×%Ñ%¬"¯*©*´b·m±mÐ)DÑDØ—K‘K×%Ñ%×/Ñ/°3Ò6ô —h‘h˜wŸ}™}¨QÑ/°t·{±{×7HÑ7HÔI�Ü+¨D¯K©KØ,3Ø,:Ø,0¯I©IØ,/ó	1‘ð ×.Ñ.¨w¸ÓG‘Ø�yÒ Ø&*×&8Ñ&8¸¿¹Ó&>Ñ#ˆG�^Ø×+Ñ+¨G°^ÓD‰FØ�t×+Ñ+Ñ+Ù Ø×.Ñ.¨t¯y©y¸&ÔAØ˜×7Ñ7Ñ7Ø×.Ñ.¨r°6Ó:‘á  ¨Ô+�à× Ò  T§_¡_Ð%@Ø$(§O¡OˆF�=Ñ!ô �6‰6�$Œ<ÜŸ6™6ˆF�4‰LØ�~‰~˜h s¨˜m¨d¯k©k×.?Ñ.?ÀÀÐ.FÑFÓGÐGr$   c           	      ó  — t        | j                  «      }t        ||¬«      }|j                  d   t        | j                  «      k7  rt	        d|j                  d   › d|› �«      ‚|j                  }|j                  d|d   «      }t        j                  |t        ¬«      }t        j                  t        j                  |«      d¬«      }| j                  r�t        |j                  «      D ]u  \  }}t        j                  t        j                  | j                  |   d   |k  «      t        j                  || j                  |   d   k  «      «      rŒit	        d|z  «      ‚ d }n| j!                  |j                  «      }|||||fS )	N©r(   r   z.The requested sample points xi have dimension z0 but this RegularGridInterpolator has dimension r   r=   r   ú8One of the requested xi is out of bounds in dimension %d)r'   r   r   r)   r   rv   r   r   r   rt   ÚisnanrE   r   ri   Úlogical_andr   Ú_find_out_of_bounds)rM   rw   r(   ry   rz   r    r!   r{   s           r"   rg   z#RegularGridInterpolator._prepare_xi»  s]  € Ü�4—9‘9‹~ˆÜ% b¨tÔ4ˆØ�8‰8�B‰<œ3˜tŸy™y›>Ò)ÜÐMØ "§¡¨¡˜~ð .FØFJÀVðMó Nð Nð —8‘8ˆØ�Z‰Z˜˜H R™LÓ)ˆÜ�Z‰Z˜¤%Ô(ˆô �v‰v”b—h‘h˜r“l¨Ô,ˆà×ÒÜ! "§$¡$›ò <‘��1Ü—~‘~¤b§f¡f¨T¯Y©Y°q©\¸!©_ÀÑ-AÓ&BÜ&(§f¡f¨Q°$·)±)¸A±,¸rÑ2BÑ-BÓ&CõEä$ð &7Ø9:ñ&;ó <ð <ð<ð
 !‰Mà ×4Ñ4°R·T±TÓ:ˆMà�8˜T 4¨Ð6Ð6r$   c                 ó  — t        d «      fd| j                  j                  t        |«      z
  z  z   }|D �cg c]  }d|z
  ‘Œ	 }}|D �cg c]  }|dz   ‘Œ	 }}t	        ||«      }t	        ||«      }	t        j                  t	        ||	«      Ž }
t        j                  dg«      }|
D ]\  }t	        |Ž \  }}t        j                  dg«      }|D ]  }||z  }Œ	 t        j                  | j                  |   «      ||   z  }||z   }Œ^ |S c c}w c c}w )NrV   r   g        g      ð?)
Úslicer*   r(   r'   ÚzipÚ	itertoolsÚproductr   Úarrayr   )rM   r|   r}   ÚvsliceÚyiÚshift_norm_distancesr    Úshift_indicesÚzipped1Úzipped2Ú	hypercubeÚvalueÚhÚedge_indicesÚweightsÚweightÚwÚterms                     r"   rp   z(RegularGridInterpolator._evaluate_linearÖ  s  € ä˜“+� '¨4¯;©;×+;Ñ+;¼cÀ'»lÑ+JÑ"KÑKˆð 2@Ö@¨2  B£Ð@ÐÐ@Ø(/Ö0 1˜˜Q›Ð0ˆÐ0ô �gÐ3Ó4ˆÜ�m ^Ó4ˆô
 ×%Ñ%¤s¨7°GÓ'<Ð=ˆ	Ü—‘˜"˜“ˆØò 	!ˆAÜ$'¨ GÑ!ˆL˜'Ü—X‘X˜r˜d“^ˆFØò $�Ø !™‘ð$ä—:‘:˜dŸk™k¨,Ñ7Ó8¸6À&¹>ÑIˆDØ˜D‘L‰Eð	!ð ˆùò1  AùÚ0s   ·DÁ	D	c           
      ó°   — t        ||«      D ��cg c]"  \  }}t        j                  |dk  ||dz   «      ‘Œ$ }}}| j                  t	        |«         S c c}}w )Ng      à?r   )r‰   r   Úwherer*   r   )rM   r|   r}   r    rŽ   Úidx_ress         r"   rq   z)RegularGridInterpolator._evaluate_nearestõ  sW   € ä # G¨^Ó <÷>Ù�q˜"ô —8‘8˜B "™H a¨¨Q©Õ/ð >ˆñ >à�{‰{œ5 ›>Ñ*Ð*ùó>s   �'Ac                 óÄ   — | j                   |   }t        |«      D ]C  \  }}t        t        j                  |«      «      }||k  sŒ*t        d|› d|› d|› d|dz   › d�	«      ‚ y )Nz
There are z points in dimension z, but method z requires at least  r   z points per dimension.)rS   r   r'   r   Ú
atleast_1dr   )rM   r   rC   Úkr    Úpointr(   s          r"   rB   z1RegularGridInterpolator._validate_grid_dimensionsú  s„   € Ø×#Ñ# FÑ+ˆÜ! &Ó)ò 	B‰HˆAˆuÜ”r—}‘} UÓ+Ó,ˆDØ�q‹yÜ  :¨d¨VÐ3HÈÈð L0Ø06¨xð 8%Ø%& q¡S EÐ)?ð"Aó Bð Bñ	Br$   c           	      óö  — |j                   dk(  r|j                  d|j                  f«      }|j                  \  }}t	        t        | j                  j                   «      «      }|d | d d d…   ||d  z   }| j                  j                  |«      }|dk(  r| j                  }n| j                  }| j                  |   }	|dz
  }
 || j                  |
   ||d d …|
f   |	«      }|g| j                  j                  |d  ¢­}t        j                  || j                  j                  ¬«      }t        |«      D ]B  }||df   }t        |
dz
  dd«      D ]  } || j                  |   ||||f   |	«      }Œ! |||df<   ŒD |S )Nr   r   r2   r   .)r(   rv   Úsizer)   r   Úranger*   Ú	transposeÚ	_do_pchipÚ_do_spline_fitrS   r   r   ro   r   )rM   rw   rC   ÚmÚnÚaxesÚaxxr*   Ú
_eval_funcr    Úlast_dimÚfirst_valuesr)   r   ÚjÚfolded_valuesr    s                    r"   rs   z(RegularGridInterpolator._evaluate_spline  s’  € ð �7‰7�aŠ<Ø—‘˜Q §¡˜LÓ)ˆBØ�x‰x‰ˆˆ1ô ”U˜4Ÿ;™;×+Ñ+Ó,Ó-ˆØ�2�Aˆh‘t˜�t‰n˜t A B˜xÑ'ˆØ—‘×&Ñ& sÓ+ˆà�WÒØŸ™‰Jà×,Ñ,ˆJØ×#Ñ# FÑ+ˆð �q‘5ˆÙ! $§)¡)¨HÑ"5Ø"(Ø"$¢Q¨ [¡/Ø"#ó%ˆð Ð+�T—[‘[×&Ñ& q rÐ*Ñ+ˆÜ—‘˜% t§{¡{×'8Ñ'8Ô9ˆÜ�q“ò 	+ˆAð )¨¨C¨Ñ0ˆMÜ˜8 A™: r¨2Ó.ò .�ñ !+¨4¯9©9°Q©<Ø+8Ø+-¨a°¨d©8Ø+,ó!.‘ð.ð +ˆF�1�c�6ŠNð	+ð ˆr$   c                 ó4   — t        | ||d¬«      } ||«      }|S )Nr   )r    r>   r   ©ÚxÚyÚptr    Úlocal_interpr*   s         r"   r§   z&RegularGridInterpolator._do_spline_fit:  s!   € ä)¨!¨Q°!¸!Ô<ˆÙ˜bÓ!ˆØˆr$   c                 ó2   — t        | |d¬«      } ||«      }|S )Nr   r=   r   r²   s         r"   r¦   z!RegularGridInterpolator._do_pchip@  s   € ä(¨¨A°AÔ6ˆÙ˜bÓ!ˆØˆr$   c                 ó.   — t        | j                  |«      S rV   )r
   r   )rM   rw   s     r"   rh   z%RegularGridInterpolator._find_indicesF  s   € Ü˜DŸI™I rÓ*Ð*r$   c                 ó¾   — t        j                  |j                  d   t        ¬«      }t	        || j
                  «      D ]  \  }}|||d   k  z  }|||d   kD  z  }Œ |S )Nr   r   r   r   )r   Úzerosr)   Úboolr‰   r   )rM   rw   r{   r³   r   s        r"   r†   z+RegularGridInterpolator._find_out_of_boundsI  sd   € äŸ™ "§(¡(¨1¡+´dÔ;ˆä˜2˜tŸy™yÓ)ò 	*‰GˆAˆtØ˜Q  a¡™[Ñ(ˆMØ˜Q  b¡™\Ñ)‰Mð	*ð Ðr$   rV   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rS   rr   rK   ÚlistÚkeysrA   r@   r   ru   rO   rL   r+   r#   rG   rH   r€   rg   rp   rq   rB   rs   Ústaticmethodr§   r¦   rh   r†   © r$   r"   r   r   4   sè   „ ñJð\ &'°¸qÈ1Ø,-¸qÐTUñXÐò!;Ðâ<ÐÙÐ-×2Ñ2Ó4Ó5€OØ˜iÐ(¨?Ñ:€Là.6ÀTØŸF™FðØ.2Àôó>ò,ò%ò	òðkH¨dô kHòZ7ò6ò>+ò
Bò5ðn ñó ðð
 ñó ðò
+ór$   r6   Tc           	      ó¸  — |dvrt        d|› d�«      ‚t        |d«      st        j                  |«      }|j                  }|dkD  r|dk(  rt        d«      ‚|s|€|dk(  rt        d	«      ‚t        | «      |kD  rt        d
t        | «      |fz  «      ‚t        | «      |k7  r|dk(  rt        d«      ‚t        | «      \  }}t        ||«       t        |t        |«      ¬«      }|j                  d   t        |«      k7  r&t        d|j                  d   t        |«      fz  «      ‚|ryt        |j                  «      D ]a  \  }	}
t        j                  t        j                  ||	   d   |
k  «      t        j                  |
||	   d   k  «      «      rŒUt        d|	z  «      ‚ |t        j                  v rt        | ||||¬«      } ||«      S |dk(  �r|j                  }|j!                  d|j                  d   «      }t        j                  |d   d   |dd…df   k  |dd…df   |d   d   k  |d   d   |dd…df   k  |dd…df   |d   d   k  fd¬«      }t        j"                  |dd…df   «      }t%        | d   | d   |dd «      }|j'                  ||df   ||df   «      ||<   ||t        j(                  |«      <   |j!                  |dd «      S t        d|›�«      ‚)a�  
    Multidimensional interpolation on regular or rectilinear grids.

    Strictly speaking, not all regular grids are supported - this function
    works on *rectilinear* grids, that is, a rectangular grid with even or
    uneven spacing.

    Parameters
    ----------
    points : tuple of ndarray of float, with shapes (m1, ), ..., (mn, )
        The points defining the regular grid in n dimensions. The points in
        each dimension (i.e. every elements of the points tuple) must be
        strictly ascending or descending.

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

        .. deprecated:: 1.13.0
            Complex data is deprecated with ``method="pchip"`` and will raise an
            error in SciPy 1.15.0. This is because ``PchipInterpolator`` only
            works with real values. If you are trying to use the real components of
            the passed array, use ``np.real`` on ``values``.

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

    method : str, optional
        The method of interpolation to perform. Supported are "linear",
        "nearest", "slinear", "cubic", "quintic", "pchip", 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 `xi`. See notes for behaviour when
        ``xi.ndim == 1``.

    See Also
    --------
    NearestNDInterpolator : Nearest neighbor interpolation on unstructured
                            data in N dimensions
    LinearNDInterpolator : Piecewise linear interpolant on unstructured data
                           in N dimensions
    RegularGridInterpolator : interpolation on a regular or rectilinear grid
                              in arbitrary dimensions (`interpn` wraps this
                              class).
    RectBivariateSpline : Bivariate spline approximation over a rectangular mesh
    scipy.ndimage.map_coordinates : interpolation on grids with equal spacing
                                    (suitable for e.g., N-D image resampling)

    Notes
    -----

    .. versionadded:: 0.14

    In the case that ``xi.ndim == 1`` a new axis is inserted into
    the 0 position of the returned array, values_x, so its shape is
    instead ``(1,) + values.shape[ndim:]``.

    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 interpolation.

    Examples
    --------
    Evaluate a simple example function on the points of a regular 3-D grid:

    >>> import numpy as np
    >>> from scipy.interpolate import interpn
    >>> def value_func_3d(x, y, z):
    ...     return 2 * x + 3 * y - z
    >>> x = np.linspace(0, 4, 5)
    >>> y = np.linspace(0, 5, 6)
    >>> z = np.linspace(0, 6, 7)
    >>> points = (x, y, z)
    >>> values = value_func_3d(*np.meshgrid(*points, indexing='ij'))

    Evaluate the interpolating function at a point

    >>> point = np.array([2.21, 3.12, 1.15])
    >>> print(interpn(points, values, point))
    [12.63]

    )
r6   r7   r0   r1   r2   Ú	splinef2dr/   r3   r4   r5   z€interpn only understands the methods 'linear', 'nearest', 'slinear', 'cubic', 'quintic', 'pchip', and 'splinef2d'. You provided r?   r(   re   rÅ   zBThe method splinef2d can only be used for 2-dimensional input dataNz4The method splinef2d does not support extrapolation.r&   zSThe method splinef2d can only be used for scalar data with one point per coordinater‚   r   zcThe requested sample points xi have dimension %d, but this RegularGridInterpolator has dimension %dr   rƒ   )rC   rE   rI   r   r=   zunknown method = )r   rZ   r   r   r(   r'   r#   r+   r   r)   r   ri   r…   r   r   r@   rv   Ú
empty_liker   ÚevÚlogical_not)r   r*   rw   rC   rE   rI   r(   r   r   r    r!   Úinterpry   Ú	idx_validr   s                  r"   r   r   S  s=  € ðF ð Jñ Jô ð :à:@¸ÀðDó Eð 	Eô �6˜6Ô"Ü—‘˜FÓ#ˆà�;‰;€DØˆa‚x�F˜kÒ)Üð 4ó 5ð 	5á˜JÐ.°6¸[Ò3HÜÐOÓPÐPô ˆ6ƒ{�TÒÜð &Ü),¨V«°dÐ(;ñ<ó =ð 	=ä
ˆ6ƒ{�dÒ˜v¨Ò4Üð Eó Fð 	Fô #0°Ó"7Ñ€DÐ
Ü˜$ Ô'ô 
" "¬3¨t«9Ô	5€BØ	‡x�x��|”s˜4“yÒ Üð (à+-¯8©8°B©<¼¸T»Ð*CñDó Eð 	Eñ Ü˜bŸd™d“Oò 	8‰DˆAˆqÜ—>‘>¤"§&¡&¨¨a©°©°q©Ó"9Ü"$§&¡&¨¨d°1©g°b©kÑ)9Ó":õ<ä ð "3Ø56ñ"7ó 8ð 8ð	8ð Ô(×5Ñ5Ñ5Ü(¨°ÀØ6BØ4>ô@ˆñ �b‹zÐØ	�;Ó	Ø—8‘8ˆØ�Z‰Z˜˜BŸH™H R™LÓ)ˆô —F‘F˜D ™G A™J¨"ªQ°¨T©(Ñ2°B²q¸!°t±HÀÀQÁÈÁÑ4KØ  ™G A™J¨"ªQ°¨T©(Ñ2°B²q¸!°t±HÀÀQÁÈÁÑ4KðMà !ô#ˆ	ô —‘˜r¢! Q $™xÓ(ˆô % V¨A¡Y°°q±	¸6Á!¸9ÓEˆØ"ŸI™I b¨°A¨Ñ&6¸¸9Àa¸<Ñ8HÓIˆˆyÑØ,6ˆŒr�~‰~˜iÓ(Ñ)à�~‰~˜h s¨˜mÓ,Ð,äÐ- F ;Ð/Ó0Ð0r$   )Ú__all__rŠ   Únumpyr   Úscipy.sparse.linalgÚsparseÚlinalgrQ   Ú	_interpndr   Ú_cubicr   Ú_rgi_cythonr	   r
   Ú	_bsplinesr   Ú	_fitpack2r   Ú
_ndbspliner   r#   r+   r   ru   r   rÃ   r$   r"   ú<module>rÖ      sY   ðØ$ iÐ
0€ã ã ç !Ð !å /Ý %ß 9Ý )Ý *Ý #ò5ò,
L÷\ñ \ð~ (0¸dØ—v‘vôd1r$   