U
    \	a                     @   s  d dl 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
 d dlmZmZ d dlmZmZ d dlmZ ejjdejjjkddZejjed	 d
d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d'd( Z ed)d* Z!ed+d, Z"ed-gd.d/ Z#ed0gd1d2 Z$edgd3d4d5 Z%ed6d7 Z&ed8gd9d:d;d< Z'dS )=    N)Path)cbookpatheffects)check_figures_equalimage_comparison)MatplotlibDeprecationWarningepsz*This test needs a ghostscript installation)reasonTz"This test needs a TeX installation   )ZrerunsorientationZportraitZ	landscapezformat, use_log, rcParamspsFps.usedistillerZghostscriptZxpdftext.usetex	ps.useafmzps with distiller=ghostscriptzps with distiller=xpdfzps with usetexzeps afmzeps with usetex)idsc                 C   sp  t j| t \}}t D}t .}|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 | d
}| }tdd|}tdd|}||ddksXt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getvalueencoderesubreplaceAssertionError)r   Zuse_logr   r   figaxZs_bufZb_buftitleZallowable_exceptionsexcZs_valZb_val r4   D/tmp/pip-unpacked-wheel-wjyw_3jo/matplotlib/tests/test_backend_ps.pytest_savefig_to_stringio   s6    







 r6   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)Z	linewidthZ
foregroundzpath.effectsr   r   r
   r   r   )
r   Z
withStroker   r   r   r   r    r   r   r%   )r0   r1   r   r4   r4   r5   test_patheffectsS   s    

r:   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
   r7   z\textbf{time} (s)ztex_demo.epsr   r9   )r   mkdirr   Z_setattr_cmtempfiler)   r   r   r   r    xlabelr%   )ZtmpdirZbase_tempdirr4   r4   r5   test_tilde_in_tempfilename\   s    


r?   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r0   r1   r4   r4   r5   test_transparencyo   s    rH   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st	t||tt||dkspt	qpd S )Nr   r9   s$   ^%%BoundingBox: (.+) (.+) (.+) (.+)$s)   ^%%HiResBoundingBox: (.+) (.+) (.+) (.+)$r         .)r   r   r   r   r%   r*   r,   search	MULTILINEr/   rangegroupintr'   Zapproxfloat)r0   r1   bufZbbZhibbir4   r4   r5   	test_bboxw   s    
rS   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   r9   N)
r   r   r   r>   r'   Zraisesr$   r%   r   r   r4   r4   r4   r5   test_failing_latex   s    

rT   c                 C   sP   |  d tjddddd tjt dd | jrHtdd	 | jD sLtd S )
NWARNINGrC   rD   T)Zusetexr   r9   c                 s   s   | ]}d |  kV  qdS )zas if usetex=FalseN)
getMessage).0recordr4   r4   r5   	<genexpr>   s   z&test_partial_usetex.<locals>.<genexpr>)	Z	set_levelr   figtextr%   r   r   recordsallr/   )Zcaplogr4   r4   r5   test_partial_usetex   s    
r]   z
useafm.epsc                  C   s:   dt jd< t \} }|  |d |ddd d S )NTr   rC   Zqk)r   r   r   r   rE   ZaxhlinerF   rG   r4   r4   r5   test_useafm   s
    

r^   z	type3.epsc                   C   s   t ddd d S )NrC   zI/J)r   rZ   r4   r4   r4   r5   test_type3_font   s    r_   )
extensionsc                 C   s*   |   }|jddd| jdd |   d S )Nr   ZhelloT)Z	transformZclip_on)Zadd_subplotrF   ZtransFigure)Zfig_testZfig_refr1   r4   r4   r5   test_text_clip   s    ra   c                 C   s>   t  }|ddd | d }|| tjjj|dd d S )NrC   defztest.epsF)cache)r   figurerF   r%   r   testingcompareconvert)Ztmp_pathr0   outr4   r4   r5   test_d_glyph   s
    
ri   ztype42_without_prep.epsZmpl20)stylec                   C   s&   dt jd< dt jd< tddd d S )N*   zps.fonttypeZstixzmathtext.fontsetrC   zMass $m$)r   r   r   rZ   r4   r4   r4   r5   test_type42_font_without_prep   s    

rl   )(r   pathlibr   r,   r=   r'   Z
matplotlibr   Zmatplotlib.pyplotZpyplotr   r   r   Zmatplotlib.testing.decoratorsr   r   Zmatplotlib.cbookr   markZskipifre   rf   	converterZneeds_ghostscriptZcheckdep_usetexZneeds_usetexZflakyZparametrizer6   r:   r?   rH   rS   rT   r]   r^   r_   ra   ri   rl   r4   r4   r4   r5   <module>   sv   
	(	

	






