o
    tBh>!                     @   s4  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
 d dlmZ d dlmZ d dlmZmZ d dl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#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d0d1 Z)ed2gd3d4 Z*edgd5d6d7 Z+ed8d9 Z,ed:gd;d<d=d> Z-ejd?d@dAgdBdC Z.dDdE Z/dFdG Z0dS )H    )Counter)PathN)cbookpatheffects)MatplotlibDeprecationWarning)Figure)check_figures_equalimage_comparison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 |jrJ |jrJ d
| v rtd | 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      zThis appears to be the result of a bug in ghostscript or one of its dependencies that fails to ascii85 encode the compressed fonts which results in encoding the string as ascii failing just below.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closedgetvalueencoderesubreplace)r   use_logr!   r   figaxs_bufb_buftitleallowable_exceptionsexcs_valb_val rD   w/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/matplotlib/tests/test_backend_ps.pytest_savefig_to_stringio   sH   









PrF   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/   )r;   r<   r   rD   rD   rE   test_patheffects]   s   

"rM   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   rG   z\textbf{time} (s)ztex_demo.epsr   rK   )r   mkdirr   _setattr_cmtempfiler3   r    r!   r#   r)   xlabelr/   )tmpdirbase_tempdirrD   rD   rE   test_tilde_in_tempfilenamef   s   


"rU   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r;   r<   rD   rD   rE   test_transparencyy   s   r_   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   rV   rW   rZ   r[   )r    r!   r#   r$   r\   r)   r]   r^   rD   rD   rE   test_transparency_tex   s
   
r`   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
   rK   s$   ^%%BoundingBox: (.+) (.+) (.+) (.+)$s)   ^%%HiResBoundingBox: (.+) (.+) (.+) (.+)$r         .)r#   r$   r%   r'   r/   r5   r7   search	MULTILINErangegroupintr1   approxfloat)r;   r<   bufbbhibbirD   rD   rE   	test_bbox   s   

*rn   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   rK   N)
r    r!   r#   rR   r1   raisesr.   r/   r%   r'   rD   rD   rD   rE   test_failing_latex   s
   

"rp   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 s,J d S )NWARNINGg?r[   T)usetexg?barr   rK   zas if usetex=False)	set_levelr#   figtextr/   r%   r'   records
getMessage)caplogrecordrD   rD   rE   test_partial_usetex   s   
rz   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.preamblerZ   r[   r   rK   )r    r!   r"   r#   ru   r/   r%   r'   )rx   rD   rD   rE   test_usetex_preamble   s   r{   z
useafm.epsc                  C   s:   dt jd< t \} }|  |d |ddd d S )NTr   rZ   qk)r    r!   r#   r$   r\   axhliner]   r^   rD   rD   rE   test_useafm   s
   

r~   z	type3.epsc                   C   s   t ddd d S )NrZ   zI/J)r#   ru   rD   rD   rD   rE   test_type3_font   s   r   )
extensionsc                 C   s*   |   }|jddd| jdd |   d S )Nr   helloT)	transformclip_on)add_subplotr]   transFigure)fig_testfig_refr<   rD   rD   rE   test_text_clip   s   r   c                 C   s>   t  }|ddd | d }|| tjjj|dd d S )NrZ   defztest.epsF)cache)r#   figurer]   r/   r    testingcompareconvert)tmp_pathr;   outrD   rD   rE   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*   ps.fonttypestixzmathtext.fontsetrZ   zMass $m$)r    r!   r#   ru   rD   rD   rD   rE   test_type42_font_without_prep   s   

r   fonttype342c                 C   sl   | t jd< t \}}|ddd t }|j|dd dt|  dd	 d
 }t	
|| t	js4J d S )Nr   g      ?rZ   z&Forty-two is the answer to everything!r   rK   s
   /FontType zutf-8)encodings    def)r    r!   r#   r$   r]   r%   r'   r/   bytesr7   rc   r5   rd   )r   r;   r<   rj   testrD   rD   rE   test_fonttype   s   
r   c                  C   sH   t  \} }|jddgdd t }| j|dd | dks"J dS )z-Test that dashed lines do not break PS outputr   r   z--)	linestyler   rK   N)r#   r$   r)   r%   r'   r/   tell)r;   r<   rj   rD   rD   rE   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sLJ d S )NrG   polar)
projection)
subplot_kw)xticksyticksr   r   zhello, worldr
   rK   r   c                 S   s$   g | ]}| d r|dd qS )/ r   )
startswith	partition).0lnrD   rD   rE   
<listcomp>  s    z0test_no_duplicate_definition.<locals>.<listcomp>)r   r$   dictflatsetr)   suptitler%   r&   r/   seek	readlinesmaxr   values)r;   axsr<   rj   wdsrD   rD   rE   test_no_duplicate_definition  s   


r   )1collectionsr   pathlibr   r%   r7   rQ   r1   
matplotlibr   r   matplotlib.cbookr   matplotlib.figurer   matplotlib.testing.decoratorsr   r	   r    matplotlib.pyplotpyplotr#   markskipifr   r   	converterneeds_ghostscriptcheckdep_usetexneeds_usetexflakyparametrizerF   rM   rU   r_   r`   rn   rp   rz   r{   r~   r   r   r   r   r   r   r   rD   rD   rD   rE   <module>   s    
1	

	
	









