o
    j                     @   s.  d 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	 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mZ dd
lmZ ddlmZmZ ddlZddlmZ ddlmZ dddZ ej!"dddddddej#dddeegdddej#dddedg
d d! Z$ej!"d"d#d$gd%d& Z%dS )'z
Test output reproducibility.
    N)pyplot)get_sample_data)PathCollection)	BboxImage)AnchoredOffsetboxAuxTransformBox)Circle	PathPatch)Path)subprocess_run_for_testing)needs_ghostscriptneeds_usetex)TextPath)IdentityTransformmhippdfFc              	   C   s  t | t jd|d t }d| v rX|ddd}td}|j|dgd dd |j|d	gd d
d |j|dgd dd |j|dgd dd |j|dgd dd d| v r|ddd	}|	tddtdd|j	tdddgd tddd }|
g d d}t||D ]	\}	}
|	|
 qd| v rg dg dg dg}|dddj|dd g dg dg dg}|dddj|dd g dg dg dg}|dddj|dd d| v rG d d! d!t}|jd"d#}|d	gg}|td$d%d& |d	\}}ttd'}td(d)d*d+}|||d,d-}tt }|| td.|d/d0d1}|| t  }| jd9  _| jd	8  _t  }|jd d d2 |_t||}td }| jd39  _|jd	d	d/d/d4\}}||fD ]B}|\}}t |gdd5d6d7d8d9}|||j! |"| t|dd5d6d7d8d9}|||j! |#| |$d:dg |%d:dg q}td}|ddd}||| |&d; |'d; |(d; t)t*j+d<t*j+}|j,||d= d S )>NZasdf)zsvg.hashsaltztext.usetexm      
   D)marker   x   ^   H   vh)bottom)g      ?g      @g      @g      @)-+r   \*oO.i)r   r   r   )r   r   r   )r   r   r   nearest)interpolation)r   r   r   Zbilinear)r   r   r   Zbicubicpc                       s:   e Zd ZdZ fddZ fddZd	 fdd	Z  ZS )
z+_save_figure.<locals>.PathClippedImagePatchz
            The given image is used to draw the face of the patch. Internally,
            it uses BboxImage whose clippath set to the path of the patch.

            FIXME : The result is currently dpi dependent.
            c                    s6   t  j|fi | t| jd d d| _| j| d S )N)Znormorigin)super__init__r   Zget_window_extent
bbox_imageset_data)selfpathr0   kwargs	__class__ b/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/matplotlib/tests/test_determinism.pyr/   H   s
   z4_save_figure.<locals>.PathClippedImagePatch.__init__c                    s   t  d dS )zSimply ignore facecolor.noneN)r.   set_facecolor)r2   colorr5   r7   r8   r:   N   s   z9_save_figure.<locals>.PathClippedImagePatch.set_facecolorNc                    s0   | j | j|   | j | t | d S N)r0   set_clip_path_pathZget_transformdrawr.   )r2   rendererr5   r7   r8   r?   R   s   z0_save_figure.<locals>.PathClippedImagePatch.drawr<   )__name__
__module____qualname____doc__r/   r:   r?   __classcell__r7   r7   r5   r8   PathClippedImagePatch@   s
    rF   Zpolar)Z
projection)r   r   gioT?)Zradiuszgrace_hopper.jpg)r   r   z!?   )sizek)ecz
upper leftTg?)locchildZframeonZ	borderpadg@)ZsharexZshareyblueredgffffff?r%   )ZlwZ	edgecolorZ	facecoloralphaZhatchzA string $1+2+\sigma$buffer)format)-mplZuseZrcParamsupdatepltZfigureZadd_subplotrangeZplotbarZ
set_xtickszipZ	set_hatchZimshowr	   r=   r   ZsubplotsZimreadr   r   r   r   Z
add_artistr   r
   Zunit_rectangledeepcopyZverticesZunit_circleZmake_compound_pathZunit_regular_starr   Z	transDataZadd_collectionZ	add_patchZset_xlimZset_ylim	set_titleZ
set_xlabelZ
set_ylabelgetattrsysstdoutZsavefig)objectsfmtusetexZfigZax1r   Zax2ZbarspatternsrX   patternArF   ZpxZpimgZarrZ	text_pathr,   Z	offsetboxZaoZexteriorZinterior	clip_pathstarZrow1Zrow2rowZ
collectionpatchaxr^   r7   r7   r8   _save_figure   s   
 










rj   zobjects, fmt, usetex) r   F)r   r   F)r    r   F)r)   r   F)r   r   F)r   psFrl   T)Zmarks)r,   svgF)r   rm   Frm   c                    sd    fddt dD }|dd D ]} dkr'r'||d kr&td q||d ks/J qdS )	aR  
    Output three times the same graphs and checks that the outputs are exactly
    the same.

    Parameters
    ----------
    objects : str
        Objects to be included in the test document: 'm' for markers, 'h' for
        hatch patterns, 'i' for images, and 'p' for paths.
    fmt : {"pdf", "ps", "svg"}
        Output format.
    c                    sN   g | ]#}t tjd ddd d dgi tjddddd	d	d
jqS )-R-czHfrom matplotlib.tests.test_determinism import _save_figure;_save_figure(z, )	946684800AggSOURCE_DATE_EPOCHZ
MPLBACKENDFT)envtextcapture_outputcheckr   r]   
executableosenvironr^   ).0_r`   r_   ra   r7   r8   
<listcomp>   s&    
z*test_determinism_check.<locals>.<listcomp>r   r   Nrl   r   z+failed, maybe due to ghostscript timestamps)rW   pytestskip)r_   r`   ra   Zplotsr,   r7   r   r8   test_determinism_check   s   

r   zfmt, string)r   s!   /CreationDate (D:20000101000000Z))rl   s(   %%CreationDate: Sat Jan 01 00:00:00 2000c                 C   sF   t tjddd| dgi tjddddd	dd
j}||v s!J dS )a  
    Test SOURCE_DATE_EPOCH support. Output a document with the environment
    variable SOURCE_DATE_EPOCH set to 2000-01-01 00:00 UTC and check that the
    document contains the timestamp that corresponds to this date (given as an
    argument).

    Parameters
    ----------
    fmt : {"pdf", "ps", "svg"}
        Output format.
    string : bytes
        Timestamp string for 2000-01-01 00:00 UTC.
    rn   ro   zMfrom matplotlib.tests.test_determinism import _save_figure; _save_figure('', rp   rq   rr   rs   TF)ru   rw   rv   rx   Nry   )r`   stringbufr7   r7   r8   "test_determinism_source_date_epoch   s   
r   )&rD   r{   r]   r   Z
matplotlibrT   r   rV   Zmatplotlib.cbookr   Zmatplotlib.collectionsr   Zmatplotlib.imager   Zmatplotlib.offsetboxr   r   Zmatplotlib.patchesr   r	   Zmatplotlib.pathr
   Zmatplotlib.testingr   Zmatplotlib.testing._markersr   r   Zmatplotlib.testing.compareZmatplotlib.textr   Zmatplotlib.transformsr   rj   markZparametrizeparamr   r   r7   r7   r7   r8   <module>   sT    
u

