a
    ëÝEb2  ã                   @   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v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| v 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| v �r4| 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 ]\}	}
|	 |
¡ �qd| v �rÈ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� g d¢g d¢g d¢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)Úbottom)g      ø?g      @g      @g      @)ú-ú+r   ú\Ú*ÚoÚOÚ.Úi)r   r   r   )r   r   r   )r   r   r   Znearest)Úinterpolation)r   r   r   Zbilinear)r   r   r   Z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ÚAÚaxr+   © r3   úa/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/matplotlib/tests/test_determinism.pyÚ_save_figure   sF    

 ÿ



r5   zobjects, fmt, usetex)Ú r   F)r   r   F)r   r   F)r   r   F)r   r   F)r   ÚpsFr7   )Zmarks)r   ÚsvgFr8   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&J ‚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                    sH   g | ]@}t jtjd ddˆ›dˆ ›dˆ› d�gi 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.   r3   r4   Ú
<listcomp>b   s   úÿÿÿÿ
ÿüz*test_determinism_check.<locals>.<listcomp>r   r   Nr7   r   z+failed, maybe due to ghostscript timestamps)r%   ÚpytestÚskip)r,   r-   r.   ZplotsÚpr3   rJ   r4   Útest_determinism_checkG   s    ù	rO   zfmt, string)r   s!   /CreationDate (D:20000101000000Z))r7   s(   %%CreationDate: Sat Jan 01 00:00:00 2000c                 C   s@   t jtjddd| ›d�gi tj¥dddœ¥d�}||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.
    r9   r:   zMfrom matplotlib.tests.test_determinism import _save_figure; _save_figure('', r;   r<   r=   r>   r@   NrB   )r-   ÚstringÚbufr3   r3   r4   Ú"test_determinism_source_date_epochs   s    ÿÿ
ÿürR   )r   r   F)Ú__doc__rF   rC   r*   rL   Z
matplotlibr!   Zmatplotlib.testing.comparer   r#   ÚmarkZskipifÚtestingÚcompareÚ	converterZneeds_ghostscriptZcheckdep_usetexZneeds_usetexr5   ZparametrizeÚparamrO   rR   r3   r3   r3   r4   Ú<module>   sN   þ
þ
/ÿöÿ
úÿ
