403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.216.52
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 :  /usr/lib/python3/dist-packages/matplotlib/testing/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/matplotlib/testing/__pycache__/compare.cpython-312.pyc
�

G8�c�J����dZddlZddlZddlZddlZddlZddlmZddlZddl	Z	ddl
Z
ddlmZm
Z
ddlZddlZddlmZddlZddlmZddlmZej0e�Zgd�Zd	�Zd
�Zd�Zd!d�ZGd
�de �Z!Gd�d�Z"Gd�de"�Z#Gd�de"�Z$Gd�de$�Z%d�Z&iZ'e&�e%�Z(d�Z)d�Z*d�Z+ejX�d��Z-d�Z.d�Z/d�Z0d"d�Z1d �Z2y)#z(
Utilities for comparing image results.
�N)�Path)�TemporaryDirectory�
TemporaryFile)�Image)�cbook)�ImageComparisonFailure)�
calculate_rms�comparable_formats�compare_imagesc�X�tjj|�\}}|�d|�|��S)zQ
    Make a new filename by inserting *purpose* before the file's extension.
    �-)�os�path�splitext)�fname�purpose�base�exts    �</usr/lib/python3/dist-packages/matplotlib/testing/compare.py�make_test_filenamers)����� � ��'�I�D�#��g�s�+�+�c�h�ttj�d�}|jdd��|S)N�
test_cacheT)�parents�exist_ok)r�mpl�get_cachedir�mkdir)�	cache_dirs r�_get_cache_pathr %s-���S�%�%�'��6�I�
�O�O�D�4�O�0��rc�(�tt��S�N)�strr �rr�
get_cache_dirr%+s���� �!�!rc�t�tj�}t|d�5}	|j|�}|sn|j	|��&	ddd�t|�jdk(rV|j	ttjd�j�jd��|j�St|�jdk(rF|j	ttjd�j�jd��|j�S#1swY��xYw)N�rbz.pdf�gszutf-8�.svg�inkscape)
�hashlib�md5�open�read�updater�suffixr#r�_get_executable_info�version�encode�	hexdigest)r�
block_sizer,�fd�datas     r�
get_file_hashr8/s���
�+�+�-�C�	
�d�D�	��R���7�7�:�&�D����J�J�t��	��	��D�z���F�"��
�
�3�s�/�/��5�=�=�>��F�7�O�	%��=�=�?��	
�d��	�	�f�	$��
�
�3�s�/�/�
�;�C�C�D��F�7�O�	%��=�=�?����s�(D.�.D7c��eZdZy)�_ConverterErrorN)�__name__�
__module__�__qualname__r$rrr:r:Bs��rr:c��eZdZd�Zd�Zd�Zy)�
_Converterc�P�d|_tj|j�yr")�_proc�atexit�register�__del__)�selfs r�__init__z_Converter.__init__Gs����
�
	������%rc�T�|jr�|jj�|jj�td|jj|jj
|jjg�D]}|j��d|_yyr")rA�kill�wait�filter�stdin�stdout�stderr�close)rE�streams  rrDz_Converter.__del__Os���:�:��J�J�O�O���J�J�O�O�� ���
�
�(8�(8�(,�
�
�(9�(9�(,�
�
�(9�(9�(;�<�
������
��D�J�rc��t�}	|jjjd�}|s't	tjt|����|j|�|j|�rt|�S�|)z!Read until the prompt is reached.�)
�	bytearrayrArLr.r:r�fsdecode�bytes�extend�endswith)rE�
terminator�buf�cs    r�_read_untilz_Converter._read_untilYsg���k����
�
�!�!�&�&�q�)�A��%�b�k�k�%��*�&=�>�>��J�J�q�M��|�|�J�'��S�z�!�
rN)r;r<r=rFrDrZr$rrr?r?Fs��&��	"rr?c��eZdZd�Zy)�_GSConverterc��|jsmtjtjd�j
ddddgtjtj��|_	|jd�d
�}|jjjd||�zdz||�zd
z�|jjj�|jd�}|jd�r|jd�nd}|stj j#|�sj|rt%|dd�nd	}|jjjd|z�t'||zj)t+j,�d���y#t$r!}td|jd	z�d�d}~wwxYw)Nr(z	-dNOSAFERz	-dNOPAUSEz	-dEPSCropz-sDEVICE=png16m)rKrLs
GSzFailed to start Ghostscript:

rc��tj|�jdd�jdd�jdd�S)N�\s\\�(s\(�)s\))r�fsencode�replace)�names r�encode_and_escapez0_GSConverter.__call__.<locals>.encode_and_escapess7���K�K��%��W�U�G�,��W�T�6�*��W�T�6�*�
,rs<< /OutputFile (s) >> setpagedevice (s) run flush
)�GS<sGS>rf�>r���spop
rc)rA�
subprocess�Popenrr1�
executable�PIPErZr:�OSError�argsrK�write�flushrVrr�exists�intr�decode�sys�getfilesystemencoding)rE�orig�dest�errre�stack�
stack_sizes       r�__call__z_GSConverter.__call__fs����z�z�#�)�)��)�)�$�/�:�:��k�;�8I�K�!�o�o�j�o�o�	?�D�J�

P�� � ��)�
	,�	
�
�
��������%�
&�%�
&� ��%�
&��	
�	 �	
�
�
����� ����/�0��*-�,�,�v�*>�� � ��&�C��������t�,�,1��U�3�B�Z��q�J��J�J���"�"�8�j�#8�9�(��u��$�$�S�%>�%>�%@�)�L�N�
N�	-��)#�
P��6����!��D�F�KO�P��
P�s�)F�	G	�(G�G	N)r;r<r=r{r$rrr\r\es��"Nrr\c�$��eZdZd�Z�fd�Z�xZS)�
_SVGConverterc��tjd�jjdk}|rdnd}t	|d�s9t�|_tj|j|j�|jr|jj���6|j�z|jj��`td|jj|jj|jjg�D]}|j!��it"j$�d|jj&d��}t)�}t+j,|rgd�ndd	gt*j.t*j.|||jj&�
�|_
||j_	|j1|�t9|jj&t#j:d
��}	t9|jj&t#j:d��}
	|	j=t9|�j?��|jjjE|rdnd�|jjjG�	|j1|�t#jT|	�tAjV|
|�y#t2$r!}t5d|j6dz�|�d}~wwxYw#t4$rtAjB||	�Y��wxYw#t2$rz}|jjjId�tK|jjjM�jOtQjR�d��|�d}~wwxYw)Nr*rQs
>s> �_tmpdir�)�DISPLAY�INKSCAPE_PROFILE_DIR)r*z
--without-gui�--shellr�)rKrLrM�env�cwdz/Failed to start Inkscape in interactive mode:

rsf.svgsf.pngsf.svg --export-png=f.png
s;file-open:f.svg;export-filename:f.png;export-do;file-close
rc),rr1r2�major�hasattrrr�weakref�finalizerDrA�pollrJrKrLrMrNr�environrdrrirjrlrZr:rmrnrrS�
symlink_to�resolve�shutil�copyfilerorp�seekrr.rsrtru�remove�move)rErvrw�old_inkscaperWrOr�rMrx�
inkscape_orig�
inkscape_dests           rr{z_SVGConverter.__call__�s����/�/�
�;�C�C�I�I�A�M��+�V��
��t�Y�'�-�/�D�L�
���T�\�\�4�<�<�8��
�
��:�:�?�?�$�0��z�z�%�$�*�*�/�/�*;�*G�$�T�D�J�J�,<�,<�,0�J�J�,=�,=�,0�J�J�,=�,=�,?�@�#�F��L�L�N�#�
��*�*�
��(,���(9�(9�
�C�#�_�F�#�)�)�<H�8��Y�'� �o�o�j�o�o�f��T�\�\�.�.�	0�D�J�!'�D�J�J��
,�� � ��,��T�\�\�.�.����H�0E�F�
��T�\�\�.�.����H�0E�F�
�	1��$�$�T�$�Z�%7�%7�%9�:�	
�
�
�����-9�)�K�	M�	
�
�
����� �		F����Z�(�	�	�	�-� ����M�4�(��;#�
,��G��h�h�q�k�"�#�(+�,��
,���	1��O�O�D�-�0�	1���	F�
�J�J���"�"�1�%�(��
�
�!�!�&�&�(�/�/��-�-�/��<�=�BE�
F��	F�sC�K/�<(L�2M�/	L�8L�L�L>�=L>�	O�
A5N?�?Oc�p��t�|��t|d�r|jj	�yy)Nr)�superrDr�r�cleanup)rE�	__class__s �rrDz_SVGConverter.__del__�s,���
�����4��#��L�L� � �"�$r)r;r<r=r{rD�
__classcell__�r�s@rr}r}�s���E)�N#�#rr}c�"��eZdZdZ�fd�Z�xZS)� _SVGWithMatplotlibFontsConverterz�
    A SVG converter which explicitly adds the fonts shipped by Matplotlib to
    Inkspace's font search path, to better support `svg.fonttype = "none"`
    (which is in particular used by certain mathtext tests).
    c����t|d�sVt�|_tjtjd�t|jjd��t�|�)||�S)Nrz	fonts/ttf�fonts)r�rrr��copytreer�_get_data_pathrrdr�r{)rErvrwr�s   �rr{z)_SVGWithMatplotlibFontsConverter.__call__�sV����t�Y�'�-�/�D�L��O�O�E�0�0��=� ����!2�!2�G�<�
>��w���d�+�+r)r;r<r=�__doc__r{r�r�s@rr�r��s����,�,rr�c��	tjd�t�xtd<td<	tjd�t�td<y#tj$rY�=wxYw#tj$rYywxYw)Nr(�pdf�epsr*�svg)rr1r\�	converter�ExecutableNotFoundErrorr}r$rr�_update_converterr��s���=�� � ��&�/;�n�<�	�%��9�U�+�+�� � ��,�)�?�	�%����&�&�
��
���&�&�
��
�s"�A�A2�A/�.A/�2B�Bc��dgt�S)z�
    Return the list of file formats that `.compare_images` can compare
    on this system.

    Returns
    -------
    list of str
        E.g. ``['png', 'pdf', 'svg', 'eps']``.

    �png)r�r$rrr
r
s��
��I��rc���t|�}|j�st|�d���|jddtvr#ddl}|j
d|j�d��|j|j�d|jdd�d�z}|j�r6|j�j|j�jk�r
|r
t�nd}|�nt�t|�}|||jzz}|j�r7tjd	|�t!j"||�t%|�Stjd
|�t|jdd}|jdk(r|j'�}	d|	vrt(}|||�|�,tjd
|�t!j"|�t%|�S)a�
    Convert the named file to png; return the name of the created file.

    If *cache* is True, the result of the conversion is cached in
    `matplotlib.get_cachedir() + '/test_cache/'`.  The caching is based on a
    hash of the exact contents of the input file.  Old cache entries are
    automatically deleted as needed to keep the size of the cache capped to
    twice the size of all baseline images.
    z does not existrQNrzDon't know how to convert z
 files to png�_z.pngz"For %s: reusing cached conversion.zFor %s: converting to png.r)zstyle="font:z"For %s: caching conversion result.)rrq�IOErrorr0r��pytest�skip�parent�stem�stat�st_mtimer �'_register_conversion_cache_cleaner_oncer8�_log�debugr�r�r#�	read_text�$_svg_with_matplotlib_fonts_converter)
�filename�cacherr��newpathr�
hash_value�cached_path�convert�contentss
          rr�r�s�����>�D��;�;�=����o�.�/�/��{�{�1�2��i�'�����0����
�]�K�L��k�k�t�y�y�k��4�;�;�q�r�?�*;�4�@�@�G��>�>��w�|�|�~�6�6�����9M�9M�M�).�O�%�D�	�� �3�5�&�t�,�J�#�z�G�N�N�'B�C�K��!�!�#��
�
�?��J�����W�5��7�|�#��
�
�/��:��D�K�K���O�,���;�;�&� ��~�~�'�H���)�?����g��� ��J�J�;�X�F��O�O�G�[�1��w�<�rc�J��td�ttj�jjd�D��}d|z}t
jt��5t�jd�D�cic]}||j���c}�td��j�D��}t��fd�d��}||kDr8|j�}|�|jz}|j�||kDr�8ddd�ycc}w#1swYyxYw)	Nc3�PK�|]}|j�j��� y�wr")r��st_size)�.0rs  r�	<genexpr>z*_clean_conversion_cache.<locals>.<genexpr>Bs&����O��	
�	�	����O�s�$&z**/baseline_images/**/*��*c3�4K�|]}|j���y�wr")r�)r�r�s  rr�z*_clean_conversion_cache.<locals>.<genexpr>Ls����F�$����F�s�c�"���|jSr")�st_atime)r�
cache_stats �r�<lambda>z)_clean_conversion_cache.<locals>.<lambda>Ns����D�)9�)B�)B�rT)�key�reverse)�sumrr�__file__r��globr�
_lock_pathr r��values�sorted�popr��unlink)�baseline_images_size�max_cache_sizer�
cache_size�paths_by_atimer�s     @r�_clean_conversion_cacher�?s����O�����&�-�-�2�2�3L�M�O�O��
�-�-�N�	�	�	�/�+�	,�
�*9�*;�*@�*@��*E�G�"&�D�$�)�)�+��G�
��F�*�2C�2C�2E�F�F�
���B�����>�)�!�%�%�'�D��*�T�*�2�2�2�J��K�K�M��>�)�
�
��G�
�
�s�&D�D�A0D�D�D"c�6�tjt�yr")rBrCr�r$rrr�r�Vs��
�O�O�+�,rc��|dddk(r{|dddk(rs|j\}}}|j\}}}	|t|dz|dzz
�t|dz|dzz��t|dz|dzz
�t|dz|dzz��f}||fS)Ni�������r�r�r�)�shaperr)
�actual_path�actual_image�
expected_path�expected_image�aw�ah�ad�ew�eh�eds
          r�crop_to_samer�[s����2�b��U�"�}�R��';�u�'D�!�'�'�
��B��#�)�)�
��B��#�C��Q���a���$8����F�R�!�V�O�:�%�!�"�q�&�2��6�/�2�3�r�A�v��Q���3G�G�%H�I����'�'rc�
�|j|jk7r/tdj|j|j���tj||z
jt�dzj��S)zR
    Calculate the per-pixel errors, then compute the root mean square error.
    �9Image sizes do not match expected size: {} actual size {}r�)r�r�format�np�sqrt�astype�float�mean)r�r�s  rr	r	fss�����|�1�1�1�$�
�#�V�N�$8�$8�,�:L�:L�M�O�	O��7�7�^�l�2�:�:�5�A�Q�F�L�L�N�O�Orc���tj|�}|jdk7s|j�dddk(r|j	d�}tj|�S)N�RGBA�r��RGB)rr-�mode�
getextremar�r��asarray)r�imgs  r�_load_imager�vsR��
�*�*�T�
�C��x�x�6��S�^�^�-�a�0��3�s�:��k�k�%� ��
�:�:�c�?�rc
��tj|�}tjj|�st	d|z��tj
|�jdk(rt	d|z��tj|�}tjj|�std|z��|jd�d}|dk7rt|d�	�}t|d�	�}t|�}t|�}t||||�\}}t|d
�}|dkrtj||�ry|jtj �}|jtj �}t#||�}||kryt%|||�t'|t)|�t)|�t)|�|��}	|s3gd
�}
dj+|
D�cgc]}|j,di|	����c}�}	|	Scc}w)a+
    Compare two "image" files checking differences within a tolerance.

    The two given filenames may point to files which are convertible to
    PNG via the `.converter` dictionary. The underlying RMS is calculated
    with the `.calculate_rms` function.

    Parameters
    ----------
    expected : str
        The filename of the expected image.
    actual : str
        The filename of the actual image.
    tol : float
        The tolerance (a color value difference, where 255 is the
        maximal difference).  The test fails if the average pixel
        difference is greater than this value.
    in_decorator : bool
        Determines the output format. If called from image_comparison
        decorator, this should be True. (default=False)

    Returns
    -------
    None or dict or str
        Return *None* if the images are equal within the given tolerance.

        If the images differ, the return value depends on  *in_decorator*.
        If *in_decorator* is true, a dict with the following entries is
        returned:

        - *rms*: The RMS of the image difference.
        - *expected*: The filename of the expected image.
        - *actual*: The filename of the actual image.
        - *diff_image*: The filename of the difference image.
        - *tol*: The comparison tolerance.

        Otherwise, a human-readable multi-line string representation of this
        information is returned.

    Examples
    --------
    ::

        img1 = "./baseline/plot.png"
        img2 = "./output/plot.png"
        compare_images(img1, img2, 0.001)

    zOutput image %s does not exist.rzOutput image file %s is empty.z!Baseline image %r does not exist.�.rhr�T)r�zfailed-diffN)�rms�expected�actual�diff�tol)z!Error: Image files did not match.zRMS Value: {rms}zExpected:  
    {expected}zActual:    
    {actual}zDifference:
    {diff}zTolerance: 
    {tol}z
  r$)r�fspathrrq�	Exceptionr�r�r��splitr�r�r�rr��array_equalr��int16r	�save_diff_image�dictr#�joinr�)rrr�in_decorator�	extensionr�r��
diff_imager��results�template�lines            rrr�s���b�Y�Y�v�
�F�
�7�7�>�>�&�!��9�F�B�C�C�	�w�w�v����!�#��8�6�A�B�B��y�y��"�H�
�7�7�>�>�(�#��9�H�D�E�E����s�#�B�'�I��E����t�,���8�4�0��!��*�N��v�&�L�#/���h��$8� �L�.�$�F�M�:�J�
�a�x�
�>�>�.�,�7��$�*�*�2�8�8�4�N��&�&�r�x�x�0�L�
���
5�C�
�c�z���H�f�j�1��s�S��]��f�+�C�
�O��F�G��0���+�+�(�K�$�{�t�{�{�5�W�5�K�L���N��Ls�G6c��t|�}t|�}t||||�\}}tj|�j	t
�}tj|�j	t
�}|j|jk7r/tdj|j|j���tj||z
�}|dz}tj|dd�j	tj�}|jddk(rd|dd�dd�df<tj|�j|d	�
�y)z�
    Parameters
    ----------
    expected : str
        File path of expected image.
    actual : str
        File path of actual image.
    output : str
        File path to save difference image to.
    r��
rr�r��Nr�r�)r�)r�r�r��arrayr�r�r�rr��abs�clip�uint8r�	fromarray�save)rr�outputr�r��abs_diffs      rr	r	�s ��!��*�N��v�&�L�#/���h��$8� �L�.��X�X�n�-�4�4�U�;�N��8�8�L�)�0�0��7�L����|�1�1�1�$�
�#�V�N�$8�$8�,�:L�:L�M�O�	O��v�v�n�|�3�4�H�
��N�H��w�w�x��C�(�/�/����9�H��~�~�a��A�����A�q���	�O�O�H��"�"�6�%�"�8r)i)F)3r�rB�	functoolsr+�loggingr�pathlibrr�rirt�tempfilerrr��numpyr��PILr�
matplotlibrr�matplotlib.testing.exceptionsr�	getLoggerr;r��__all__rr r%r8rr:r?r\r}r�r�r�r�r
r�r��	lru_cacher�r�r	r�rr	r$rr�<module>r(s
�������	��
��
�6������@��w����"��
C��,��"��&	�i�	�"�"�>#N�:�#N�LK#�J�K#�\,�}�,�+�&
�	���'G�'I�$��.�b�.�����-��-�(�	P� �e�P9r

Youez - 2016 - github.com/yon3zu
LinuXploit