U
    \	a2                     @   s   d Z ddlZddlZddlZddlZddlZddl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d ddZej
dddddddejd	ddeeg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)pyplotZepsz*This test needs a ghostscript installation)reasonTz"This test needs a TeX installationmhipdfFc                 C   s@  t | t jd|d t }d| kr|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| kr8|ddd	}|	tddtdd|j	tdddgd tddd }|
ddddg d}t||D ]\}	}
|	|
 q"d| krdd	dgd	ddgddd	gg}|dddj|dd ddd	gdd	dgddd	gg}|dddj|dd d	ddgdd	dgd	ddgg}|dddj|dd 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)Zbottomg      ?g      @g      @g      @)-+r   \*oO.iZnearest)interpolationZbilinearZbicubiczA string $1+2+\sigma$buffer)format)mplZuseZrcParamsupdatepltfigureZadd_subplotrangeZplotbarZ
set_xtickszipZ	set_hatchZimshow	set_titleZ
set_xlabelZ
set_ylabelgetattrsysstdoutZsavefig)objectsfmtusetexZfigZax1r   Zax2Zbarspatternsr%   patternAZaxr*    r1   E/tmp/pip-unpacked-wheel-wjyw_3jo/matplotlib/tests/test_determinism.py_save_figure   sF    

 



r3   zobjects, fmt, usetex) r   F)r   r   F)r   r   F)r   r   F)r   r   F)r   psFr5   )Zmarks)r   svgFr6   c                    sd    fddt dD }|dd D ]8} dkrNrN||d kr^td q&||d ks&tq&dS )	a?  
    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.
    fmt : {"pdf", "ps", "svg"}
        Output format.
    c                    sD   g | ]<}t jtjd ddd d dgtjddddqS )	-R-czHfrom matplotlib.tests.test_determinism import _save_figure;_save_figure(z, )	946684800AggSOURCE_DATE_EPOCHZ
MPLBACKENDenv)
subprocesscheck_outputr)   
executableosenviron).0_r,   r+   r-   r1   r2   
<listcomp>b   s   z*test_determinism_check.<locals>.<listcomp>r   r   Nr5   r   z+failed, maybe due to ghostscript timestamps)r$   pytestskipAssertionError)r+   r,   r-   Zplotspr1   rG   r2   test_determinism_checkG   s    	rM   zfmt, string)r   s!   /CreationDate (D:20000101000000Z))r5   s(   %%CreationDate: Sat Jan 01 00:00:00 2000c                 C   s<   t jtjddd| dgtjdddd}||ks8t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.
    r7   r8   zMfrom matplotlib.tests.test_determinism import _save_figure; _save_figure('', r9   r:   r;   r<   r>   N)r@   rA   r)   rB   rC   rD   rK   )r,   stringbufr1   r1   r2   "test_determinism_source_date_epochs   s    
rP   )r   r   F)__doc__rC   r@   r)   rI   Z
matplotlibr    Zmatplotlib.testing.comparer   r"   markZskipifZtestingcompare	converterZneeds_ghostscriptZcheckdep_usetexZneeds_usetexr3   ZparametrizeparamrM   rP   r1   r1   r1   r2   <module>   sT   

/   

