U
    Âmœdê2  ã                   @   s0  d dl Z d dlZd dl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„ Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Z d+d,„ Z!d-d.„ Z"d/d0„ Z#d1d2„ Z$d3d4„ Z%d5d6„ Z&d7d8„ Z'd9d:„ Z(dS );é    N)ÚPath)Úpyplot)ÚMatplotlibDeprecationWarningc              
   C   s´   t tjƒjd d }| ¡ s&t d¡ t tjƒ ¡ }|  	d¡}| 
|d¡ tjtjt|ƒt|ƒgdd | d¡}||kr°d 	tj| d¡| d¡d	d
ddd¡}t d| ¡ d S )Né   ztools/boilerplate.pyzboilerplate.py not foundz	pyplot.pyzutf-8T)ÚcheckÚ
zfound pyplot.pyzexpected pyplot.pyr   Ú )ÚfromfileÚtofileÚnZlinetermzøpyplot.py is not up-to-date. Please run 'python tools/boilerplate.py' to update pyplot.py. This needs to be done from an environment where your current working copy is installed (e.g. 'pip install -e'd). Here is a diff of unexpected differences:
%s)r   ÚmplÚ__file__ÚparentsÚexistsÚpytestÚskipÚpltÚ	read_textÚjoinÚ
write_textÚ
subprocessÚrunÚsysÚ
executableÚstrÚdifflibZunified_diffÚsplitZfail)ZtmpdirZ
gen_scriptZorig_contentsZplt_fileZnew_contentsZdiff_msg© r   úU/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/matplotlib/tests/test_pyplot.pyÚtest_pyplot_up_to_date   s4    

ÿ
  üÿüÿr   c              	   C   s²   t j ddd¡t j dd¡ddd„ƒƒ}t |¡ddd„ƒ}|d ƒ |d d	 |d d d
 |d d d | rnt‚t t	¡ |d d W 5 Q R X t t	¡ |d d ƒ W 5 Q R X d S )Nz	(version)ÚoldÚnewÚkwoc                 S   s   d S ©Nr   ©r!   r"   r   r   r   Úfunc,   s    z1test_copy_docstring_and_deprecators.<locals>.funcc                 S   s   d S r#   r   r$   r   r   r   Úwrapper_func1   s    z9test_copy_docstring_and_deprecators.<locals>.wrapper_func)r!   )r"   r$   )r    )N)N)
r   Z_apiZrename_parameterZmake_keyword_onlyr   Z_copy_docstring_and_deprecatorsÚAssertionErrorr   Úwarnsr   )Zrecwarnr%   r&   r   r   r   Ú#test_copy_docstring_and_deprecators+   s    
r)   c                  C   sd   t  ¡ \} }t  d¡ | ¡ r"t‚t  d¡ | ¡ s8t‚t  ¡  | ¡ rLt‚t  ¡  | ¡ s`t‚d S )NFT)r   ÚsubplotsÚboxZget_frame_onr'   )ÚfigÚaxr   r   r   Útest_pyplot_box@   s    

r.   c                   C   s   t  dddgdddg¡ d S )Né   r   é   )r   Z	stackplotr   r   r   r   Útest_stackplot_smokeL   s    r1   c                	   C   sH   t  t¡ tjdd W 5 Q R X t  t¡ tjdd W 5 Q R X d S )Nr/   )Znrows)Zncols)r   ÚraisesÚ	TypeErrorr   Úsubplotr   r   r   r   Útest_nrows_errorQ   s    r5   c                	   C   s„   t  ¡  t ¡ st‚t  ¡  t ¡ r*t‚W 5 Q R X t ¡ s@t‚t  ¡  t ¡ rTt‚t  ¡  t ¡ rjt‚W 5 Q R X t ¡ r€t‚d S r#   )r   Úionr   Úis_interactiver'   Úioffr   r   r   r   Ú	test_ioffX   s    

r9   c                	   C   s„   t  ¡  t ¡ rt‚t  ¡  t ¡ s*t‚W 5 Q R X t ¡ r@t‚t  ¡  t ¡ sTt‚t  ¡  t ¡ sjt‚W 5 Q R X t ¡ s€t‚d S r#   )r   r8   r   r7   r'   r6   r   r   r   r   Útest_ionf   s    

r:   c                
   C   sž  t  ¡  t  ¡ > t ¡ rt‚t  ¡  t ¡ s4t‚W 5 Q R X t ¡ rJt‚W 5 Q R X t ¡ s`t‚t  ¡ & t  ¡  t ¡ r€t‚W 5 Q R X W 5 Q R X t ¡ s t‚t  ¡  t  ¡  W 5 Q R X t ¡ sÈt‚t  ¡  t  ¡ @ t ¡ sæt‚t  ¡  t ¡ rüt‚W 5 Q R X t ¡ st‚W 5 Q R X t ¡ r,t‚t  ¡ ( t  ¡  t ¡ sNt‚W 5 Q R X W 5 Q R X t ¡ rpt‚t  ¡  t  ¡  W 5 Q R X t ¡ ršt‚d S r#   )r   r6   r8   r   r7   r'   r   r   r   r   Útest_nested_ion_iofft   s8    



 




"
r;   c               
   C   sF   zt  d¡ W n2 tk
r@ }  zt| ƒdks0t‚W 5 d } ~ X Y nX d S )Ngš™™™™™ñ?zQclose() argument must be a Figure, an int, a string, or None, not <class 'float'>)r   Úcloser3   r   r'   )Úer   r   r   Ú
test_close    s    r>   c                  C   s^   t  d¡} | t  ¡ kst‚t  d¡}|t  ¡ ks4t‚t  d¡}| t  ¡ ksNt‚| |ksZt‚d S )Néy   éz   )r   r4   Úgcar'   ©Úax1Úax2Úax3r   r   r   Útest_subplot_reuse¨   s    


rF   c                  C   sÆ   t  ¡  t  ¡ } t  ¡ }| d k	s$t‚|| k	s0t‚t  ¡  t  ¡  t jdd} t jdd}| d k	sdt‚|| k	spt‚t  ¡  t  ¡  t jdd} t  ¡ }| d k	s t‚|jdks®t‚|| k	sºt‚t  ¡  d S )NÚpolar©Ú
projectionÚrectilinear)r   ÚfigureÚaxesr'   r<   Úname©r-   rC   r   r   r   Útest_axes_kwargs²   s&    rO   c               	   C   s   t  ¡ } t  ddd¡}t  ddd¡}t  ddd¡}t t¡ t jddddd}W 5 Q R X t jddddd}|d k	sxt‚||ks„t‚||k	st‚||k	sœt‚||ks¨t‚|| jks¶t‚|| jksÄt‚|| jksÒt‚|jdksàt‚|jdksît‚|jdksüt‚d S )Nr/   r   rG   rH   rJ   )	r   rK   r4   r   r(   r   r'   rL   rM   )r,   r-   rC   rD   rE   Zax4r   r   r   Útest_subplot_replace_projectionË   s$    rP   c                  C   s`   t jddd} t jddd}| |ks(t‚|  ¡  t jddd}| |k	sJt‚| t  ¡ jks\t‚d S )NrG   r   )rI   Ztheta_offsetr/   )r   r4   r'   ÚremoveÚgcfrL   rB   r   r   r   Útest_subplot_kwarg_collisionä   s    rS   c                  C   s<   t  ¡  t  ¡ } t  ¡ }| d k	s$t‚|| ks0t‚t  ¡  d S r#   )r   rK   rA   r'   r<   rN   r   r   r   Útest_gcaî   s    rT   c                  C   s¾   t  d¡} | t  ¡ kst‚| t  d¡ks,t‚|  ¡  t jddd}|t  ¡ ksRt‚| t  ¡ jksdt‚|t  d¡ksvt‚| ¡  t jddd}|t  ¡ ksœt‚||k	s¨t‚|t  ¡ jksºt‚d S )Néo   rG   rH   rJ   )r   r4   rA   r'   rQ   rR   rL   rB   r   r   r   Útest_subplot_projection_reuseø   s    
rV   c               	   C   sr   t jddd} t jddd}t jdddd}| |ks8t‚| |ksDt‚tjtdd t jddd	d}W 5 Q R X d S )
NrU   rG   rH   T)rG   )rG   rI   zpolar=True, yet projection='3d')ÚmatchÚ3d)r   r4   r'   r   r2   Ú
ValueErrorrB   r   r   r   Ú test_subplot_polar_normalization  s    ÿrZ   c                  C   s~   t ƒ } t ¡ }|  |¡ d}|D ]@}| ¡  tj|d}|t ¡ ksHt‚|j|ksVt‚|  |¡ q t| ƒdt|ƒ kszt‚d S )N)ZaitoffÚhammerZlambertZ	mollweiderG   rJ   rX   rH   r/   )Úsetr   r4   ÚaddrQ   r'   rM   Úlen)Zcreated_axesr-   ZprojectionsZprojr   r   r   Útest_subplot_change_projection  s    
r_   c                  C   sX   t  ddd¡\} t| tjjƒs"t‚t  ddd¡\}t|tjjƒsDt‚| j|jksTt‚d S )Ng        g      ð?Úrog…ëQ¸ù?ç      à?Zbo)r   rG   Ú
isinstancer   ÚlinesZLine2Dr'   rL   )Zln1Zln2r   r   r   Útest_polar_second_call-  s
    rd   c                  C   sŽ   t  ddddg¡} t jddddgd}tj |j ¡ | j ¡ ¡ t  ddddg¡} t jddddgddddgd}tj |j ¡ | j ¡ ¡ d S )Ngš™™™™™É?ra   )Úpositiongš™™™™™¹?gš™™™™™é?)r   rL   ÚnpÚtestingZassert_allcloseZbboxZ
get_points)ZaxrefZaxtestr   r   r   Útest_fallback_position7  s    ÿÿrh   c                  C   sX   t  ¡ } |  d¡}t  ¡  t  ¡ | ks*t‚t  |d ¡}t  ¡ | ksHt‚|| ksTt‚d S )Nr   r/   )r   rK   Ú
subfiguresrR   r'   )Zfig1ÚsubfigsÚcurrentr   r   r   Ú%test_set_current_figure_via_subfigureE  s    
rl   c                  C   sd   t  ¡ } |  d¡}|d jddd}|d jddd t  ¡ |ksFt‚t  |¡ t  ¡ |ks`t‚d S )Nr   r   r/   T)Zsqueeze)r   rK   ri   r*   rA   r'   Zsca)r,   rj   r-   r   r   r   Ú"test_set_current_axes_on_subfigureQ  s    

rm   c                  C   s,   t  d¡} tjj| jddd d¡dd d S )NÚIPythonz--pylabz-cú;)zimport matplotlib.pyplot as pltz<assert plt._REPL_DISPLAYHOOK == plt._ReplDisplayHook.IPYTHONé<   )Útimeout)r   Zimportorskipr   rg   Zsubprocess_run_helperZstart_ipythonr   )rn   r   r   r   Útest_pylab_integration]  s    
ørr   c                  C   sŠ   t tƒjd } |  ¡ s t d¡ dd„ }|  ¡  d¡}t||ƒƒ}tt	 
¡ ƒ}| |¡}|rjtd|›ƒ‚| |¡}|r†td|›ƒ‚dS )	z6Test that pyplot_summary lists all the plot functions.z#../../../doc/api/pyplot_summary.rstz#Documentation sources not availablec                 S   sZ   g }d}| D ]H}|s$|  d¡rTd}q|r|  d¡r4q|d  ¡ sFd}q| | ¡ ¡ q|S )ae  
        Return a list of all the functions that are mentioned in the
        autosummary blocks contained in *lines*.

        An autosummary block looks like this::

            .. autosummary::
               :toctree: _as_gen
               :template: autosummary.rst
               :nosignatures:

               plot
               plot_date

        Fz.. autosummary::Tz   :r   )Ú
startswithÚisspaceÚappendÚstrip)rc   Z	functionsZin_autosummaryÚliner   r   r   Úextract_documented_functionsq  s    
z=test_doc_pyplot_summary.<locals>.extract_documented_functionsr   zsThe following pyplot functions are not listed in the documentation. Please add them to doc/api/pyplot_summary.rst: z•The following functions are listed in the pyplot documentation, but they do not exist in pyplot. Please remove them from doc/api/pyplot_summary.rst: N)r   r   Úparentr   r   r   r   r   r\   r   Z_get_pyplot_commandsÚ
differencer'   )Zpyplot_docsrx   rc   Zdoc_functionsZplot_commandsÚmissingÚextrar   r   r   Útest_doc_pyplot_summaryk  s"    
!
ÿ
ÿr}   c                  C   sÆ   t  ¡  t  t dd¡¡ t jdd\} }t |tjg tjdk¡sHt	‚|g ksTt	‚t j
ddgdd	gdd
 t  ¡ }|jdd} |jdd}t | t ddg¡k¡s¨t	‚dd„ |D ƒdd	gksÂt	‚d S )Nr/   é
   T)Úminor)Zdtypeg      @g      @ÚaÚb)ZticksÚlabelsr   c                 S   s   g | ]}|  ¡ ‘qS r   )Zget_text)Ú.0Úlr   r   r   Ú
<listcomp>¯  s     z$test_minor_ticks.<locals>.<listcomp>)r   rK   Zplotrf   ZarangeZxticksÚallÚarrayZfloat64r'   ZyticksrA   Z
get_yticksZget_yticklabels)Ztick_posZtick_labelsr-   r   r   r   Útest_minor_ticks£  s    rˆ   c                  C   sn   t  d¡ t  ¡ } t  ¡ } tt  ¡ ƒdks.t‚t  d¡ tt  ¡ ƒdksLt‚t  d¡ tt  ¡ ƒdksjt‚d S )NZaggr   Úsvgr   )r   Zswitch_backendrK   r^   Zget_fignumsr'   )r,   r   r   r   Útest_switch_backend_no_close²  s    


rŠ   c                 C   s
   d| _ d S )NT)Ú_test_was_here)rK   r   r   r   Úfigure_hook_example½  s    rŒ   c               	   C   s6   ddgi} t  | ¡ t ¡ }W 5 Q R X |js2t‚d S )Nzfigure.hooksz0matplotlib.tests.test_pyplot:figure_hook_example)r   Z
rc_contextr   rK   r‹   r'   )Ztest_rcr,   r   r   r   Útest_figure_hookÁ  s     ÿr   ))r   Únumpyrf   r   r   Úpathlibr   r   Z
matplotlibr   r   r   Zmatplotlib._apir   r   r)   r.   r1   r5   r9   r:   r;   r>   rF   rO   rP   rS   rT   rV   rZ   r_   rd   rh   rl   rm   rr   r}   rˆ   rŠ   rŒ   r   r   r   r   r   Ú<module>   sF   ,



8