o
    h                     @   s  d dl mZ d dlZd dlmZ d dlZd dlZ	d dlm
Z
 d dlmZ d dlmZmZ d dlmZ d dlmZ eZedgd	d
gdddd Ze dd Ze dd Zdd Zedgdd Zejdg ddd Zejdddgdd Zejd d!d"gd#d$ Zd%d& Z ejj!d'd(ejd)d	d*gd+d, Z"ze	#d-j$ed.k Z%W n e	j&y   d/Z%Y nw ed0gg d1de%rd2nd d3d4d5 Z'dS )6    )TemporaryFileN)parse)dviread)_has_tex_package)check_figures_equalimage_comparison)needs_usetextest_usetexpdfpngmpl20)baseline_images
extensionsstylec                  C   s   dt jd< t \} }ddtddddd	}|jd
i | |jdi | |jdi | |jdi | |jdi | dd |jD D ]}|| qFdd |jD D ]}|| qV|	  d S )NTtext.usetexbaseline   r   knone)pad	edgecolor	facecolor)verticalalignmentsizebbox)皙?gffffff?zO\LaTeX\ $\left[\int\limits_e^{2e}\sqrt\frac{\log^3 x}{x}\,\mathrm{d}x \right\}$)r   333333?lg)g?r   z$\frac{1}{2}\pi$)g333333?r   z	$p^{3^A}$)g?r   z	$p_{3_2}$c                 S      h | ]}|  d  qS r   get_position.0t r%   p/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/matplotlib/tests/test_usetex.py	<setcomp>&       ztest_usetex.<locals>.<setcomp>c                 S   r      r    r"   r%   r%   r&   r'   (   r(   )
mplrcParamspltsubplotsdicttexttextsaxvlineaxhlineset_axis_off)figaxkwargsxyr%   r%   r&   r	      s"   
c                 C   s   dt jd< | ddd d S )NTr         ?z% a commentr+   r,   r0   fig_testfig_refr%   r%   r&   
test_empty-   s   
r?   c                 C   s*   dt jd< | ddd |ddd d S )NTr   r:   z$-$u   −r;   r<   r%   r%   r&   test_unicode_minus3   s   
r@   c                  C   s:   dt jd< t  } |  dd dtjd< | j  d S )NTzaxes.formatter.use_mathtextr*   r   )r-   r,   figureadd_subplotset_xlimr+   canvasdraw)r5   r%   r%   r&   test_mathdefault:   s
   

rG   zeqnarray.pngc                  C   s*   d} t jdd}|jdd| dddd d S )Nz/\begin{eqnarray*}foo\\bar\\baz\\\end{eqnarray*})r*   r*   )figsizer:   Tcenter)usetexhorizontalalignmentr   )r-   rB   r0   )r0   r5   r%   r%   r&   test_multiline_eqnarrayD   s   
rL   fontsize)   
      c                 C   s   t jd | t jd< i }t }dD ]1}|  |D ]}|jddd| ddd q|j	  t
|j d d	kjd
d ||< qth | d
ksQJ d S )Nr   z	font.size)r)   )rA   )rA   r*   r:   $TrJ   ).r      r*   )axis)r+   r   user,   r-   rB   clearr0   rE   rF   nparraybuffer_rgbaanysumlenvalues)rM   heightsr5   valsr8   r%   r%   r&   test_minus_no_descentS   s   

r`   pkgxcolorchemformulac                 C   s   t | st|  d dtjd< t }|ddd}|j	  d|  tjd< t }|ddd}|j	  t
j| |  d S )Nz is not availableTr   r:   zSome text 0123456789z8\PassOptionsToPackage{dvipsnames}{xcolor}\usepackage{%s}text.latex.preamble)r   pytestskipr+   r,   r-   rB   r0   rE   rF   rW   testingassert_array_equalget_window_extent)ra   r5   r0   text2r%   r%   r&   test_usetex_packagesg   s   


rk   preamblez\usepackage[full]{textcomp}z\usepackage{underscore}c                 C   s2   | t jd< t  }|jddddd |j  d S )Nrd   r:   zhello, worldTrR   )r-   r,   rB   r0   rE   rF   )rl   r5   r%   r%   r&   test_latex_pkg_already_loadedz   s   
rm   c                  C   sh   dt jd< tdd d d tdd} t  \}}|jdd| d |  |jd	d	d
dd t   d S )NTr      rA   )a_bcrp   ro   )datar   foo_barrR   )r-   r,   ranger.   plotlegendr0   rF   )dfr5   r6   r%   r%   r&   test_usetex_with_underscore   s   
rw      )rerunsfmtsvgc              	   C   s   | tjddd  dtjd< t \}}|ddd t -}t	
t |j|| d W d	   n1 s7w   Y  W d	   d	S W d	   d	S 1 sOw   Y  d	S )
z:An error is raised if a TeX font lacks a Type-1 equivalent__getitem__c                 S   s   t jddd d d dS )Ns   texfonts	   Some Font)texnamepsnameeffectsencodingfilename)r   PsFont)selfr   r%   r%   r&   <lambda>   s    z%test_missing_psfont.<locals>.<lambda>Tr   r:   hello)formatN)setattrr   
PsfontsMapr+   r,   r-   r.   r0   r   re   raises
ValueErrorsavefig)rz   monkeypatchr5   r6   tmpfiler%   r%   r&   test_missing_psfont   s   
Pr   gsz9.55Trotation)epsr
   r   r{   gHzG@)r   r   r   tolc                  C   s  dt jd< t } | g d}|jddgg ddgg dd d	d
 dD }d|d< d|d< tg dD ]P\}}tg dD ]E\}}tg dD ]:\}}|d }||d  }	||d  }
|j|	|
dd| ddd |j|	|
d||  ||  d| d|||d qGq=q3d S )NTr   )r   r   r*   r*   g      rn   rx   F)xlimxticksylimyticksframe_onc                 S   s   i | ]}||d  qS r   r%   )r#   valr%   r%   r&   
<dictcomp>   s    z!test_rotation.<locals>.<dictcomp>)toprI   bottomleftrightBr   Ccenter_baseline)r   rI   r   r   r   )r   rI   r   )r   Z      i     +   r:   )rp   
markersizemarkeredgewidthz$\mathrm{My  z}$)r   rK   r   )	r+   r,   r-   rB   add_axesset	enumeratert   r0   )r5   r6   r0   ivajhar   angler8   r9   r%   r%   r&   test_rotation   s(   
$r   )(tempfiler   numpyrW   packaging.versionr   parse_versionre   
matplotlibr+   r   matplotlib.testingr   matplotlib.testing.decoratorsr   r   matplotlib.testing._markersr   matplotlib.pyplotpyplotr-   
pytestmarkr	   r?   r@   rG   rL   markparametrizer`   rk   rm   rw   flakyr   _get_executable_infoversion_old_gs_versionExecutableNotFoundErrorr   r%   r%   r%   r&   <module>   s\    








