a
    ü
þdó)  ã                   @   sº  d dl mZ d dlm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mZmZmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d d	lmZmZ d dl
Zd dlm Z d dlm Z! d dl"m#Z$ e	j%j&d
de	j% 'dddg¡e	j%j'dddi fddddifddddifddddifddi fddddifddddifgg d¢ddd„ ƒƒƒZ(dd„ Z)eedd „ ƒƒZ*ed!gƒd"d#„ ƒZ+eed!gƒd$d%„ ƒƒZ,d&d'„ Z-ed(d)„ ƒZ.ed*d+„ ƒZ/ed,d-„ ƒZ0ed.gƒd/d0„ ƒZ1ed1gƒd2d3„ ƒZ2ed4gƒd5d6„ ƒZ3edgd7d8d9„ ƒZ4ed:d;„ ƒZ5ed<gd=d>d?d@„ ƒZ6e	j% 'dAdBdCg¡dDdE„ ƒZ7dFdG„ Z8dHdI„ Z9dJdK„ Z:edLgdMdNdOdP„ ƒZ;edQgdRdNdSdT„ ƒZ<edUgƒdVdW„ ƒZ=edXgdYdZid=d[d\d]„ ƒZ>dS )^é    )ÚCounter)ÚPathN)ÚcbookÚpathÚpatheffectsÚfont_manager)ÚMatplotlibDeprecationWarning)ÚFigure)ÚEllipse)Úneeds_ghostscriptÚneeds_usetex)Úcheck_figures_equalÚimage_comparisoné   )ZrerunsÚorientationZportraitZ	landscapezformat, use_log, rcParamsÚpsFúps.usedistillerZghostscriptZxpdfútext.usetexTÚepsú	ps.useafm)r   zps with distiller=ghostscriptzps with distiller=xpdfzps with usetexr   zeps afmzeps with usetex)Úidsc                 C   s¶  t j |¡ t ¡ \}}t ¡ ~}t ¡ R}|r>| d¡ | 	ddgddg¡ d}t jd sh|d7 }| 
|¡ g }	| d¡rŒ|	 t j¡ | d¡r |	 t¡ | d¡r´|	 t¡ z$|j|| |d	 |j|| |d	 W n8 t|	ƒy }
 zt t|
ƒ¡ W Y d }
~
n
d }
~
0 0 |jrJ ‚|jr*J ‚| ¡  d
¡}| ¡ }t dd|¡}t dd|¡}|| dd¡ksrJ ‚W d   ƒ n1 sˆ0    Y  W d   ƒ n1 s¨0    Y  d S )NÚlogé   é   u	   DÃ©jÃ  vur   u    âˆ’â‚¬r   r   )Úformatr   Úasciis   (?<=
%%CreationDate: ).*ó    s   
ó   
)ÚmplÚrcParamsÚupdateÚpltÚsubplotsÚioÚStringIOÚBytesIOZ
set_yscaleÚplotÚ	set_titleÚgetÚappendZExecutableNotFoundErrorÚRuntimeErrorr   ÚsavefigÚtupleÚpytestÚskipÚstrÚclosedÚgetvalueÚencodeÚreÚsubÚreplace)r   Zuse_logr   r   ÚfigÚaxZs_bufZb_bufÚtitleZallowable_exceptionsÚexcZs_valZb_val© r:   úi/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/matplotlib/tests/test_backend_ps.pyÚtest_savefig_to_stringio   s:    







$r<   c                  C   sj   t jdddgtjd< t ¡ \} }| g d¢¡ t ¡ }| j	|dd W d   ƒ n1 s\0    Y  d S )Né   Úw)Ú	linewidthZ
foregroundzpath.effects)r   r   r   r   ©r   )
r   Z
withStroker   r   r!   r"   r&   r#   r%   r+   )r6   r7   r   r:   r:   r;   Útest_patheffectsT   s    ÿ

rA   c                 C   s|   t | dƒ}| ¡  tjtt|ƒdD dtjd< t 	g d¢¡ t 
d¡ tj|d dd	 W d   ƒ n1 sn0    Y  d S )
Nzshort-1)ÚtempdirTr   )r   r   r   r=   z\textbf{time} (s)ztex_demo.epsr   r@   )r   Úmkdirr   Z_setattr_cmÚtempfiler/   r   r   r!   r&   Úxlabelr+   )ÚtmpdirZbase_tempdirr:   r:   r;   Útest_tilde_in_tempfilename]   s    


rG   z	empty.epsc                  C   s@   t  ¡ \} }| ¡  |jddgddd |jdddddd d S )Nr   r   Úr©ÚcolorÚalphaç      à?Úfoo)r!   r"   Úset_axis_offr&   Útext©r6   r7   r:   r:   r;   Útest_transparencyp   s    rQ   c                  C   sJ   dt jd< t ¡ \} }| ¡  |jddgddd |jdddddd d S )	NTr   r   r   rH   rI   rL   rM   )r   r   r!   r"   rN   r&   rO   rP   r:   r:   r;   Útest_transparency_texx   s
    
rR   c                  C   sÈ   t  ¡ \} }t ¡ &}| j|dd | ¡ }W d   ƒ n1 s@0    Y  t d|tj¡}|sbJ ‚t d|tj¡}|szJ ‚t	ddƒD ]>}d| 
|¡vsšJ ‚t| 
|¡ƒt t| 
|¡ƒd¡ks„J ‚q„d S )Nr   r@   s$   ^%%BoundingBox: (.+) (.+) (.+) (.+)$s)   ^%%HiResBoundingBox: (.+) (.+) (.+) (.+)$r   é   ó   .)r!   r"   r#   r%   r+   r1   r3   ÚsearchÚ	MULTILINEÚrangeÚgroupÚintr-   ZapproxÚfloat)r6   r7   ÚbufZbbZhibbÚir:   r:   r;   Ú	test_bbox‚   s    
&ÿr]   c                   C   sT   dt jd< t d¡ t t¡" tjt 	¡ dd W d  ƒ n1 sF0    Y  dS )z"Test failing latex subprocess callTr   z$22_2_2$r   r@   N)
r   r   r!   rE   r-   Zraisesr*   r+   r#   r%   r:   r:   r:   r;   Útest_failing_latex”   s    

r^   c                 C   s\   |   d¡ tjddddd tjddddd tjt ¡ dd	 | j\}d
| ¡ v sXJ ‚d S )NÚWARNINGçš™™™™™¹?rM   T)Zusetexçš™™™™™É?Úbarr   r@   zas if usetex=False)Z	set_levelr!   Úfigtextr+   r#   r%   ÚrecordsÚ
getMessage)ÚcaplogÚrecordr:   r:   r;   Útest_partial_usetexž   s    
rh   c                 C   s6   t j dddœ¡ t ddd¡ tjt ¡ dd d S )NTz$\usepackage{color,graphicx,textcomp})r   ztext.latex.preamblerL   rM   r   r@   )r   r   r    r!   rc   r+   r#   r%   )rf   r:   r:   r;   Útest_usetex_preamble¨   s    ýri   z
useafm.epsc                  C   s:   dt jd< t ¡ \} }| ¡  | d¡ | ddd¡ d S )NTr   rL   Zqk)r   r   r!   r"   rN   ZaxhlinerO   rP   r:   r:   r;   Útest_useafm³   s
    

rj   z	type3.epsc                   C   s   t  ddd¡ d S )NrL   zI/J)r!   rc   r:   r:   r:   r;   Útest_type3_font¼   s    rk   zcoloredhatcheszerolw.epsc                  C   sh   t  ¡ } |  tdddddddd¡ |  tdd	d	d
dddd¡ |  tdddddddd¡ |  ¡  d S )N)r   r   r   ú/ÚnonerH   r   )ZhatchZ	facecolorÚ	edgecolorr?   )rL   rL   rL   ú+Úgra   )r   r   g333333Ó?gš™™™™™é?ú\Úb)r!   ZgcaZ	add_patchr
   rN   )r7   r:   r:   r;   Ú!test_colored_hatch_zero_linewidthÁ   s    ÿÿÿrs   )Ú
extensionsc                 C   s*   |   ¡ }|jddd| jdd |  ¡  d S )Nr   ZhelloT)Z	transformZclip_on)Zadd_subplotrO   ZtransFigure)Zfig_testZfig_refr7   r:   r:   r;   Útest_text_clipÍ   s    ru   c                 C   s>   t  ¡ }| ddd¡ | d }| |¡ tjjj|dd d S )NrL   Údefztest.epsF)Úcache)r!   ÚfigurerO   r+   r   ZtestingÚcompareÚconvert)Útmp_pathr6   Úoutr:   r:   r;   Útest_d_glyphÕ   s
    
r}   ztype42_without_prep.epsZmpl20)Ústylec                   C   s&   dt jd< dt jd< t ddd¡ d S )Né*   úps.fonttypeZstixzmathtext.fontsetrL   zMass $m$)r   r   r!   rc   r:   r:   r:   r;   Útest_type42_font_without_prepà   s    

r   ÚfonttypeÚ3Z42c                 C   sl   | t jd< t ¡ \}}| ddd¡ t ¡ }|j|dd dt| › dd	 d
 }t	 
|| ¡ t	j¡shJ ‚d S )Nr€   g      Ð?rL   z&Forty-two is the answer to everything!r   r@   s
   /FontType zutf-8)Úencodings    def)r   r   r!   r"   rO   r#   r%   r+   Úbytesr3   rU   r1   rV   )r‚   r6   r7   r[   Útestr:   r:   r;   Útest_fonttypeé   s    
r‡   c                  C   sH   t  ¡ \} }|jddgdd t ¡ }| j|dd | ¡ dksDJ ‚dS )z-Test that dashed lines do not break PS outputr   r   z--)Z	linestyler   r@   N)r!   r"   r&   r#   r%   r+   Útell)r6   r7   r[   r:   r:   r;   Útest_linedashø   s
    r‰   c                  C   s<   t ƒ } |  ddd¡ t ¡ }| j|dd | j|dd d S )NrL   z
foo

r   r@   r   )r	   rO   r#   r%   r+   )rx   r[   r:   r:   r;   Útest_empty_line  s
    rŠ   c                  C   sœ   t ƒ } | jddtddd}|jD ] }|jg g d | ddg¡ q"|  d¡ t ¡ }| j	|d	d
 | 
d¡ dd„ | ¡ D ƒ}tt|ƒ ¡ ƒdks˜J ‚d S )Nr=   Zpolar)Z
projection)Z
subplot_kw)ZxticksZyticksr   r   zhello, worldr   r@   r   c                 S   s$   g | ]}|  d ¡r| d¡d ‘qS )rl   ú r   )Ú
startswithÚ	partition)Ú.0Úlnr:   r:   r;   Ú
<listcomp>  s   
þz0test_no_duplicate_definition.<locals>.<listcomp>)r	   r"   ÚdictZflatÚsetr&   Zsuptitler#   r$   r+   ÚseekÚ	readlinesÚmaxr   Úvalues)r6   Zaxsr7   r[   Zwdsr:   r:   r;   Útest_no_duplicate_definition  s    


ÿr—   zmulti_font_type3.epsgR¸…ëQà?)Ztolc                  C   sh   t jdgd} tt  | ¡ƒjdkr,t d¡ tjdddgdd tjd	d
d t 	¡ }| 
ddd¡ d S )NúWenQuanYi Zen Hei©Úfamilyúwqy-zenhei.ttcúFont may be missingÚfontúDejaVu Sansé   ©rš   Úsizer   r   ©r‚   ç333333Ã?çffffffÞ?õ"   There are å‡ ä¸ªæ±‰å­— in between!©ÚfmZFontPropertiesr   ZfindfontÚnamer-   r.   r!   Úrcrx   rO   ©Úfpr6   r:   r:   r;   Útest_multi_font_type3!  s    
r¬   zmulti_font_type42.epsgš™™™™™ù?c                  C   sh   t jdgd} tt  | ¡ƒjdkr,t d¡ tjdddgdd tjd	d
d t 	¡ }| 
ddd¡ d S )Nr˜   r™   r›   rœ   r   rž   rŸ   r    r   r   r¢   r£   r¤   r¥   r¦   rª   r:   r:   r;   Útest_multi_font_type42.  s    
r­   zscatter.epsc            	      C   sÂ   t j d¡} |  ddd¡}|  ddd¡}|  ddd¡}t ¡ \}}|j|||g d¢dd	 | ¡  d
d„ tddƒD ƒ}|  ddd¡ 	dd¡}ddg}t
j||dd|d}| |¡ | dd¡ d S )Ni!N,r   r   é
   é   éd   )gÍÌÌÌÌÌì?ra   r`   ú<)rn   Úmarkerc                 S   s   g | ]}t j |¡‘qS r:   )r   r   Zunit_regular_polygon)rŽ   r\   r:   r:   r;   r   D  r   z(test_path_collection.<locals>.<listcomp>r   é   éÈ   é   r   g{®Gáz”?g{®Gáz¤?éÿÿÿÿZyellow)ZzorderZ
facecolorsÚoffsets)ÚnpÚrandomZdefault_rngÚuniformr!   r"   ÚscatterrN   rW   ZreshapeÚmcollectionsZPathCollectionZadd_collectionZset_xlim)	ÚrngZxvalsZyvalsÚsizesr6   r7   Úpathsr·   Zpcr:   r:   r;   Útest_path_collection;  s    
ÿ
rÀ   zcolorbar_shift.epsZbbox_inchesZtight)Zsavefig_kwargr~   c                 C   sL   t  g d¢¡}t  g d¢|j¡}tjddgddgddg||d t ¡  d S )N)rH   rp   rr   )r¶   g      à¿rL   r   r   r   )ÚcÚcmapÚnorm)ÚmcolorsZListedColormapZBoundaryNormÚNr!   r»   Zcolorbar)r{   rÂ   rÃ   r:   r:   r;   Útest_colorbar_shiftM  s     rÆ   )?Úcollectionsr   Úpathlibr   r#   r3   rD   Únumpyr¸   r-   Z
matplotlibr   r   r   r   r§   Zmatplotlib._apir   Zmatplotlib.figurer	   Zmatplotlib.patchesr
   Zmatplotlib.testing._markersr   r   Zmatplotlib.testing.decoratorsr   r   r   Zmatplotlib.collectionsr¼   Zmatplotlib.colorsÚcolorsrÄ   Zmatplotlib.pyplotZpyplotr!   ÚmarkZflakyZparametrizer<   rA   rG   rQ   rR   r]   r^   rh   ri   rj   rk   rs   ru   r}   r   r‡   r‰   rŠ   r—   r¬   r­   rÀ   rÆ   r:   r:   r:   r;   Ú<module>   s’   ùø*	

	
	










	


ÿ