Ë
    ¨ehDM  ã                   óÖ  — 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 ddlmZ  ej2                  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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jZ                  d„ «       Z.d„ Z/d„ Z0d„ Z1d"d„Z2d „ Z3y)#z(
Utilities for comparing image results.
é    N)ÚPath)ÚTemporaryDirectoryÚTemporaryFile)ÚImage)Úcbook)ÚImageComparisonFailure)Úcalculate_rmsÚcomparable_formatsÚcompare_imagesc                 óX   — t         j                  j                  | «      \  }}|› d|› |› �S )zQ
    Make a new filename by inserting *purpose* before the file's extension.
    ú-)ÚosÚpathÚsplitext)ÚfnameÚpurposeÚbaseÚexts       úX/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/matplotlib/testing/compare.pyÚmake_test_filenamer      s1   € ô —‘× Ñ  Ó'�I€Dˆ#ØˆV�1�W�I˜c˜UÐ#Ð#ó    c                  óh   — t        t        j                  «       d«      } | j                  dd¬«       | 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ØÐr   c                  ó(   — t        t        «       «      S ©N)Ústrr    © r   r   Úget_cache_dirr%   ,   s   € ÜŒÓ Ó!Ð!r   c                 óx  — t        j                  d¬«      }t        | d«      5 }	 |j                  |«      }|sn|j	                  |«       Œ&	 d d d «       t        | «      j                  dk(  rV|j	                  t        t        j                  d«      j                  «      j                  d«      «       |j                  «       S t        | «      j                  dk(  rF|j	                  t        t        j                  d«      j                  «      j                  d«      «       |j                  «       S # 1 sw Y   ŒåxY w)	NF)ÚusedforsecurityÚrbz.pdfÚgszutf-8ú.svgÚinkscape)ÚhashlibÚsha256ÚopenÚreadÚupdater   Úsuffixr#   r   Ú_get_executable_infoÚversionÚencodeÚ	hexdigest)r   Ú
block_sizer-   ÚfdÚdatas        r   Úget_file_hashr9   0   s   € Ü�^‰^¨EÔ2€FÜ	ˆd�DÓ	ð  ˜RØØ—7‘7˜:Ó&ˆDÙØØ�M‰M˜$Ôð	 ð ÷	 ô ˆDƒz×Ñ˜FÒ"Ø�‰”cœ#×2Ñ2°4Ó8×@Ñ@ÓA×HÑHÈÓQÔRð ×ÑÓÐô 
ˆd‹×	Ñ	˜fÒ	$Ø�‰”cœ#×2Ñ2°:Ó>×FÑFÓG×NÑNÈwÓWÔXà×ÑÓÐ÷ ð  ús   £(D0Ä0D9c                   ó   — e Zd Zy)Ú_ConverterErrorN)Ú__name__Ú
__module__Ú__qualname__r$   r   r   r;   r;   A   s   „ Ør   r;   c                   ó   — e Zd Zd„ Zd„ Zd„ Zy)Ú
_Converterc                 óP   — d | _         t        j                  | j                  «       y r"   )Ú_procÚatexitÚregisterÚ__del__)Úselfs    r   Ú__init__z_Converter.__init__F   s   € ØˆŒ
ô
 	�‰˜Ÿ™Õ%r   c                 óT  — | j                   rœ| j                   j                  «        | j                   j                  «        t        d | j                   j                  | j                   j
                  | j                   j                  g«      D ]  }|j                  «        Œ d | _         y y r"   )rB   ÚkillÚwaitÚfilterÚstdinÚstdoutÚstderrÚclose)rF   Ústreams     r   rE   z_Converter.__del__N   s   € Ø�:Š:Ø�J‰J�O‰OÔØ�J‰J�O‰OÔÜ  ¨¯
©
×(8Ñ(8Ø(,¯
©
×(9Ñ(9Ø(,¯
©
×(9Ñ(9ð(;ó <ò �ð —‘•ðð ˆD�Jð r   c                 ó  — t        «       }	 | j                  j                  j                  d«      }|s't	        t        j                  t        |«      «      «      ‚|j                  |«       |j                  |«      rt        |«      S Œ|)z!Read until the prompt is reached.é   )
Ú	bytearrayrB   rM   r/   r;   r   ÚfsdecodeÚbytesÚextendÚendswith)rF   Ú
terminatorÚbufÚcs       r   Ú_read_untilz_Converter._read_untilX   sg   € ä‹kˆØØ—
‘
×!Ñ!×&Ñ& qÓ)ˆAÙÜ%¤b§k¡k´%¸³*Ó&=Ó>Ð>Ø�J‰J�qŒMØ�|‰|˜JÔ'Ü˜S“zÐ!ð r   N)r<   r=   r>   rG   rE   r[   r$   r   r   r@   r@   E   s   „ ò&òó	"r   r@   c                   ó   — e Zd Zd„ Zy)Ú_GSConverterc                 ó˜  — | j                   smt        j                  t        j                  d«      j
                  ddddgt        j                  t        j                  ¬«      | _         	 | j                  d«       d
„ }| j                   j                  j                  d ||«      z   dz    ||«      z   dz   «       | j                   j                  j                  «        | j                  d«      }|j                  d«      r| j                  d«      nd}|st        j                   j#                  |«      sj|rt%        |d d «      nd	}| j                   j                  j                  d|z  «       t'        ||z   j)                  t+        j,                  «       d«      «      ‚y # t        $ r!}t        d|j                  d	   › �«      d ‚d }~ww xY w)Nr)   z	-dNOSAFERz	-dNOPAUSEz	-dEPSCropz-sDEVICE=png16m)rL   rM   s   
GSzFailed to start Ghostscript:

r   c                 óŒ   — t        j                  | «      j                  dd«      j                  dd«      j                  dd«      S )Nó   \s   \\ó   (s   \(ó   )s   \))r   ÚfsencodeÚreplace)Únames    r   Úencode_and_escapez0_GSConverter.__call__.<locals>.encode_and_escapeq   s7   € Ü—K‘K Ó%ß‘W˜U GÓ,ß‘W˜T 6Ó*ß‘W˜T 6Ó*ð,r   s   << /OutputFile (s   ) >> setpagedevice (s   ) run flush
)ó   GS<s   GS>rg   ó   >r   éÿÿÿÿs   pop
rd   )rB   Ú
subprocessÚPopenr   r2   Ú
executableÚPIPEr[   r;   ÚOSErrorÚargsrL   ÚwriteÚflushrW   r   r   ÚexistsÚintr   ÚdecodeÚsysÚgetfilesystemencoding)rF   ÚorigÚdestÚerf   ÚerrÚstackÚ
stack_sizes           r   Ú__call__z_GSConverter.__call__e   s�  € Ø�zŠzÜ#×)Ñ)Ü×)Ñ)¨$Ó/×:Ñ:Ø˜k¨;Ð8IðKô !—o‘o¬j¯o©oô	?ˆDŒJð
XØ× Ñ  Ô)ò	,ð 	�
‰
×Ñ×ÑØÙ Ó%ñ&à%ñ&ñ   Ó%ñ&ð ñ	ô	 ð 	�
‰
×Ñ×ÑÔ à×ÑÐ/Ó0ˆØ*-¯,©,°vÔ*>�× Ñ  Ô&ÀCˆÙœŸ™Ÿ™ tÔ,Ù,1œ˜U 3 B˜Zœ°qˆJØ�J‰J×Ñ×"Ñ" 8¨jÑ#8Ô9ä(Ø�u‘×$Ñ$¤S×%>Ñ%>Ó%@À)ÓLóNð Nð	 -øô' #ò XÜÐ @ÀÇÁÈÁÀÐLÓMÐSWÐWûðXús   Á)F Æ	G	Æ(GÇG	N)r<   r=   r>   r}   r$   r   r   r]   r]   d   s   „ ó!Nr   r]   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«      s9t        «       | _        t        j                  | j                  | j                  «       | j                  r| j                  j                  «       ��6| j                  �z| j                  j                  «       �`t        d | j                  j                  | j                  j                  | j                  j                  g«      D ]  }|j!                  «        Œ i t"        j$                  ¥d| j                  j&                  dœ¥}t)        «       }t+        j,                  |rg d¢ndd	gt*        j.                  t*        j.                  ||| j                  j&                  ¬
«      | _
        || j                  _        	 | j1                  |«       t9        | j                  j&                  t#        j:                  d«      «      }	t9        | j                  j&                  t#        j:                  d«      «      }
	 |	j=                  t9        |«      j?                  «       «       | j                  j                  jE                  |rdnd«       | j                  j                  jG                  «        	 | j1                  |«       t#        jT                  |	«       tA        jV                  |
|«       y # t2        $ r!}t5        d|j6                  d   z   «      |‚d }~ww xY w# t4        $ r tA        jB                  ||	«       Y ŒÙw xY w# t2        $ rz}| j                  j                  jI                  d«       tK        | j                  j                  jM                  «       jO                  tQ        jR                  «       d«      «      |‚d }~ww xY w)Nr+   rR   s   
>s   > Ú_tmpdirÚ )ÚDISPLAYÚINKSCAPE_PROFILE_DIR)r+   z--without-guiú--shellr…   )rL   rM   rN   Ú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
rd   ),r   r2   r3   ÚmajorÚhasattrr   r�   ÚweakrefÚfinalizerE   rB   ÚpollrK   rL   rM   rN   rO   r   Úenvironre   r   rj   rk   rm   r[   r;   rn   ro   r   rT   Ú
symlink_toÚresolveÚshutilÚcopyfilerp   rq   Úseekr   r/   rt   ru   rv   ÚremoveÚmove)rF   rw   rx   Úold_inkscaperX   rP   r†   rN   rz   Úinkscape_origÚinkscape_dests              r   r}   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 Ê2M Ë/	LË8LÌLÌL>Ì=L>Í	OÍ
A5N?Î?Oc                 óp   •— t         ‰| �  «        t        | d«      r| j                  j	                  «        y y )Nr�   )ÚsuperrE   r‰   r�   Úcleanup)rF   Ú	__class__s    €r   rE   z_SVGConverter.__del__Ñ   s,   ø€ Ü‰‰ÔÜ�4˜Ô#Ø�L‰L× Ñ Õ"ð $r   )r<   r=   r>   r}   rE   Ú__classcell__©r›   s   @r   r   r   ‰   s   ø„ òE)÷N#ð #r   r   c                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )Ú _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        «       | _        t        j                  t        j                  d«      t        | j                  j                  d«      «       t        ‰| �)  ||«      S )Nr�   z	fonts/ttfÚfonts)r‰   r   r�   r�   Úcopytreer   Ú_get_data_pathr   re   r™   r}   )rF   rw   rx   r›   s      €r   r}   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   @r   rŸ   rŸ   ×   s   ø„ ñ÷,ð ,r   rŸ   c                  ó  — 	 t        j                  d«       t        «       xt        d<   t        d<   	 t        j                  d«       t        «       t        d<   y # t         j                  $ r Y Œ=w xY w# t         j                  $ r Y y w xY w)Nr)   ÚpdfÚepsr+   Úsvg)r   r2   r]   Ú	converterÚExecutableNotFoundErrorr   r$   r   r   Ú_update_converterr«   æ   s�   € ð=Ü× Ñ  Ô&ô /;«nÐ<Œ	�%Ñœ9 UÑ+ð+Ü× Ñ  Ô,ô )›?Œ	�%Òøô ×&Ñ&ò Ùðûô ×&Ñ&ò Ùðús"   ‚A ²A2 ÁA/Á.A/Á2BÂB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                 óö  — t        | «      }|j                  «       st        |› d�«      ‚|j                  dd t        vr#ddl}|j                  d|j                  › d�«       |j                  |j                  › d|j                  dd › d�z  }|j                  «       r6|j                  «       j                  |j                  «       j                  k  �r|r
t        «       nd}|�nt        «        t        |«      }|||j                  z   z  }|j                  «       r7t        j                  d	| «       t!        j"                  ||«       t%        |«      S t        j                  d
| «       t        |j                  dd    }|j                  dk(  r,|j'                  «       }	t)        j*                  d|	«      rt,        } |||«       |�,t        j                  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 existrR   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*   z9style="[^"]*font(|-size|-weight|-family|-variant|-style):z"For %s: caching conversion result.)r   rr   rn   r1   r©   ÚpytestÚskipÚparentÚstemÚstatÚst_mtimer    Ú'_register_conversion_cache_cleaner_oncer9   Ú_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Ø�;‰;Œ=Ü˜˜˜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ô �y‰yð MØôô ?�Ù��gÔàÐ Ü�J‰JÐ;¸XÔFÜ�O‰O˜G [Ô1äˆw‹<Ðr   c                  óJ  ‡— t        d„ t        t        j                  «      j                  j                  d«      D «       «      } d| z  }t        j                  t        «       «      5  t        «       j                  d«      D �ci c]  }||j                  «       “Œ c}Št        d„ ‰j                  «       D «       «      }t        ‰ˆfd„d¬«      }||kD  r8|j                  «       }|‰|   j                  z  }|j                  «        ||kD  rŒ8d d d «       y c c}w # 1 sw Y   y xY w)	Nc              3   óP   K  — | ]  }|j                  «       j                  –— Œ  y ­wr"   )r´   Úst_size)Ú.0r   s     r   ú	<genexpr>z*_clean_conversion_cache.<locals>.<genexpr>K  s&   è ø€ ò Oàð 	�	‰	‹×ÕñOùs   ‚$&z**/baseline_images/**/*é   Ú*c              3   ó4   K  — | ]  }|j                   –— Œ y ­wr"   )rÆ   )rÇ   r´   s     r   rÈ   z*_clean_conversion_cache.<locals>.<genexpr>U  s   è ø€ ÒF¨$˜Ÿ�ÑFùs   ‚c                 ó"   •— ‰|    j                   S r"   )Úst_atime)r   Ú
cache_stats    €r   ú<lambda>z)_clean_conversion_cache.<locals>.<lambda>W  s   ø€ ¨°DÑ)9×)BÑ)B€ r   T)ÚkeyÚreverse)Úsumr   r   Ú__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Þ   H  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   — t        j                  t        «       y r"   )rC   rD   rÞ   r$   r   r   r¶   r¶   _  s   € ä
‡O�OÔ+Õ,r   c                 ó  — | dd dk(  r{|dd dk(  rs|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É   )Úshapers   )
Úactual_pathÚactual_imageÚexpected_pathÚexpected_imageÚawÚahÚadÚewÚehÚeds
             r   Úcrop_to_samerí   d  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ˆà˜Ð'Ð'r   c                 óö   — | j                   |j                   k7  r%t        d| j                   › d|j                   › �«      ‚t        j                  | |z
  j	                  t
        «      dz  j                  «       «      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	   o  sy   € ð ×Ñ˜|×1Ñ1Ò1Ü$Ø6°~×7KÑ7KÐ6Lð MØ'×-Ñ-Ð.ð0ó1ð 	1ô �7‰7�^ lÑ2×:Ñ:¼5ÓAÀQÑF×LÑLÓNÓOÐOr   c                 óÈ   — t        j                  | «      }|j                  dk7  s|j                  «       d   d   dk(  r|j	                  d«      }t        j                  |«      S )NÚRGBAé   r   éÿ   ÚRGB)r   r.   ÚmodeÚ
getextremarÂ   rñ   Úasarray)r   Úimgs     r   Ú_load_imagerÿ     sR   € Ü
�*‰*�TÓ
€Cð ‡x�x�6Ò˜SŸ^™^Ó-¨aÑ0°Ñ3°sÒ:Ø�k‰k˜%Ó ˆÜ�:‰:�c‹?Ðr   c           
      óü  — t        j                  |«      }t         j                  j                  |«      st	        d|› d�«      ‚t        j
                  |«      j                  dk(  rt	        d|› d�«      ‚t        j                  | «      } t         j                  j                  | «      st        d| ›d�«      ‚| j                  d«      d   }|d	k7  rt        |d
¬«      }t        | d
¬«      } t        | «      }t        |«      }t        ||| |«      \  }}t        |d«      }|dk  rt        j                  ||«      ry|j                  t        j                   «      }|j                  t        j                   «      }t#        ||«      }||k  ryt%        | ||«       t'        |t)        | «      t)        |«      t)        |«      |¬«      }	|s3g d¢}
dj+                  |
D �cg c]  } |j,                  di |	¤Ž‘Œ c}«      }	|	S c c}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)

    zOutput image z does not exist.r   zOutput image file z
 is empty.zBaseline image ú.ri   r­   T)r¾   zfailed-diffN)Ú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
  r$   )r   Úfspathr   rr   Ú	Exceptionr´   rÆ   rn   ÚsplitrÂ   rÿ   rí   r   rñ   Úarray_equalró   Úint16r	   Úsave_diff_imageÚdictr#   ÚjoinÚformat)r  r  r  Úin_decoratorÚ	extensionræ   rä   Ú
diff_imager  ÚresultsÚtemplateÚlines               r   r   r   ‰  sÍ  € ôb �Y‰Y�vÓ€FÜ�7‰7�>‰>˜&Ô!Ü˜-¨ xÐ/?Ð@ÓAÐAÜ	‡w�wˆvƒ×Ñ !Ò#ÜÐ,¨V¨H°JÐ?Ó@Ð@ô �y‰y˜Ó"€HÜ�7‰7�>‰>˜(Ô#Ü˜¨ |Ð3CÐ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ùò Ls   ÇG9c                 ó`  — t        | «      }t        |«      }t        ||| |«      \  }}t        j                  |t        «      }t        j                  |t        «      }|j
                  |j
                  k7  r%t        d|j
                  › d|j
                  › �«      ‚t        j                  ||z
  «      }|dz  }t        j                  |dd«      j                  t        j                  «      }|j
                  d   dk(  rd|dd…dd…d	f<   t        j                  |«      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ï   rð   é
   r   rù   rÉ   é   Nrø   r­   )r  )rÿ   rí   rñ   Úarrayrô   râ   r   ÚabsÚclipró   Úuint8r   Ú	fromarrayÚsave)r  r  Úoutputræ   rä   Úabs_diffs         r   r  r  ñ  s  € ô ! Ó*€NÜ˜vÓ&€LÜ#/Ø�˜h¨ó$8Ñ €L�.ä—X‘X˜n¬eÓ4€NÜ—8‘8˜L¬%Ó0€LØ×Ñ˜|×1Ñ1Ò1Ü$Ø6°~×7KÑ7KÐ6Lð MØ'×-Ñ-Ð.ð0ó1ð 	1ô �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)4r¤   rC   Ú	functoolsr,   Úloggingr   Úpathlibr   r�   rj   ru   Útempfiler   r   rŠ   rº   Únumpyrñ   ÚPILr   Ú
matplotlibr   r   Úmatplotlib.testing.exceptionsr   Ú	getLoggerr<   r·   Ú__all__r   r    r%   r9   r  r;   r@   r]   r   rŸ   r«   r©   r¼   r
   rÂ   rÞ   r¾   r¶   rí   r	   rÿ   r   r  r$   r   r   ú<module>r+     s	  ðñó Û Û Û Û 	Ý Û Û Û 
ß 6Û Û 	ã Ý ã Ý Ý @à€w×Ñ˜Ó"€â
C€ò$òò"óô"	�iô 	÷"ñ "ô>"N�:ô "NôJK#�Jô K#ô\, }ô ,ò+ð" €	Ù Ô Ù'GÓ'IÐ $òò;ò|ð. ‡�ñ-ó ð-ò(ò	Pò óeóP9r   