o
    :a%                     @   s   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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rZd	tj|d|dd	d
ddd}td|  d S d S )N   ztools/boilerplate.pyzboilerplate.py not foundz	pyplot.pyzutf-8T)check
zfound pyplot.pyzexpected pyplot.pyr    )ZfromfileZtofilenZlinetermzpyplot.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pltZ	read_textjoinZ
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   >/usr/lib/python3/dist-packages/matplotlib/tests/test_pyplot.pytest_pyplot_up_to_date   s2   


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 | r7J tt |d d W d    n1 sLw   Y  tt |d d  W d    d S 1 sgw   Y  d S )Nz	(version)oldnewkwoc                 S      d S Nr   r   r   r   r   r   func+   s   z1test_copy_docstring_and_deprecators.<locals>.funcc                 S   r   r    r   r!   r   r   r   wrapper_func0   s   z9test_copy_docstring_and_deprecators.<locals>.wrapper_func)r   )r   r!   )r   r    )	r
   Z_apiZrename_parameterZmake_keyword_onlyr   Z_copy_docstring_and_deprecatorsr   warnsr   )Zrecwarnr"   r#   r   r   r   #test_copy_docstring_and_deprecators*   s    
"r%   c                  C   sd   t  \} }t d | rJ t d | sJ t   | r&J t   | s0J d S )NFT)r   ZsubplotsZboxZget_frame_on)figaxr   r   r   test_pyplot_box?   s   

r(   c                   C   s   t g dg d d S )N)   r      )r   Z	stackplotr   r   r   r   test_stackplot_smokeK   s   r+   c                   C   sr   t t tjdd W d    n1 sw   Y  t t tjdd W d    d S 1 s2w   Y  d S )Nr)   )Znrows)Zncols)r   raises	TypeErrorr   subplotr   r   r   r   test_nrows_errorP   s   "r/   c                   C   s   t   t s
J t   t rJ W d    n1 sw   Y  t s*J t   t r4J t   t r?J W d    n1 sIw   Y  t rTJ d S r    )r   ionr
   is_interactiveioffr   r   r   r   	test_ioffW      

r3   c                   C   s   t   t r
J t   t sJ W d    n1 sw   Y  t r*J t   t s4J t   t s?J W d    n1 sIw   Y  t sTJ d S r    )r   r2   r
   r1   r0   r   r   r   r   test_ione   r4   r5   c                	   C   sd  t   t  . t rJ t   t sJ W d    n1 s$w   Y  t r/J W d    n1 s9w   Y  t sDJ t  " t   t rTJ W d    n1 s^w   Y  W d    n1 smw   Y  t sxJ t   t   W d    n1 sw   Y  t sJ t   t  . t sJ t   t rJ W d    n1 sw   Y  t sJ W d    n1 sw   Y  t rJ t  " t   t sJ W d    n1 sw   Y  W d    n	1 sw   Y  t rJ t   t   W d    n	1 s$w   Y  t r0J d S r    )r   r0   r2   r
   r1   r   r   r   r   test_nested_ion_ioffs   sP   











r6   c               
   C   sH   zt d W d S  ty# }  zt| dksJ W Y d } ~ d S d } ~ ww )Ng?zQclose() argument must be a Figure, an int, a string, or None, not <class 'float'>)r   closer-   r   )er   r   r   
test_close   s   r9   c                  C   s^   t d} | t  u sJ t d}|t  u sJ t d}| t  u s'J | |u s-J d S )Ny   z   )r   r.   gcaax1ax2ax3r   r   r   test_subplot_reuse   s   


rA   c                  C   s   t   t  } t  }| d usJ || usJ t   t   t jdd} t jdd}| d us2J || us8J t   t   t jdd} t  }| d usPJ |jdksWJ || us]J t   d S )Npolar
projectionrectilinear)r   figureaxesr7   namer'   r>   r   r   r   test_axes_kwargs   s&   rJ   c                  C   s   t  } t ddd}t ddd}t ddd}t jddddd}t jddddd}|d us1J ||u s7J ||us=J ||usCJ ||u sIJ || jvsPJ || jv sWJ || jv s^J |jdkseJ |jdkslJ |jdkssJ d S )Nr)   r   rB   rC   rE   )r   rF   r.   rG   rH   )r&   r'   r>   r?   r@   Zax4r   r   r   test_subplot_replace_projection   s"   rK   c                  C   sX   t jddd} t jddd}| |u sJ t jddd}| |us!J | t  jvs*J d S )NrB   r   )rD   Ztheta_offsetr)   )r   r.   gcfrG   r=   r   r   r   test_subplot_kwarg_collision   s   rM   c                  C   s,  t   t  } t  }| d usJ || u sJ t   t   tjtdd t jdd} W d    n1 s8w   Y  t  }| d usGJ || u sMJ |jdksTJ t   t   t  } tjtdd t jdd}W d    n1 sxw   Y  | d usJ || u sJ |jdksJ t   d S )Nz5Calling gca\(\) with keyword arguments was deprecatedmatchrB   rC   rE   )r   rF   r<   r7   r   r$   r   rH   rI   r   r   r   test_gca_kwargs   s<   rP   c                  C   s   t d} | t  u sJ | t du sJ t jddd}|t  u s%J | t  jvs.J |t du s7J t jddd}|t  u sFJ ||usLJ |t  jvsUJ d S )No   rB   rC   rE   )r   r.   r<   rL   rG   r=   r   r   r   test_subplot_projection_reuse  s   
rR   c                  C   s   t jddd} t jddd}t jdddd}| |u sJ | |u s"J tjtdd t jddd	d}W d    d S 1 s=w   Y  d S )
NrQ   rB   rC   T)rB   )rB   rD   zpolar=True, yet projection='3d'rN   3d)r   r.   r   r,   
ValueErrorr=   r   r   r    test_subplot_polar_normalization$  s   "rU   c                  C   sT   t  } d}|D ]}t j|d}|t  u sJ |j|ksJ | |us%J |} qd S )N)ZaitoffZhammerZlambertZ	mollweiderB   rE   rS   rC   )r   r.   rH   )r'   ZprojectionsZprojZax_nextr   r   r   test_subplot_change_projection0  s   rV   c                  C   sX   t ddd\} t| tjjsJ t ddd\}t|tjjs"J | j|ju s*J d S )Ng        g      ?rogQ?      ?Zbo)r   rB   
isinstancer
   linesZLine2DrG   )Zln1Zln2r   r   r   test_polar_second_call<  s
   r[   c                  C   sz   t g d} t jg dd}tj|j | j  t g d} t jg dg dd}tj|j | j  d S )N)皙?r\   rX   rX   )Zposition)皙?r]   皙?r^   )r   rG   npZtestingZassert_allcloseZbboxZ
get_points)ZaxrefZaxtestr   r   r   test_fallback_positionF  s   r`   )!r   Znumpyr_   r   r   Zpathlibr   r   Z
matplotlibr
   r   r   Zmatplotlib.cbookr   r   r%   r(   r+   r/   r3   r5   r6   r9   rA   rJ   rK   rM   rP   rR   rU   rV   r[   r`   r   r   r   r   <module>   s8    ,
	"
