a
    s=icº$  ã                   @   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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 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-„ ƒZ(ed.gƒd/d0„ ƒZ)ed1gƒd2d3„ ƒZ*ed4gƒd5d6„ ƒZ+edgd7d8d9„ ƒZ,ed:d;„ ƒZ-ed<gd=d>d?d@„ ƒZ.ej dAdBdCg¡dDdE„ ƒZ/dFdG„ Z0dHdI„ Z1edJgdKdLdMdN„ ƒZ2edOgdPdLdQdR„ ƒZ3dS )Sé    )ÚCounter)ÚPathN)ÚcbookÚ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)Z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© r8   úq/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/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)Ú	linewidthÚ
foregroundzpath.effects)r   r   r   r   ©r   )
r   Z
withStroker   r   r   r    r$   r!   r#   r)   )r4   r5   r   r8   r8   r9   Útest_patheffectsQ   s    ÿ

r@   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)   )ZtmpdirZbase_tempdirr8   r8   r9   Útest_tilde_in_tempfilenameZ   s    


rE   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©r4   r5   r8   r8   r9   Útest_transparencym   s    rO   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   rF   rG   rJ   rK   )r   r   r   r    rL   r$   rM   rN   r8   r8   r9   Útest_transparency_texu   s
    
rP   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)   r/   r1   ÚsearchÚ	MULTILINEÚrangeÚgroupÚintr+   ZapproxÚfloat)r4   r5   ÚbufZbbZhibbÚir8   r8   r9   Ú	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   rD   r+   Zraisesr(   r)   r!   r#   r8   r8   r8   r9   Ú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ÚWARNINGgš™™™™™¹?rK   T)Zusetexçš™™™™™É?Úbarr   r?   zas if usetex=False)Z	set_levelr   Úfigtextr)   r!   r#   ÚrecordsÚ
getMessage)ÚcaplogÚrecordr8   r8   r9   Útest_partial_usetex›   s    
re   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.preamblerJ   rK   r   r?   )r   r   r   r   r`   r)   r!   r#   )rc   r8   r8   r9   Útest_usetex_preamble¥   s    ýrf   z
useafm.epsc                  C   s:   dt jd< t ¡ \} }| ¡  | d¡ | ddd¡ d S )NTr   rJ   Zqk)r   r   r   r    rL   ZaxhlinerM   rN   r8   r8   r9   Útest_useafm°   s
    

rg   z	type3.epsc                   C   s   t  ddd¡ d S )NrJ   zI/J)r   r`   r8   r8   r8   r9   Útest_type3_font¹   s    rh   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   ú/ÚnonerF   r   )ZhatchZ	facecolorZ	edgecolorr=   )rJ   rJ   rJ   ú+Úgr^   )r   r   g333333Ó?gš™™™™™é?ú\Úb)r   ZgcaZ	add_patchr	   rL   )r5   r8   r8   r9   Ú!test_colored_hatch_zero_linewidth¾   s    ÿÿÿro   )Ú
extensionsc                 C   s*   |   ¡ }|jddd| jdd |  ¡  d S )Nr   ZhelloT)Z	transformZclip_on)Zadd_subplotrM   ZtransFigure)Zfig_testZfig_refr5   r8   r8   r9   Útest_text_clipÊ   s    rq   c                 C   s>   t  ¡ }| ddd¡ | d }| |¡ tjjj|dd d S )NrJ   Údefztest.epsF)Úcache)r   ÚfigurerM   r)   r   ÚtestingÚcompareÚconvert)Ztmp_pathr4   Úoutr8   r8   r9   Útest_d_glyphÒ   s
    
ry   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.fontsetrJ   zMass $m$)r   r   r   r`   r8   r8   r8   r9   Ú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      Ð?rJ   z&Forty-two is the answer to everything!r   r?   s
   /FontType zutf-8)Úencodings    def)r   r   r   r    rM   r!   r#   r)   Úbytesr1   rS   r/   rT   )r~   r4   r5   rY   Útestr8   r8   r9   Ú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)r4   r5   rY   r8   r8   r9   Útest_linedashõ   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 )ri   ú r   )Ú
startswithÚ	partition)Ú.0Úlnr8   r8   r9   Ú
<listcomp>  s   
þz0test_no_duplicate_definition.<locals>.<listcomp>)r   r    ÚdictZflatÚsetr$   Zsuptitler!   r"   r)   ÚseekÚ	readlinesÚmaxr   Úvalues)r4   Zaxsr5   rY   Zwdsr8   r8   r9   Ú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   Úrcrt   rM   ©Úfpr4   r8   r8   r9   Ú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¥   r8   r8   r9   Útest_multi_font_type42"  s    
r¨   )4Úcollectionsr   Úpathlibr   r!   r1   rC   r+   Z
matplotlibr   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.pyplotZpyplotr   ÚmarkZflakyZparametrizer:   r@   rE   rO   rP   r[   r\   re   rf   rg   rh   ro   rq   ry   r}   rƒ   r…   r’   r§   r¨   r8   r8   r8   r9   Ú<module>   s~   ùø*	

	
	

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




