U
    Âmœ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dddddddg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d0d1„ ƒZ0ed2gƒd3d4„ ƒZ1ed5gƒd6d7„ ƒZ2ed8gƒd9d:„ ƒZ3edgd;d<d=„ ƒZ4ed>d?„ ƒZ5ed@gdAdBdCdD„ ƒZ6e	j% 'dEdFdGg¡dHdI„ ƒZ7dJdK„ Z8dLdM„ Z9dNdO„ Z:edPgdQdRdSdT„ ƒZ;edUgdVdRdWdX„ ƒZ<edYgƒdZd[„ ƒZ=ed\gd]d^idAd_d`da„ ƒZ>dS )bé    )Ú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.useafmzps with distiller=ghostscriptzps with distiller=xpdfzps with usetexzeps afmzeps with usetex)Zidsc                 C   sˆ  t j |¡ t ¡ \}}t ¡ \}t ¡ F}|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 n6 t|	ƒk
r }
 zt t|
ƒ¡ W 5 d }
~
X Y nX |jrt‚|jr(t‚| ¡  d
¡}| ¡ }t dd|¡}t dd|¡}|| dd¡kspt‚W 5 Q R X W 5 Q R X 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ÚAssertionErrorÚ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:   úY/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/matplotlib/tests/test_backend_ps.pyÚtest_savefig_to_stringio   s:    







 r<   c               	   C   sX   t jdddgtjd< t ¡ \} }| dddg¡ t ¡ }| j	|dd	 W 5 Q R X d S )
Né   Úw)Ú	linewidthÚ
foregroundzpath.effectsr   r   r   r   ©r   )
r   Z
withStroker   r   r    r!   r%   r"   r$   r*   )r6   r7   r   r:   r:   r;   Útest_patheffectsT   s    ÿ

rB   c              	   C   sl   t | dƒ}| ¡  tjtt|ƒd> dtjd< t 	ddddg¡ t 
d	¡ tj|d
 dd W 5 Q R X d S )Nzshort-1)ÚtempdirTr   r   r   r   r=   z\textbf{time} (s)ztex_demo.epsr   rA   )r   Úmkdirr   Z_setattr_cmÚtempfiler.   r   r   r    r%   Úxlabelr*   )Z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 5 Q R X t d|tj¡}|sNt	‚t d|tj¡}|sft	‚t
ddƒD ]>}d| |¡ks†t	‚t| |¡ƒt t| |¡ƒd¡kspt	‚qpd S )Nr   rA   s$   ^%%BoundingBox: (.+) (.+) (.+) (.+)$s)   ^%%HiResBoundingBox: (.+) (.+) (.+) (.+)$r   é   ó   .)r    r!   r"   r$   r*   r1   r3   ÚsearchÚ	MULTILINEr0   ÚrangeÚgroupÚintr,   ZapproxÚfloat)r6   r7   ÚbufZbbZhibbÚir:   r:   r;   Ú	test_bbox‚   s    
ÿr]   c                	   C   s@   dt jd< t d¡ t t¡ tjt 	¡ dd W 5 Q R X dS )z"Test failing latex subprocess callTr   z$22_2_2$r   rA   N)
r   r   r    rF   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
| ¡ ksXt‚d S )NÚWARNINGçš™™™™™¹?rM   T)Zusetexçš™™™™™É?Úbarr   rA   zas if usetex=False)	Z	set_levelr    Úfigtextr*   r"   r$   ÚrecordsÚ
getMessager0   )Ú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   rA   )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   Ú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¡sht‚d S )Nr   g      Ð?rL   z&Forty-two is the answer to everything!r   rA   s
   /FontType zutf-8)Úencodings    def)r   r   r    r!   rO   r"   r$   r*   Úbytesr3   rU   r1   rV   r0   )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sDt‚dS )z-Test that dashed lines do not break PS outputr   r   z--)Z	linestyler   rA   N)r    r!   r%   r"   r$   r*   Útellr0   )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   rA   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˜t‚d S )Nr=   Zpolar)Z
projection)Z
subplot_kw)ZxticksZyticksr   r   zhello, worldr   rA   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   Úvaluesr0   )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|||ddd	g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  s     z(test_path_collection.<locals>.<listcomp>r   é   éÈ   é   r   g{®Gáz”?g{®Gá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   sR   t  dddg¡}t  ddddg|j¡}tjddgddgddg||d	 t ¡  d S )
NrH   rp   rr   r·   g      à¿rL   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   rE   Ú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<   rB   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    ù	ùø*	

	
	

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

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