a
    Sic$                     @   s&   d dl Zd dlmZ G dd dZdS )    N)_apic                   @   sr   e Zd ZdZdddZdd Zedd Zd	d
 Zdd Z	e
dd Ze
dd Zdd Zedd Zdd ZdS )Triangulationa"  
    An unstructured triangular grid consisting of npoints points and
    ntri triangles.  The triangles can either be specified by the user
    or automatically generated using a Delaunay triangulation.

    Parameters
    ----------
    x, y : (npoints,) array-like
        Coordinates of grid points.
    triangles : (ntri, 3) array-like of int, optional
        For each triangle, the indices of the three points that make
        up the triangle, ordered in an anticlockwise manner.  If not
        specified, the Delaunay triangulation is calculated.
    mask : (ntri,) array-like of bool, optional
        Which triangles are masked out.

    Attributes
    ----------
    triangles : (ntri, 3) array of int
        For each triangle, the indices of the three points that make
        up the triangle, ordered in an anticlockwise manner. If you want to
        take the *mask* into account, use `get_masked_triangles` instead.
    mask : (ntri, 3) array of bool
        Masked out triangles.
    is_delaunay : bool
        Whether the Triangulation is a calculated Delaunay
        triangulation (where *triangles* was not specified) or not.

    Notes
    -----
    For a Triangulation to be valid it must not have duplicate points,
    triangles formed from colinear points, or overlapping triangles.
    Nc              
   C   s  ddl m} tj|tjd| _tj|tjd| _| jj| jjksL| jjdkrht	d| jjd| jjd | _
d | _d | _d| _|d u r|||\| _| _d| _nztj|tjd	d
| _W n4 t	y } zt	d||W Y d }~n
d }~0 0 | jjdks| jjd dkr$t	d| jj| j t| jkrZt	dt| j d| j  | j dk rt	dt| j d| j  d | _d | _| | d S )Nr   )_qhulldtype   z9x and y must be equal-length 1D arrays, but found shapes z and FTC)r   orderz*triangles must be a (N, 3) int array, not       z6triangles must be a (N, 3) int array, but found shape zHtriangles are indices into the points and must be in the range 0 <= i < z but found value )
matplotlibr   npasarrayfloat64xyshapendim
ValueErrormask_edges
_neighborsis_delaunayZdelaunay	trianglesarrayint32maxlenmin_cpp_triangulation
_trifinderset_mask)selfr   r   r   r   r   e r$   X/var/www/html/django/DPS/env/lib/python3.9/site-packages/matplotlib/tri/triangulation.py__init__(   sb     zTriangulation.__init__c                 C   s   |   |S )au  
        Calculate plane equation coefficients for all unmasked triangles from
        the point (x, y) coordinates and specified z-array of shape (npoints).
        The returned array has shape (npoints, 3) and allows z-value at (x, y)
        position in triangle tri to be calculated using
        ``z = array[tri, 0] * x  + array[tri, 1] * y + array[tri, 2]``.
        )get_cpp_triangulationcalculate_plane_coefficients)r"   zr$   r$   r%   r(   [   s    z*Triangulation.calculate_plane_coefficientsc                 C   s   | j du r|   | _ | j S )aM  
        Return integer array of shape (nedges, 2) containing all edges of
        non-masked triangles.

        Each row defines an edge by its start point index and end point
        index.  Each edge appears only once, i.e. for an edge between points
        *i*  and *j*, there will only be either *(i, j)* or *(j, i)*.
        N)r   r'   Z	get_edgesr"   r$   r$   r%   edgese   s    

zTriangulation.edgesc              	   C   sD   ddl m} | jdu r>|| j| j| j| j| j| j	| j
 | _| jS )zc
        Return the underlying C++ Triangulation object, creating it
        if necessary.
        r   )_triN)r   r,   r   r   r   r   r   r   r   r   r   )r"   r,   r$   r$   r%   r'   s   s    

z#Triangulation.get_cpp_triangulationc                 C   s"   | j dur| j| j   S | jS dS )zL
        Return an array of triangles taking the mask into account.
        N)r   r   r*   r$   r$   r%   get_masked_triangles   s    
z"Triangulation.get_masked_trianglesc                  O   sl   t | d tr<| ^}} d|v r(td d|v rbtd n&t| |\}}}}} }t||||}|| |fS )a  
        Return a Triangulation object from the args and kwargs, and
        the remaining args and kwargs with the consumed values removed.

        There are two alternatives: either the first argument is a
        Triangulation object, in which case it is returned, or the args
        and kwargs are sufficient to create a new Triangulation to
        return.  In the latter case, see Triangulation.__init__ for
        the possible args and kwargs.
        r   r   zOPassing the keyword 'triangles' has no effect when also passing a Triangulationr   zJPassing the keyword 'mask' has no effect when also passing a Triangulation)
isinstancer   r   warn_external_extract_triangulation_params)argskwargstriangulationr   r   r   r   r$   r$   r%   get_from_args_and_kwargs   s    
z&Triangulation.get_from_args_and_kwargsc                 C   s   | ^}}} | dd }d}|d u r2| r2| d }d}|d urfztj|tjd}W n tyd   d }Y n0 |d ur|jdks|jd dkrd }|d ur|r| dd  } | d	d }||||| |fS )
Nr   Fr   Tr   r
   r   r   r   )popr   r   r   r   r   r   )r1   r2   r   r   r   Z	from_argsr   r$   r$   r%   r0      s&    

z+Triangulation._extract_triangulation_paramsc                 C   s&   | j du r ddlm} || | _ | j S )z
        Return the default `matplotlib.tri.TriFinder` of this
        triangulation, creating it if necessary.  This allows the same
        TriFinder object to be easily shared.
        Nr   )TrapezoidMapTriFinder)r    Zmatplotlib.tri.trifinderr6   )r"   r6   r$   r$   r%   get_trifinder   s    

zTriangulation.get_trifinderc                 C   s   | j du r|   | _ | j S )a  
        Return integer array of shape (ntri, 3) containing neighbor triangles.

        For each triangle, the indices of the three triangles that
        share the same edges, or -1 if there is no such neighboring
        triangle.  ``neighbors[i, j]`` is the triangle that is the neighbor
        to the edge from point index ``triangles[i, j]`` to point index
        ``triangles[i, (j+1)%3]``.
        N)r   r'   Zget_neighborsr*   r$   r$   r%   	neighbors   s    
zTriangulation.neighborsc                 C   sz   |du rd| _ n.tj|td| _ | j j| jjd fkr>td| jdurV| j| j  d| _	d| _
| jdurv| j  dS )z
        Set or clear the mask array.

        Parameters
        ----------
        mask : None or bool array of length ntri
        Nr   r   z3mask array must have same length as triangles array)r   r   r   boolr   r   r   r   r!   r   r   r    _initialize)r"   r   r$   r$   r%   r!      s    

zTriangulation.set_mask)NN)__name__
__module____qualname____doc__r&   r(   propertyr+   r'   r-   staticmethodr4   r0   r7   r8   r!   r$   r$   r$   r%   r      s   !
3

	


r   )numpyr   r   r   r   r$   r$   r$   r%   <module>   s   