§
    îóÉjúO  ã                   ó  — d Z ddlZddlZddlZddlZddlZddlmZ ddlZddl	Z	ddl
Z
ddlmZmZ ddlZddlZddlZddlmZ ddlZddlmZmZ ddlmZ  ej        e¦  «        Zg d¢Zd	„ Zd
„ Zd„ Z d%d„Z! G d„ de"¦  «        Z# G d„ d¦  «        Z$ G d„ d¦  «        Z% G d„ de$¦  «        Z& G d„ de$¦  «        Z' G d„ de'¦  «        Z(d„ Z)i Z* e)¦   «           e(¦   «         Z+d„ Z,d„ Z-d„ Z.ej/        d„ ¦   «         Z0d„ Z1d „ Z2d!„ Z3d&d#„Z4d$„ Z5dS )'z(
Utilities for comparing image results.
é    N)ÚPath)ÚTemporaryDirectoryÚTemporaryFile)ÚImage)ÚcbookÚ_image)ÚImageComparisonFailure)Úcalculate_rmsÚcomparable_formatsÚcompare_imagesc                 óX   — t           j                             | ¦  «        \  }}|› d|› |› �S )zQ
    Make a new filename by inserting *purpose* before the file's extension.
    ú-)ÚosÚpathÚsplitext)ÚfnameÚpurposeÚbaseÚexts       ú/home/lighthouse/badge-speaker-benchmark/.benchmark-venv-community/lib64/python3.11/site-packages/matplotlib/testing/compare.pyÚmake_test_filenamer      s6   € õ ”× Ò  Ñ'Ô'�I€Dˆ#ØÐ#Ð#�WÐ#˜cÐ#Ð#Ð#ó    c                  óv   — t          t          j        ¦   «         d¦  «        } |                      dd¬¦  «         | S )NÚ
test_cacheT)ÚparentsÚexist_ok)r   ÚmplÚget_cachedirÚmkdir)Ú	cache_dirs    r   Ú_get_cache_pathr!   &   s6   € Ý•SÔ%Ñ'Ô'¨Ñ6Ô6€IØ‡O‚O˜D¨4€OÑ0Ô0Ð0ØÐr   c                  ó8   — t          t          ¦   «         ¦  «        S ©N)Ústrr!   © r   r   Úget_cache_dirr&   ,   s   € Ý�Ñ Ô Ñ!Ô!Ð!r   é   c                 ó–  — t          j        d¬¦  «        }t          | d¦  «        5 }	 |                     |¦  «        }|sn|                     |¦  «         Œ.	 d d d ¦  «         n# 1 swxY w Y   t          | ¦  «        j        dk    rM|                     t          t          j	        d¦  «        j
        ¦  «                             d¦  «        ¦  «         ndt          | ¦  «        j        dk    rL|                     t          t          j	        d	¦  «        j
        ¦  «                             d¦  «        ¦  «         |                     ¦   «         S )
NF)ÚusedforsecurityÚrbTz.pdfÚgsúutf-8ú.svgÚinkscape)ÚhashlibÚsha256ÚopenÚreadÚupdater   Úsuffixr$   r   Ú_get_executable_infoÚversionÚencodeÚ	hexdigest)r   Ú
block_sizer0   ÚfdÚdatas        r   Úget_file_hashr<   0   s^  € ÝŒ^¨EÐ2Ñ2Ô2€FÝ	ˆd�DÑ	Ô	ð  ˜Rð	 Ø—7’7˜:Ñ&Ô&ˆDØð ØØ�MŠM˜$ÑÔÐð		 ð ð	 ð  ð  ñ  ô  ð  ð  ð  ð  ð  ð  øøøð  ð  ð  ð  õ ˆD�z„zÔ˜FÒ"Ð"Ø�Š•c�#Ô2°4Ñ8Ô8Ô@ÑAÔA×HÒHÈÑQÔQÑRÔRÐRÐRÝ	ˆd‰ŒÔ	˜fÒ	$Ð	$Ø�Š•c�#Ô2°:Ñ>Ô>ÔFÑGÔG×NÒNÈwÑWÔWÑXÔXÐXà×ÒÑÔÐs   ¦0A#Á#A'Á*A'c                   ó   — e Zd ZdS )Ú_ConverterErrorN)Ú__name__Ú
__module__Ú__qualname__r%   r   r   r>   r>   A   s   € € € € € Ø€Dr   r>   c                   ó    — e Zd Zd„ Zd„ Zd„ ZdS )Ú
_Converterc                 óF   — d | _         t          j        | j        ¦  «         d S r#   )Ú_procÚatexitÚregisterÚ__del__)Úselfs    r   Ú__init__z_Converter.__init__F   s#   € ØˆŒ
õ
 	Œ˜œÑ%Ô%Ð%Ð%Ð%r   c                 ó  — | j         rƒ| j                              ¦   «          | j                              ¦   «          t          d | j         j        | j         j        | j         j        g¦  «        D ]}|                     ¦   «          Œd | _         d S d S r#   )rE   ÚkillÚwaitÚfilterÚstdinÚstdoutÚstderrÚclose)rI   Ústreams     r   rH   z_Converter.__del__N   s�   € ØŒ:ð 	ØŒJ�OŠOÑÔÐØŒJ�OŠOÑÔÐÝ  ¨¬
Ô(8Ø(,¬
Ô(9Ø(,¬
Ô(9ð(;ñ <ô <ð ð �ð —’‘”��ØˆDŒJˆJˆJð	ð 	r   c                 ó2  — t          ¦   «         }	 | j        j                             d¦  «        }|s.t	          t          j        t          |¦  «        ¦  «        ¦  «        ‚|                     |¦  «         | 	                    |¦  «        rt          |¦  «        S Œ‰)z!Read until the prompt is reached.Té   )
Ú	bytearrayrE   rP   r2   r>   r   ÚfsdecodeÚbytesÚextendÚendswith)rI   Ú
terminatorÚbufÚcs       r   Ú_read_untilz_Converter._read_untilX   s‚   € å‰kŒkˆð	"Ø”
Ô!×&Ò& qÑ)Ô)ˆAØð ?Ý%¥b¤kµ%¸±*´*Ñ&=Ô&=Ñ>Ô>Ð>Ø�JŠJ�q‰MŒMˆMØ�|Š|˜JÑ'Ô'ð "Ý˜S‘z”zÐ!ð	"r   N)r?   r@   rA   rJ   rH   r^   r%   r   r   rC   rC   E   sA   € € € € € ð&ð &ð &ðð ð ð	"ð 	"ð 	"ð 	"ð 	"r   rC   c                   ó   — e Zd Zd„ ZdS )Ú_MagickConverterc                 ó  — 	 |                      ¦   «         r|                     ¦   «         }t          j        t	          j        d¦  «        j        ||gd¬¦  «         d S # t          j        $ r}t          ¦   «         |‚d }~ww xY w)NÚmagickT)Úcheck)	Ú
is_symlinkÚresolveÚ
subprocessÚrunr   r5   Ú
executableÚCalledProcessErrorr>   )rI   ÚorigÚdestÚes       r   Ú__call__z_MagickConverter.__call__e   s–   € ð	+à�ŠÑ Ô ð &Ø—|’|‘~”~�ÝŒNÝÔ)¨(Ñ3Ô3Ô>ÀÀdÐKØðñ ô ð ð ð øõ Ô,ð 	+ð 	+ð 	+Ý!Ñ#Ô#¨Ð*øøøøð	+øøøs   ‚AA ÁA?Á+A:Á:A?N©r?   r@   rA   rm   r%   r   r   r`   r`   d   s#   € € € € € ð	+ð 	+ð 	+ð 	+ð 	+r   r`   c                   ó   — e Zd Zd„ ZdS )Ú_GSConverterc                 ó¢  — | j         s“t          j        t          j        d¦  «        j        ddddgt          j        t          j        ¬¦  «        | _         	 |                      d¦  «         n0# t          $ r#}t          d|j
        d	         › �¦  «        d ‚d }~ww xY wd
„ }| j         j                             d ||¦  «        z   dz    ||¦  «        z   dz   ¦  «         | j         j                             ¦   «          |                      d¦  «        }|                     d¦  «        r|                      d¦  «        nd}|st          j                             |¦  «        st|rt%          |d d…         ¦  «        nd	}| j         j                             d|z  ¦  «         t'          ||z                        t+          j        ¦   «         d¦  «        ¦  «        ‚d S )Nr+   z	-dNOSAFERz	-dNOPAUSEz	-dEPSCropz-sDEVICE=png16m)rO   rP   s   
GSzFailed to start Ghostscript:

r   c                 ó¢   — t          j        | ¦  «                             dd¦  «                             dd¦  «                             dd¦  «        S )Nó   \s   \\ó   (s   \(ó   )s   \))r   ÚfsencodeÚreplace)Únames    r   Úencode_and_escapez0_GSConverter.__call__.<locals>.encode_and_escape~   sA   € Ý”K Ñ%Ô%ß’W˜U GÑ,Ô,ß’W˜T 6Ñ*Ô*ß’W˜T 6Ñ*Ô*ð,r   s   << /OutputFile (s   ) >> setpagedevice (s   ) run flush
)ó   GS<s   GS>rz   ó   >r   éÿÿÿÿs   pop
rw   )rE   rf   ÚPopenr   r5   rh   ÚPIPEr^   r>   ÚOSErrorÚargsrO   ÚwriteÚflushrZ   r   r   ÚexistsÚintr	   ÚdecodeÚsysÚgetfilesystemencoding)rI   rj   rk   rl   ry   ÚerrÚstackÚ
stack_sizes           r   rm   z_GSConverter.__call__r   s  € ØŒzð 		XÝ#Ô)ÝÔ)¨$Ñ/Ô/Ô:Ø˜k¨;Ð8IðKõ !”o­j¬oð	?ñ ?ô ?ˆDŒJð
XØ× Ò  Ñ)Ô)Ð)Ð)øÝ"ð Xð Xð XÝÐLÀÄÈÄÐLÐLÑMÔMÐSWÐWøøøøðXøøøð	,ð 	,ð 	,ð 	Œ
Ô×ÒØØÐ Ñ%Ô%ñ&à%ñ&ð  Ð Ñ%Ô%ñ&ð ñ	ñ	 ô 	 ð 	 ð 	Œ
Ô×ÒÑ Ô Ð à×ÒÐ/Ñ0Ô0ˆØ*-¯,ª,°vÑ*>Ô*>ÐG�× Ò  Ñ&Ô&Ð&ÀCˆØð 	N�œŸš tÑ,Ô,ð 	NØ,1Ð8�˜U 3 B 3œZ™œ˜°qˆJØŒJÔ×"Ò" 8¨jÑ#8Ñ9Ô9Ð9å(Ø�u‘×$Ò$¥SÔ%>Ñ%@Ô%@À)ÑLÔLñNô Nð Nð		Nð 	Ns   ÁA+ Á+
BÁ5BÂBNrn   r%   r   r   rp   rp   q   s(   € € € € € ð!Nð !Nð !Nð !Nð !Nr   rp   c                   ó$   ‡ — e Zd Zd„ Zˆ fd„Zˆ xZS )Ú_SVGConverterc                 óÞ  — t          j        d¦  «        j        j        dk     }|rdnd}t	          | d¦  «        s2t          ¦   «         | _        t          j        | j        | j	        ¦  «         | j
        r| j
                             ¦   «         ��+| j
        �a| j
                             ¦   «         �Ht          d | j
        j        | j
        j        | j
        j        g¦  «        D ]}|                     ¦   «          Œi t"          j        ¥d| j        j        dœ¥}t)          ¦   «         }t+          j        |rg d¢ndd	gt*          j        t*          j        ||| j        j        ¬
¦  «        | _
        || j
        _        	 |                      |¦  «         n0# t2          $ r#}t5          d|j        d         z   ¦  «        |‚d }~ww xY wt9          | j        j        t#          j        d¦  «        ¦  «        }	t9          | j        j        t#          j        d¦  «        ¦  «        }
	 |	                     t9          |¦  «                             ¦   «         ¦  «         n%# t4          $ r tA          j!        ||	¦  «         Y nw xY w| j
        j         "                    |rdnd¦  «         | j
        j         #                    ¦   «          	 |                      |¦  «         n‚# t2          $ ru}| j
        j         $                    d¦  «         tK          | j
        j         &                    ¦   «          '                    tQ          j)        ¦   «         d¦  «        ¦  «        |‚d }~ww xY wt#          j*        |	¦  «         tA          j+        |
|¦  «         d S )Nr.   rU   s   
>s   > Ú_tmpdirÚ )ÚDISPLAYÚINKSCAPE_PROFILE_DIR)r.   z--without-guiú--shellr’   )rO   rP   rQ   ÚenvÚcwdz/Failed to start Inkscape in interactive mode:

r   s   f.svgs   f.pngs   f.svg --export-png=f.png
s;   file-open:f.svg;export-filename:f.png;export-do;file-close
rw   ),r   r5   r6   ÚmajorÚhasattrr   rŽ   ÚweakrefÚfinalizerH   rE   ÚpollrN   rO   rP   rQ   rR   r   Úenvironrx   r   rf   r}   r~   r^   r>   r   r€   r   rW   Ú
symlink_tore   ÚshutilÚcopyfiler�   r‚   Úseekr	   r2   r…   r†   r‡   ÚremoveÚmove)rI   rj   rk   Úold_inkscaper[   rS   r“   rQ   rˆ   Úinkscape_origÚinkscape_dests              r   rm   z_SVGConverter.__call__—   sˆ  € ÝÔ/°
Ñ;Ô;ÔCÔIÈAÒMˆØ+Ð6�V�V°ˆ
Ý�t˜YÑ'Ô'ð 	9Ý-Ñ/Ô/ˆDŒLõ Ô˜Tœ\¨4¬<Ñ8Ô8Ð8Ø”
ð #	,Ø”:—?’?Ñ$Ô$Ñ0ØŒzÐ%¨$¬*¯/ª/Ñ*;Ô*;Ð*GÝ$ T¨D¬JÔ,<Ø,0¬JÔ,=Ø,0¬JÔ,=ð,?ñ @ô @ð #ð #�Fð —L’L‘N”N�N�Nð
Ý”*ð
ð à(,¬Ô(9ð
ð 
ð 
ˆCõ #‘_”_ˆFÝ#Ô)Ø<Hð (Ð8Ð8Ð8Ð8Ø˜YÐ'Ý ”o­j¬oÀfØ˜Tœ\Ô.ð	0ñ 0ô 0ˆDŒJð !'ˆDŒJÔð,Ø× Ò  Ñ,Ô,Ð,Ð,øÝ"ð ,ð ,ð ,ÝØGØ”h˜q”kñ"ñ#ô #à(+ð,øøøøð,øøøõ ˜Tœ\Ô.µ´¸HÑ0EÔ0EÑFÔFˆÝ˜Tœ\Ô.µ´¸HÑ0EÔ0EÑFÔFˆð	1Ø×$Ò$¥T¨$¡Z¤Z×%7Ò%7Ñ%9Ô%9Ñ:Ô:Ð:Ð:øÝð 	1ð 	1ð 	1ÝŒO˜D -Ñ0Ô0Ð0Ð0Ð0ð	1øøøàŒ
Ô×ÒØ-9ð LÐ)Ð)ØKñ	Mô 	Mð 	Mð 	Œ
Ô×ÒÑ Ô Ð ð		FØ×Ò˜ZÑ(Ô(Ð(Ð(øÝð 	Fð 	Fð 	Fð ŒJÔ×"Ò" 1Ñ%Ô%Ð%Ý(Ø”
Ô!×&Ò&Ñ(Ô(×/Ò/ÝÔ-Ñ/Ô/°ñ<ô <ñ=ô =àBEðFøøøøð	Føøøõ 	Œ	�-Ñ Ô Ð ÝŒ�M 4Ñ(Ô(Ð(Ð(Ð(sC   Å1F Æ
F4ÆF/Æ/F4È4I ÉI'É&I'Ê,K Ë
MËA0L<Ì<Mc                 óž   •— t          ¦   «                              ¦   «          t          | d¦  «        r| j                             ¦   «          d S d S )NrŽ   )ÚsuperrH   r–   rŽ   Úcleanup)rI   Ú	__class__s    €r   rH   z_SVGConverter.__del__Þ   sM   ø€ Ý‰Œ�ŠÑÔÐÝ�4˜Ñ#Ô#ð 	#ØŒL× Ò Ñ"Ô"Ð"Ð"Ð"ð	#ð 	#r   )r?   r@   rA   rm   rH   Ú__classcell__©r§   s   @r   rŒ   rŒ   –   sK   ø€ € € € € ðE)ð E)ð E)ðN#ð #ð #ð #ð #ð #ð #ð #ð #r   rŒ   c                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )Ú _SVGWithMatplotlibFontsConverterzÛ
    An 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¦  «        sRt          ¦   «         | _        t          j        t          j        d¦  «        t          | j        j        d¦  «        ¦  «         t          ¦   «          
                    ||¦  «        S )NrŽ   z	fonts/ttfÚfonts)r–   r   rŽ   rœ   Úcopytreer   Ú_get_data_pathr   rx   r¥   rm   )rI   rj   rk   r§   s      €r   rm   z)_SVGWithMatplotlibFontsConverter.__call__ë   so   ø€ Ý�t˜YÑ'Ô'ð 	>Ý-Ñ/Ô/ˆDŒLÝŒO�EÔ0°Ñ=Ô=Ý  ¤Ô!2°GÑ<Ô<ñ>ô >ð >å‰wŒw×Ò  dÑ+Ô+Ð+r   )r?   r@   rA   Ú__doc__rm   r¨   r©   s   @r   r«   r«   ä   sB   ø€ € € € € ðð ð,ð ,ð ,ð ,ð ,ð ,ð ,ð ,ð ,r   r«   c                  ó   — 	 t          j        d¦  «         t          ¦   «         t          d<   n# t           j        $ r Y nw xY w	 t          j        d¦  «         t          ¦   «         xt          d<   t          d<   n# t           j        $ r Y nw xY w	 t          j        d¦  «         t          ¦   «         t          d<   d S # t           j        $ r Y d S w xY w)Nrb   Úgifr+   ÚpdfÚepsr.   Úsvg)r   r5   r`   Ú	converterÚExecutableNotFoundErrorrp   rŒ   r%   r   r   Ú_update_converterr¸   ó   sý   € ð.ÝÔ  Ñ*Ô*Ð*õ ,Ñ-Ô-�	�%ÑÐøõ Ô&ð ð ð Øˆðøøøð=ÝÔ  Ñ&Ô&Ð&õ /;©n¬nÐ<�	�%Ñ�9 UÑ+Ð+øõ Ô&ð ð ð Øˆðøøøð+ÝÔ  Ñ,Ô,Ð,õ )™?œ?�	�%ÑÐÐøõ Ô&ð ð ð Øˆˆðøøøs0   ‚- ­?¾?ÁA8 Á8B
Â	B
ÂB: Â:CÃCc                  ó   — dgt           ¢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%   r   r   r   r     s   € ð Ð•IÐÐr   c                 óR  — t          | ¦  «        }|                     ¦   «         st          |› d�¦  «        ‚|j        dd…         t          vr"ddl}|                     d|j        › d�¦  «         |j        |j        › d|j        dd…         › d�z  }|                     ¦   «         r5| 	                    ¦   «         j
        | 	                    ¦   «         j
        k     �rA|rt          ¦   «         nd}|�}t          ¦   «          t          |¦  «        }|||j        z   z  }|                     ¦   «         r?t                               d	| ¦  «         t!          j        ||¦  «         t%          |¦  «        S t                               d
| ¦  «         t          |j        dd…                  }|j        dk    r2|                     d¬¦  «        }	t)          j        d|	¦  «        rt,          } |||¦  «         |�0t                               d| ¦  «         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 existrU   Nr   zDon't know how to convert z files to pngÚ_z.pngz"For %s: reusing cached conversion.zFor %s: converting to png.r-   r,   )Úencodingz9style="[^"]*font(|-size|-weight|-family|-variant|-style):z"For %s: caching conversion result.)r   rƒ   r   r4   r¶   ÚpytestÚskipÚparentÚstemÚstatÚst_mtimer!   Ú'_register_conversion_cache_cleaner_oncer<   Ú_logÚdebugrœ   r�   r$   Ú	read_textÚreÚsearchÚ$_svg_with_matplotlib_fonts_converter)
ÚfilenameÚcacher   r¾   Únewpathr    Ú
hash_valueÚcached_pathÚconvertÚcontentss
             r   rÐ   rÐ     s  € õ �‰>Œ>€DØ�;Š;‰=Œ=ð 0Ý˜Ð.Ð.Ð.Ñ/Ô/Ð/Ø„{�1�2�2„�iÐ'Ð'ØˆˆˆØ�ŠÐK°´ÐKÐKÐKÑLÔLÐLØŒk˜tœyÐ@Ð@¨4¬;°q°r°r¬?Ð@Ð@Ð@Ñ@€Gð �>Š>ÑÔð %2˜wŸ|š|™~œ~Ô6¸¿º¹¼Ô9MÒMÑMØ).Ð8•OÑ%Ô%Ð%°Dˆ	àÐ Ý3Ñ5Ô5Ð5Ý& tÑ,Ô,ˆJØ# z°G´NÑ'BÑCˆKØ×!Ò!Ñ#Ô#ð $Ý—
’
Ð?ÀÑJÔJÐJÝ” ¨WÑ5Ô5Ð5Ý˜7‘|”|Ð#å�
Š
Ð/°Ñ:Ô:Ð:Ý˜DœK¨¨¨œOÔ,ˆØŒ;˜&Ò Ð Ø—~’~¨w�~Ñ7Ô7ˆHõ Œyð MØñô ð ?õ ?�Øˆ��gÑÔÐàÐ Ý�JŠJÐ;¸XÑFÔFÐFÝŒO˜G [Ñ1Ô1Ð1åˆw‰<Œ<Ðr   c                  ór  ‡— t          d„ t          t          j        ¦  «        j                             d¦  «        D ¦   «         ¦  «        } d| z  }t          j        t          ¦   «         ¦  «        5  d„ t          ¦   «                              d¦  «        D ¦   «         Št          d„ ‰ 	                    ¦   «         D ¦   «         ¦  «        }t          ‰ˆfd„d¬	¦  «        }||k    r>|                     ¦   «         }|‰|         j        z  }|                     ¦   «          ||k    °>d d d ¦  «         d S # 1 swxY w Y   d S )
Nc              3   óH   K  — | ]}|                      ¦   «         j        V — Œd S r#   )rÂ   Úst_size©Ú.0r   s     r   ú	<genexpr>z*_clean_conversion_cache.<locals>.<genexpr>^  sI   è è € ð Oð Oàð 	�	Š	‰ŒÔðOð Oð Oð Oð Oð Or   z**/baseline_images/**/*é   c                 ó8   — i | ]}||                      ¦   «         “ŒS r%   )rÂ   rÕ   s     r   ú
<dictcomp>z+_clean_conversion_cache.<locals>.<dictcomp>f  s5   € ð Gð Gð GØ"&ˆD�$—)’)‘+”+ðGð Gð Gr   Ú*c              3   ó$   K  — | ]}|j         V — Œd S r#   )rÔ   )rÖ   rÂ   s     r   r×   z*_clean_conversion_cache.<locals>.<genexpr>h  s$   è è € ÐFÐF¨$˜œÐFÐFÐFÐFÐFÐFr   c                 ó   •— ‰|          j         S r#   )Úst_atime)r   Ú
cache_stats    €r   ú<lambda>z)_clean_conversion_cache.<locals>.<lambda>j  s   ø€ ¨°DÔ)9Ô)B€ r   T)ÚkeyÚreverse)Úsumr   r   Ú__file__rÀ   Úglobr   Ú
_lock_pathr!   ÚvaluesÚsortedÚpoprÔ   Úunlink)Úbaseline_images_sizeÚmax_cache_sizeÚ
cache_sizeÚpaths_by_atimer   rß   s        @r   Ú_clean_conversion_cacherï   [  s«  ø€ õ ð Oð Oå�œÑ&Ô&Ô-×2Ò2Ð3LÑMÔMðOñ Oô Oñ Oô OÐð
 Ð-Ñ-€Nå	Ô	�/Ñ+Ô+Ñ	,Ô	,ð 
ð 
ðGð GÝ*9Ñ*;Ô*;×*@Ò*@ÀÑ*EÔ*EðGñ Gô Gˆ
åÐFÐF°*×2CÒ2CÑ2EÔ2EÐFÑFÔFÑFÔFˆ
ÝØÐBÐBÐBÐBØðñ ô ˆð ˜>Ò)Ð)Ø!×%Ò%Ñ'Ô'ˆDØ˜* TÔ*Ô2Ñ2ˆJØ�KŠK‰MŒMˆMð ˜>Ò)Ð)ð
ð 
ð 
ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
øøøð 
ð 
ð 
ð 
ð 
ð 
s   Á/B0D,Ä,D0Ä3D0c                  ó8   — t          j        t          ¦  «         d S r#   )rF   rG   rï   r%   r   r   rÄ   rÄ   r  s   € å
„OÕ+Ñ,Ô,Ð,Ð,Ð,r   c                 ó:  — | dd…         dk    rŠ|dd…         dk    r||j         \  }}}|j         \  }}}	|t          |dz  |dz  z
  ¦  «        t          |dz  |dz  z   ¦  «        …t          |dz  |dz  z
  ¦  «        t          |dz  |dz  z   ¦  «        …f         }||fS )Niùÿÿÿéüÿÿÿr´   r³   rØ   )Úshaper„   )
Úactual_pathÚactual_imageÚexpected_pathÚexpected_imageÚawÚahÚadÚewÚehÚeds
             r   Úcrop_to_samerþ   w  sÉ   € ð �2�b�5Ô˜UÒ"Ð" }°R¸°UÔ';¸uÒ'DÐ'DØ!Ô'‰
ˆˆB�Ø#Ô)‰
ˆˆB�Ø#¥C¨¨Q©°°a±©Ñ$8Ô$8½Ø�‰F�R˜!‘V‰Oñ:ô :ð %Ý! " q¡&¨2°©6¡/Ñ2Ô2µ3°r¸A±vÀÀQÁ±Ñ3GÔ3GÐGð%Hô Iˆà˜Ð'Ð'r   c                 óè   — | j         |j         k    rt          d| j         › d|j         › �¦  «        ‚t          j        | |z
                       t
          ¦  «        dz                       ¦   «         ¦  «        S )zR
    Calculate the per-pixel errors, then compute the root mean square error.
    ú(Image sizes do not match expected size: ú actual size rØ   )ró   r	   ÚnpÚsqrtÚastypeÚfloatÚmean)r÷   rõ   s     r   r
   r
   ‚  s�   € ð Ô˜|Ô1Ò1Ð1Ý$ð0°~Ô7Kð 0ð 0Ø'Ô-ð0ð 0ñ1ô 1ð 	1õ Œ7�^ lÑ2×:Ò:½5ÑAÔAÀQÑF×LÒLÑNÔNÑOÔOÐOr   c                 ó  — t          j        | ¦  «        }|j        dk    rY|j        dk    r|                     d¦  «        }|                     ¦   «         d         d         dk    r|                     d¦  «        }t          j        |¦  «        S )NÚRGBÚRGBAé   r   éÿ   )r   r1   ÚmoderÐ   Ú
getextremar  Úasarray)r   Úimgs     r   Ú_load_imager  ’  s~   € Ý
Œ*�TÑ
Ô
€CØ
„x�5ÒÐð Œ8�vÒÐØ—+’+˜fÑ%Ô%ˆCð �>Š>ÑÔ˜AÔ˜qÔ! SÒ(Ð(Ø—+’+˜eÑ$Ô$ˆCÝŒ:�c‰?Œ?Ðr   Fc                 ó  ‡— t          j        |¦  «        }t           j                             |¦  «        st	          d|› d�¦  «        ‚t          j        |¦  «        j        dk    rt	          d|› d�¦  «        ‚t          j        | ¦  «        } t           j                             | ¦  «        st          d| ›d�¦  «        ‚|                      d¦  «        d         }|d	k    r"t          |d
¬¦  «        }t          | d
¬¦  «        } t          | ¦  «        }t          |¦  «        }t          ||| |¦  «        \  }}t          |d¦  «        }|dk    rt          j        ||¦  «        rdS t          j        ||¦  «        \  }}	||k    rdS t#          j        |	¦  «                             |d	¬¦  «         t)          |t+          | ¦  «        t+          |¦  «        t+          |¦  «        |¬¦  «        Š|s%g d¢}
d                     ˆfd„|
D ¦   «         ¦  «        Š‰S )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
    in a similar way to 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)

    zOutput image z does not exist.r   zOutput image file z
 is empty.zBaseline image ú.r|   rº   T)rÌ   zfailed-diffN©Úformat)ÚrmsÚexpectedÚactualÚdiffÚtol)z!Error: Image files did not match.zRMS Value: {rms}zExpected:  
    {expected}zActual:    
    {actual}zDifference:
    {diff}zTolerance: 
    {tol}z
  c                 ó*   •— g | ]} |j         d i ‰¤Ž‘ŒS )r%   r  )rÖ   ÚlineÚresultss     €r   ú
<listcomp>z"compare_images.<locals>.<listcomp>   s+   ø€ ÐKÐKÐK¸$˜{˜tœ{Ð5Ð5¨WÐ5Ð5ÐKÐKÐKr   )r   Úfspathr   rƒ   Ú	ExceptionrÂ   rÔ   r   ÚsplitrÐ   r  rþ   r   r  Úarray_equalr   Úcalculate_rms_and_diffr   Ú	fromarrayÚsaveÚdictr$   Újoin)r  r  r  Úin_decoratorÚ	extensionr÷   rõ   Ú
diff_imager  Úabs_diffÚtemplater  s              @r   r   r   ¡  s-  ø€ õb ŒY�vÑÔ€FÝŒ7�>Š>˜&Ñ!Ô!ð BÝÐ@¨Ð@Ð@Ð@ÑAÔAÐAÝ	„wˆv�„Ô !Ò#Ð#ÝÐ?¨VÐ?Ð?Ð?Ñ@Ô@Ð@õ Œy˜Ñ"Ô"€HÝŒ7�>Š>˜(Ñ#Ô#ð FÝÐD¨ÐDÐDÐDÑEÔEÐEØ—’˜sÑ#Ô# BÔ'€IØ�EÒÐÝ˜ tÐ,Ñ,Ô,ˆÝ˜8¨4Ð0Ñ0Ô0ˆõ ! Ñ*Ô*€NÝ˜vÑ&Ô&€Lå#/Ø�˜h¨ñ$8ô $8Ñ €L�.õ $ F¨MÑ:Ô:€Jà
ˆa‚x€xÝŒ>˜.¨,Ñ7Ô7ð 	Ø�4åÔ1°.À,ÑOÔO�M€Cˆà
ˆc‚z€zØˆtå	„O�HÑÔ×"Ò" :°eÐ"Ñ<Ô<Ð<å�s¥S¨¡]¤]Ý˜f™+œ+­C°
©O¬OÀðFñ Fô F€Gð ð Mð0ð 0ð 0ˆð —+’+ÐKÐKÐKÐKÀ(ÐKÑKÔKÑLÔLˆØ€Nr   c                 ó\  — t          | ¦  «        }t          |¦  «        }t          ||| |¦  «        \  }}t          j        |t          ¦  «        }t          j        |t          ¦  «        }|j        |j        k    rt          d|j        › d|j        › �¦  «        ‚t          j        ||z
  ¦  «        }|dz  }t          j        |dd¦  «         	                    t          j
        ¦  «        }|j        d         dk    rd|dd…dd…d	f<   t          j        |¦  «                             |d
¬¦  «         dS )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   r  é
   r   r  rØ   é   Nr
  rº   r  )r  rþ   r  Úarrayr  ró   r	   ÚabsÚclipr  Úuint8r   r#  r$  )r  r  Úoutputr÷   rõ   r*  s         r   Úsave_diff_imager4    s;  € õ ! Ñ*Ô*€NÝ˜vÑ&Ô&€LÝ#/Ø�˜h¨ñ$8ô $8Ñ €L�.å”X˜n­eÑ4Ô4€NÝ”8˜L­%Ñ0Ô0€LØÔ˜|Ô1Ò1Ð1Ý$ð0°~Ô7Kð 0ð 0Ø'Ô-ð0ð 0ñ1ô 1ð 	1õ Œv�n |Ñ3Ñ4Ô4€Hð ��N€HÝŒw�x  CÑ(Ô(×/Ò/µ´Ñ9Ô9€Hà„~�aÔ˜AÒÐØˆ����A�A�A�q�Ñå	„O�HÑÔ×"Ò" 6°%Ð"Ñ8Ô8Ð8Ð8Ð8r   )r'   )F)6r°   rF   Ú	functoolsr/   Úloggingr   Úpathlibr   rœ   rf   r†   Útempfiler   r   r—   rÈ   Únumpyr  ÚPILr   Ú
matplotlibr   r   r   Úmatplotlib.testing.exceptionsr	   Ú	getLoggerr?   rÅ   Ú__all__r   r!   r&   r<   r  r>   rC   r`   rp   rŒ   r«   r¸   r¶   rÊ   r   rÐ   rï   rÌ   rÄ   rþ   r
   r  r   r4  r%   r   r   ú<module>r?     s8  ððð ð €€€Ø Ð Ð Ð Ø €€€Ø €€€Ø 	€	€	€	Ø Ð Ð Ð Ð Ð Ø €€€Ø Ð Ð Ð Ø 
€
€
€
Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø €€€Ø 	€	€	€	à Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $Ð $Ð $Ø @Ð @Ð @Ð @Ð @Ð @à€wÔ˜Ñ"Ô"€à
CÐ
CÐ
C€ð$ð $ð $ðð ð ð"ð "ð "ðð ð ð ð"	ð 	ð 	ð 	ð 	�iñ 	ô 	ð 	ð"ð "ð "ð "ð "ñ "ô "ð "ð>
+ð 
+ð 
+ð 
+ð 
+ñ 
+ô 
+ð 
+ð"Nð "Nð "Nð "Nð "N�:ñ "Nô "Nð "NðJK#ð K#ð K#ð K#ð K#�Jñ K#ô K#ð K#ð\,ð ,ð ,ð ,ð , }ñ ,ô ,ð ,ð+ð +ð +ð. €	Ø Ð Ñ Ô Ð Ø'GÐ'GÑ'IÔ'IÐ $ðð ð ð;ð ;ð ;ð|ð ð ð. „ð-ð -ñ „ð-ð(ð (ð (ð	Pð 	Pð 	Pð ð ð ð`ð `ð `ð `ðF9ð 9ð 9ð 9ð 9r   