o
    g                     @   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v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g d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d,gd-d. Z$edgd/d0d1 Z%ed2d3 Z&ed4gd5d6d7d8 Z'dS )9    N)Path)cbookpatheffects)check_figures_equalimage_comparison)MatplotlibDeprecationWarningepsz*This test needs a ghostscript installation)reasonTz"This test needs a TeX installation   )rerunsorientationportrait	landscapezformat, use_log, rcParamspsFps.usedistillerghostscriptxpdftext.usetex	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|d |	ddgddg d}t jd s2|d7 }|
| g }	|drD|	t j |drN|	t |drX|	t z|j|| |d	 |j|| |d	 W n t|	y }
 ztt|
 W Y d }
~
nd }
~
ww | d
}| }tdd|}tdd|}||ddksJ W d    n1 sw   Y  W d    d S W d    d S 1 sw   Y  d S )Nlog      u	   Déjà vur   u    −€r   r   )formatr   asciis   (?<=
%%CreationDate: ).*    s   
   
)mplrcParamsupdatepltsubplotsioStringIOBytesIO
set_yscaleplot	set_titlegetappendExecutableNotFoundErrorRuntimeErrorr   savefigtuplepytestskipstrgetvalueencoderesubreplace)r   use_logr   r   figaxs_bufb_buftitleallowable_exceptionsexcs_valb_val r@   ^/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/matplotlib/tests/test_backend_ps.pytest_savefig_to_stringio   s<   







PrB   c                  C   sl   t jdddgtjd< t \} }|g d t }| j	|dd W d    d S 1 s/w   Y  d S )N   w)	linewidth
foregroundzpath.effects)r   r   r
   r   r   )
r   
withStroker   r   r    r!   r&   r"   r$   r,   )r7   r8   r   r@   r@   rA   test_patheffectsS   s   

"rI   c                 C   s~   t | d}|  tjtt|d# dtjd< t	g d t
d tj|d dd	 W d    d S 1 s8w   Y  d S )
Nzshort-1)tempdirTr   )r   r   r
   rC   z\textbf{time} (s)ztex_demo.epsr   rG   )r   mkdirr   _setattr_cmtempfiler0   r   r   r    r&   xlabelr,   )tmpdirbase_tempdirr@   r@   rA   test_tilde_in_tempfilename\   s   


"rQ   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r7   r8   r@   r@   rA   test_transparencyo   s   rZ   c                  C   s   t  \} }t }| j|dd | }W d    n1 s w   Y  td|tj}|s1J td|tj}|s=J t	ddD ]}d|
|vsMJ t|
|tt|
|dksaJ qBd S )Nr   rG   s$   ^%%BoundingBox: (.+) (.+) (.+) (.+)$s)   ^%%HiResBoundingBox: (.+) (.+) (.+) (.+)$r         .)r    r!   r"   r$   r,   r1   r3   search	MULTILINErangegroupintr.   approxfloat)r7   r8   bufbbhibbir@   r@   rA   	test_bboxw   s   

*rh   c                   C   sV   dt jd< td tt tjt	 dd W d   dS 1 s$w   Y  dS )z"Test failing latex subprocess callTr   z$22_2_2$r   rG   N)
r   r   r    rN   r.   raisesr+   r,   r"   r$   r@   r@   r@   rA   test_failing_latex   s
   

"rj   c                 C   sP   |  d tjddddd tjt dd | jr$tdd	 | jD s&J d S )
NWARNINGrU   rV   T)usetexr   rG   c                 s   s    | ]	}d |  v V  qdS )zas if usetex=FalseN)
getMessage).0recordr@   r@   rA   	<genexpr>   s    z&test_partial_usetex.<locals>.<genexpr>)	set_levelr    figtextr,   r"   r$   recordsall)caplogr@   r@   rA   test_partial_usetex   s   
rv   z
useafm.epsc                  C   s:   dt jd< t \} }|  |d |ddd d S )NTr   rU   qk)r   r   r    r!   rW   axhlinerX   rY   r@   r@   rA   test_useafm   s
   

ry   z	type3.epsc                   C   s   t ddd d S )NrU   zI/J)r    rr   r@   r@   r@   rA   test_type3_font   s   rz   )
extensionsc                 C   s*   |   }|jddd| jdd |   d S )Nr   helloT)	transformclip_on)add_subplotrX   transFigure)fig_testfig_refr8   r@   r@   rA   test_text_clip   s   r   c                 C   s>   t  }|ddd | d }|| tjjj|dd d S )NrU   defztest.epsF)cache)r    figurerX   r,   r   testingcompareconvert)tmp_pathr7   outr@   r@   rA   test_d_glyph   s
   
r   ztype42_without_prep.epsmpl20)stylec                   C   s&   dt jd< dt jd< tddd d S )N*   zps.fonttypestixzmathtext.fontsetrU   zMass $m$)r   r   r    rr   r@   r@   r@   rA   test_type42_font_without_prep   s   

r   )(r"   pathlibr   r3   rM   r.   
matplotlibr   matplotlib.pyplotpyplotr    r   r   matplotlib.testing.decoratorsr   r   matplotlib.cbookr   markskipifr   r   	converterneeds_ghostscriptcheckdep_usetexneeds_usetexflakyparametrizerB   rI   rQ   rZ   rh   rj   rv   ry   rz   r   r   r   r@   r@   r@   rA   <module>   sj    
(	

	






