B
    Mô`ê  ã               @   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   sD  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�r<| 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}x"t||ƒD ]\}	}
|	 |
¡ �q$W d| k�râ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� 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-0c1wfn4v/matplotlib/tests/test_determinism.pyÚ_save_figure   sD    

$



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                sh   ‡ ‡‡fdd„t dƒD ƒ}xH|dd… D ]8}ˆ dkrPˆrP||d kr`t d¡ q(||d ks(t‚q(W 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                sB   g | ]:}t jtjd ddˆ›dˆ ›dˆ› d�gtjddi–d�‘qS )z-Rz-czHfrom matplotlib.tests.test_determinism import _save_figure;_save_figure(z, ú)ÚSOURCE_DATE_EPOCHÚ	946684800)Úenv)Ú
subprocessÚcheck_outputr)   Ú
executableÚosÚenviron)Ú.0Ú_)r,   r+   r-   r1   r2   ú
<listcomp>c   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   )r,   r+   r-   r2   Útest_determinism_checkG   s    rG   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i–d�}||ks6t‚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.
    z-Rz-czMfrom matplotlib.tests.test_determinism import _save_figure; _save_figure('', r7   r8   r9   )r:   N)r;   r<   r)   r=   r>   r?   rE   )r,   ÚstringÚbufr1   r1   r2   Ú"test_determinism_source_date_epochr   s
    rJ   )r   r   F)Ú__doc__r>   r;   r)   rC   Z
matplotlibr    Zmatplotlib.testing.comparer   r"   ÚmarkZskipifZtestingÚcompareÚ	converterZneeds_ghostscriptZcheckdep_usetexZneeds_usetexr3   ZparametrizeÚparamrG   rJ   r1   r1   r1   r2   Ú<module>   s<   

/ 