a
    ض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rd	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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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   l/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/matplotlib/tests/test_pyplot.pytest_pyplot_up_to_date   s0    


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 | rnJ tt |d d W d    n1 s0    Y  tt |d d  W d    n1 s0    Y  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_func0   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_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 | s8J t   | rLJ t   | s`J 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   sp   t t tjdd W d    n1 s,0    Y  t t tjdd W d    n1 sb0    Y  d S )Nr,   )Znrows)Zncols)r   raises	TypeErrorr   subplotr   r   r   r   test_nrows_errorP   s    *r2   c                   C   s   t   t sJ t   t r*J W d    n1 s>0    Y  t sTJ t   t rhJ t   t r~J W d    n1 s0    Y  t rJ d S r#   )r   ionr   is_interactiveioffr   r   r   r   	test_ioffW   s    
*
*r6   c                   C   s   t   t rJ t   t s*J W d    n1 s>0    Y  t rTJ t   t shJ t   t s~J W d    n1 s0    Y  t sJ d S r#   )r   r5   r   r4   r3   r   r   r   r   test_ione   s    
*
*r7   c                	   C   sx  t   t  \ t rJ t   t s4J W d    n1 sH0    Y  t r^J W d    n1 sr0    Y  t sJ t  D t   t rJ W d    n1 s0    Y  W d    n1 s0    Y  t sJ t   t   W d    n1 s0    Y  t s0J t   t  d t sPJ t   t rhJ W d    n1 s~0    Y  t sJ W d    n1 s0    Y  t rJ t  H t   t sJ W d    n1 s0    Y  W d    n1 s0    Y  t r4J t   t   W d    n1 s\0    Y  t rtJ d S r#   )r   r3   r5   r   r4   r   r   r   r   test_nested_ion_ioffs   s8    

**

H
(

..

N
(r8   c               
   C   sH   zt d W n4 tyB }  zt| dks.J W Y d } ~ n
d } ~ 0 0 d S )Ng?zQclose() argument must be a Figure, an int, a string, or None, not <class 'float'>)r   closer0   r   )er   r   r   
test_close   s    r;   c                  C   s^   t d} | t  u sJ t d}|t  u s4J t d}| t  u sNJ | |u sZJ d S )Ny   z   )r   r1   gcaax1ax2ax3r   r   r   test_subplot_reuse   s    


rC   c                  C   s   t   t  } t  }| d us$J || us0J t   t   t jdd} t jdd}| d usdJ || uspJ t   t   t jdd} t  }| d usJ |jdksJ || usJ t   d S )Npolar
projectionrectilinear)r   figureaxesr9   namer*   r@   r   r   r   test_axes_kwargs   s&    rL   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sbJ ||u snJ ||uszJ ||usJ ||u sJ || jvsJ || jv sJ || jv sJ |jdksJ |jdksJ |jdksJ d S )Nr,   r   rD   rE   rG   )r   rH   r1   rI   rJ   )r)   r*   r@   rA   rB   Zax4r   r   r   test_subplot_replace_projection   s"    rM   c                  C   sX   t jddd} t jddd}| |u s(J t jddd}| |usBJ | t  jvsTJ d S )NrD   r   )rF   Ztheta_offsetr,   )r   r1   gcfrI   r?   r   r   r   test_subplot_kwarg_collision   s    rO   c                  C   s2  t   t  } t  }| d us$J || u s0J t   t   tjtdd t jdd} W d    n1 sp0    Y  t  }| d usJ || u sJ |jdksJ t   t   t  } tjtdd t jdd}W d    n1 s0    Y  | d usJ || u sJ |jdks&J t   d S )Nz5Calling gca\(\) with keyword arguments was deprecatedmatchrD   rE   rG   )r   rH   r>   r9   r   r'   r   rJ   rK   r   r   r   test_gca_kwargs   s8    **rR   c                  C   s   t d} | t  u sJ | t du s,J t jddd}|t  u sJJ | t  jvs\J |t du snJ t jddd}|t  u sJ ||usJ |t  jvsJ d S )No   rD   rE   rG   )r   r1   r>   rN   rI   r?   r   r   r   test_subplot_projection_reuse  s    
rT   c                  C   s   t jddd} t jddd}t jdddd}| |u s8J | |u sDJ tjtdd  t jddd	d}W d    n1 sx0    Y  d S )
NrS   rD   rE   T)rD   )rD   rF   zpolar=True, yet projection='3d'rP   3d)r   r1   r   r/   
ValueErrorr?   r   r   r    test_subplot_polar_normalization$  s    rW   c                  C   sT   t  } d}|D ]>}t j|d}|t  u s0J |j|ks>J | |usJJ |} qd S )N)ZaitoffZhammerZlambertZ	mollweiderD   rG   rU   rE   )r   r1   rJ   )r*   ZprojectionsZprojZax_nextr   r   r   test_subplot_change_projection0  s    rX   c                  C   sX   t ddd\} t| tjjs"J t ddd\}t|tjjsDJ | j|ju sTJ d S )Ng        g      ?rogQ?      ?Zbo)r   rD   
isinstancer   linesZLine2DrI   )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^   rZ   rZ   )position)皙?r`   皙?ra   )r   rI   npZtestingZassert_allcloseZbboxZ
get_points)ZaxrefZaxtestr   r   r   test_fallback_positionF  s    rc   )!r   Znumpyrb   r   r   pathlibr   r   Z
matplotlibr   r   r   Zmatplotlib.cbookr   r   r(   r+   r.   r2   r6   r7   r8   r;   rC   rL   rM   rO   rR   rT   rW   rX   r]   rc   r   r   r   r   <module>   s6   ,
	"
