U
    \	¸a²6  ã                   @   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	m
Z
 d dlmZmZ d dlmZ d dlZdd„ Zdd	„ Zej d
e d¡e d¡e d¡fdfe d¡e d¡e d¡fdfe d¡e d¡e d¡fdfe d¡e d¡e d¡fdfe d¡e d¡e d¡fdfe d¡e d¡e d¡fdfe d¡e d¡e d¡fdfe d¡e d¡e d¡fdfd ggfdfd gd gd ggfdfg
¡dd„ ƒZdd„ Zdd„ Zd d!„ Zd"d#„ Ze
d$gd%d&d'd(d)„ ƒZe
d*gd%d+d,d-„ ƒZe
d.gd/d&d'd0d1„ ƒZe
d2gd%d&e ¡ d3krd nd4d5d6d7„ ƒZ e
d8d9gd%d+d:d;„ ƒZ!d<d=„ Z"d>d?„ Z#ej d@dAe$dBfdCe%dDfd ggd ggg gdd%d fe%dEfd ggd ggd ggdd%d fe%dFfe dG¡ &dH¡gdI d ggd%d f˜e%dJfg¡dKdL„ ƒZ'dMdN„ Z(dOdP„ Z)ej dQdRdSdTdUg¡dVdW„ ƒZ*e
dXgd%d&d'dYdZ„ ƒZ+e
d[gd%d&d\d5d]d^„ ƒZ,e
d_gd`gd%d&dadbdc„ ƒZ-ej dddedfdgg¡dhdi„ ƒZ.ej /dj¡dkdl„ ƒZ0dS )mé    N)Úassert_array_almost_equal)Úimage_comparison)ÚpyplotÚ
rc_context)ÚLogNormc                  C   s>   t  d¡} t  d¡}t j d¡}t ¡ \}}| | ||¡ d S ©Né
   é	   ©r	   r   )ÚnpÚarangeÚrandomÚpltÚsubplotsÚcontour)ÚxÚyÚzÚfigÚax© r   úA/tmp/pip-unpacked-wheel-wjyw_3jo/matplotlib/tests/test_contour.pyÚtest_contour_shape_1d_valid   s
    

r   c                  C   sN   t  d¡} t  d¡}t  | |¡\}}t j d¡}t ¡ \}}| |||¡ d S r   )r   r   Úmeshgridr   r   r   r   )r   r   ZxgZygr   r   r   r   r   r   Útest_contour_shape_2d_valid   s    

r   zargs, messager	   r
   z6Length of x (9) must match number of columns in z (10)r   z3Length of y (10) must match number of rows in z (9))r   r   z4Number of dimensions of x (2) and y (1) do not matchz4Number of dimensions of x (1) and y (2) do not match©r	   r	   z-Shapes of x (9, 9) and z (9, 10) do not matchz-Shapes of y (9, 9) and z (9, 10) do not match)é   r   r   z'Inputs x and y must be 1D or 2D, not 3DzInput z must be 2D, not 3DzDInput z must be at least a (2, 2) shaped array, but has shape (1, 1)c              	   C   s:   t  ¡ \}}tjtt |¡d |j| Ž  W 5 Q R X d S )N©Úmatch)r   r   ÚpytestÚraisesÚ	TypeErrorÚreÚescaper   )ÚargsÚmessager   r   r   r   r   Útest_contour_shape_error#   s    r&   c               	   C   s^   t  d¡} t j d¡}t ¡ \}}t t¡}|j| | |g d W 5 Q R X t	|ƒdksZt
‚d S )Nr	   r   ©Úlevelsé   )r   r   r   r   r   r   ÚwarnsÚUserWarningr   ÚlenÚAssertionError©r   r   r   r   Úrecordr   r   r   Útest_contour_empty_levels?   s    
r0   c                  C   s`   t  d¡ d¡} t ¡ \}}| | d¡}t|jƒdks:t‚|j| dd}|j|jk 	¡ s\t‚d S )Né   ©r   é   é   r)   r'   )
r   r   Úreshaper   r   r   r,   r(   r-   Úall)r   r   r   Zcs1Zcs2r   r   r   Útest_contour_NlevelsJ   s    r7   c               	   C   st   t  d¡} t  d¡}t ¡ \}}ddi}t t¡(}|j| | |dgd}|j	||d W 5 Q R X t
|ƒdkspt‚d S )Nr	   r   ç      ð?z%1.2fr'   )Úfmtr)   )r   r   Úzerosr   r   r   r*   r+   r   Úclabelr,   r-   )r   r   r   r   r9   r/   Úcsr   r   r   Útest_contour_badlevel_fmtU   s    

r=   c               	   C   sX   t  d¡} t  d¡}t ¡ \}}t t¡}| | | |¡ W 5 Q R X t	|ƒdksTt
‚d S )Nr	   r   r)   )r   r   Zonesr   r   r   r*   r+   r   r,   r-   r.   r   r   r   Útest_contour_uniform_ze   s    

r>   Zcontour_manual_labelsTZmpl20)Úremove_textÚstylec                  C   sž   t  t  dd¡t  dd¡¡\} }t  t  t| ƒt|ƒg¡d¡}tjddd t | ||¡}t  	ddd	g¡}tj
||d
 t  	dddg¡}tj
||ddd d S )Nr   r   é   )é   rA   éÈ   )ÚfigsizeZdpi)r8   ç      @)r8   çš™™™™™@)r8   ç      @)Úmanual)ç       @rE   )rI   rF   )rI   rG   Úsmall)ÚrÚg)rH   ZfontsizeÚcolors)r   r   r   ÚmaxÚdstackÚabsr   Úfigurer   Úarrayr;   )r   r   r   r<   Zptsr   r   r   Útest_contour_manual_labelsp   s     rS   z$contour_manual_colors_and_levels.png)r?   c                  C   sæ   dt jd< t  dd¡\} }t d¡ dd¡}ddd	d
dg}ddddg}t|jƒD ]\}}|d dk}ddddg|d  }|r¸|dkrˆdnd }	|dkr˜dnd }
|j|||	|
… ||d}n|j	||d d… ||d}t j
||d qPd S )NFúpcolormesh.snaprA   r3   r1   r   ZredZyellowZpinkZblueZblacké   r   ç        ÚneitherÚminrN   Úboth)rN   rW   r)   )rX   rW   éÿÿÿÿ)rM   r(   Úextend©r   )r   ÚrcParamsr   r   r   r5   Ú	enumerateZflatÚcontourfr   Úcolorbar)Ú_ÚaxsÚdatarM   r(   Úir   Zfilledr[   Zfirst_colorZ
last_colorÚcr   r   r   Ú$test_given_colors_levels_and_extends}   s(    
 ÿ ÿrf   zcontour_datetime_axis.pngFc                     s<  t  ¡ } | jdddd t ddd¡‰ t ‡ fdd„td	ƒD ƒ¡}t d	¡}t t d	¡t d	¡¡\}}|| }t  	d
¡ t  
|||¡ t  	d¡ t  |||¡ tj|tj d	dd}tj|d d …tjf d	dd}t  	d¡ t  
|||¡ t  	d¡ t  |||¡ |  ¡ D ]*}| ¡ D ]}| d¡ | d¡ qqd S )Ngš™™™™™Ù?g\Âõ(\ï?g333333Ã?)ZhspaceÚtopZbottomiÝ  r)   c                    s   g | ]}ˆ t j|d  ‘qS ))Údays)ÚdatetimeÚ	timedelta)Ú.0Úd©Úbaser   r   Ú
<listcomp>¢   s     z.test_contour_datetime_axis.<locals>.<listcomp>é   éÝ   éÞ   r   )Zaxiséß   éà   Úrighté   )r   rQ   Úsubplots_adjustri   r   rR   Úranger   r   Zsubplotr   r_   ÚrepeatZnewaxisZget_axesZget_xticklabelsZset_haZset_rotation)r   r   r   Zz1Zz2r   r   Úlabelr   rm   r   Útest_contour_datetime_axisœ   s*    





r{   z!contour_test_label_transforms.pngÚx86_64g{®Gáz´?)r?   r@   Ztolc                  C   s  d} t  dd| ¡}t  dd| ¡}t  ||¡\}}t  |d |d   d ¡dt j  }t  |d d d |d d	 d   d ¡dt j d	 d  }d
||  }t dd¡\}}	|	 |||¡}
dddg}dddg}|
 ¡  |D ]\}}|
j	||dd d qÞ|D ]\}}|
j	||ddd qþd S )Ngš™™™™™™?g      ÀrE   g       ÀrI   rA   r)   g      ø?ç      à?ç      $@)éØ   é±   )ig  i"  )i	  i–  )éþÿÿÿr}   )r   g      ø¿)gffffff@r)   T)ÚinlineZ	transformF)
r   r   r   ÚexpÚpir   r   r   r;   Zadd_label_near)Údeltar   r   ÚXÚYZZ1ZZ2ÚZr   r   ÚCSZ
disp_unitsZ
data_unitsr   r   r   Útest_labels¶   s$    &*ÿ

rŠ   zcontour_corner_mask_False.pngzcontour_corner_mask_True.pngc                  C   s²   d} d}d}t j dg¡ t  t  dd| ¡t  dd| ¡¡\}}t  d| ¡t  d| ¡ |t j | | ¡  }t j | | ¡|k}t jj	||d	}d
D ]}t
 ¡  t
j||d q’d S )Né<   çffffffî?r8   r)   r   rI   é   rU   )Úmask)FT)Úcorner_mask)r   r   Úseedr   ÚlinspaceÚcosÚsinÚrandÚmarR   r   rQ   r_   )ÚnZ
mask_levelZ	noise_ampr   r   r   rŽ   r   r   r   r   Útest_corner_maskÕ   s    $.r—   c               	   C   sB   ddgddgg} t  ¡  t t¡ t  | ddg¡ W 5 Q R X d S )Ngš™™™™™¹?g333333Ó?r}   gffffffæ?r8   rV   )r   rQ   r   r    Ú
ValueErrorr_   )r   r   r   r   Útest_contourf_decreasing_levelsç   s    r™   c                  C   sF   t  d¡ d¡} tjddd}tj| |d}t|jt  ddd¡ƒ d S )	Nr1   r2   r3   T)ZnbinsZ	symmetric)Úlocatoriôÿÿÿr4   )	r   r   r5   r   ZMaxNLocatorr_   r   r(   r‘   )r   rš   r<   r   r   r   Útest_contourf_symmetric_locatorï   s    r›   zargs, cls, messager   z,function takes exactly 6 arguments (0 given))r)   rA   r   r3   r4   rB   z#Expected 2-dimensional array, got 0z9x, y and z must all be 2D arrays with the same dimensionsz*x, y and z must all be at least 2x2 arraysr3   )rA   rA   r   zCIf mask is set it must be a 2D array with the same dimensions as x.c              	   C   s<   ddl m} tj|t |¡d tjj| Ž  W 5 Q R X d S )Nr   ©Ú_contourr   )Ú
matplotlibr   r   r    r"   r#   ÚmplÚQuadContourGenerator)r$   Úclsr%   r   r   r   r   Útest_internal_cpp_api÷   s    r¢   c               	   C   s\   ddl m}  ddgddgg}tj |||d dd¡}tjtdd | dd¡ W 5 Q R X d S )	Nr   rœ   r)   rA   r   Tz(filled contour levels must be increasingr   )rž   r   rŸ   r    r   r    r˜   Zcreate_filled_contour)r   ZarrZqcgr   r   r   Útest_internal_cpp_api_2	  s     ÿr£   c                  C   sT   t  t  ddd¡t  ddd¡¡\} }t  | |¡}t ¡  t | ||¡}t |¡ d S )Nr   rA   r3   )r   r   r‘   Úhypotr   rQ   r   r;   )r   r   rK   r<   r   r   r   Útest_circular_contour_warning  s
    $r¥   z-use_clabeltext, contour_zorder, clabel_zorder)Té{   éÒ  )Fr¦   r§   )Tr¦   N)Fr¦   Nc                 C   sà   t  t  dd¡t  dd¡¡\}}t  t  t|ƒt|ƒg¡d¡}tjdd\}\}}|j||||d}	|j	||||d}
|	j
|| d}|
j
|| d}|d kr¤d| }n|}|D ]}| ¡ |ks¬t‚q¬|D ]}| ¡ |ksÆt‚qÆd S )Nr   r   rA   )Zncols)Úzorder)r¨   Úuse_clabeltext)r   r   r   rN   rO   rP   r   r   r   r_   r;   Z
get_zorderr-   )r©   Zcontour_zorderZclabel_zorderr   r   r   r   Úax1Úax2r<   Z	cs_filledZclabels1Zclabels2Zexpected_clabel_zorderr;   r   r   r   Útest_clabel_zorder  s      ÿ
r¬   zcontour_log_extension.pngc                  C   s8  dt jd< t jdddd\} \}}}| jddd	 t d
dd¡}t d|¡ dd¡}t dd¡}t d|¡}|j	|t
| ¡ | ¡ dd}|j	||t
| ¡ | ¡ ddd}	|j	||t
| ¡ | ¡ ddd}
t j||d}|j ¡ dksît‚t j|	|d}|j ¡ dkst‚t j|
|d}t|j ¡ ddgdƒ d S )NFrT   r)   r   )r   r4   )rD   gš™™™™™©?rŒ   )Úleftru   g      Àg      #@i°  r   rv   é(   g      Àg      @r~   )ZvminZvmax)ÚnormrW   )r(   r¯   r[   rY   r\   )g:Œ0âŽyE>g    _ B)g-Cëâ6?g    €„.Ag¼á›TV” ?gÇe€ÔR HArA   )r   r]   r   rw   r   r‘   Úpowerr5   r   r_   r   rX   rN   r`   r   Úget_ylimr-   r   )r   rª   r«   Zax3Zdata_exprc   Z
levels_expr(   Zc1Úc2Úc3Úcbr   r   r   Útest_contourf_log_extension4  s8    
ÿþþ  ÿrµ   zcontour_addlines.pngg¸…ëQ¸ž?c                  C   sz   dt jd< t  ¡ \} }tj d¡ tj dd¡d }| |¡}| |d ¡}|  	|¡}| 
|¡ t|j ¡ ddgd	ƒ d S )
NFrT   i,N,r   i'  iè  gdÌ]KÈ“\@g6«>W'zÃ@r   )r   r]   r   r   r   r   r”   Z
pcolormeshr   r`   Z	add_linesr   r   r±   )r   r   r†   ZpcmZcontr´   r   r   r   Útest_contour_addlinesY  s    



r¶   Zcontour_unevenZpng)Zbaseline_imagesÚ
extensionsr?   r@   c                  C   s   dt jd< t d¡ dd¡} t  dd¡\}}|d }|j| dddd	d
gd}|j||dd |d }|j| dddd	d
gd}|j||dd d S )NFrT   é   r3   rB   r)   rA   r   r   rp   r'   Zproportional)r   ÚspacingÚuniform)r   r]   r   r   r5   r   r_   r`   )r   r   rb   r   r<   r   r   r   Útest_contour_unevenl  s    
r»   zCrc_lines_linewidth, rc_contour_linewidth, call_linewidths, expected)ç®Gáz®ó?NNr¼   )r¼   çö(\Âõ@Nr½   )r¼   r½   ç®Gáz@r¾   c              	   C   sb   t | |dœdH t ¡ \}}t d¡ dd¡}|j||d}|jd d |ksTt‚W 5 Q R X d S )N)zlines.linewidthzcontour.linewidth)Úrcr1   r3   r   )Z
linewidthsr   )	r   r   r   r   r   r5   r   Ztlinewidthsr-   )Zrc_lines_linewidthZrc_contour_linewidthZcall_linewidthsÚexpectedr   r   r†   r<   r   r   r   Útest_contour_linewidth|  s    	ÿrÁ   Zpdfc                   C   s    t  t  ddgddgg¡¡ d S )Nr)   rA   r   r3   )r   r;   r   r   r   r   r   Útest_label_nonagg  s    rÂ   )1ri   Úplatformr"   Znumpyr   Znumpy.testingr   rž   rŸ   Zmatplotlib.testing.decoratorsr   r   r   r   Zmatplotlib.colorsr   r   r   r   ÚmarkZparametrizer   Úemptyr&   r0   r7   r=   r>   rS   rf   r{   ÚmachinerŠ   r—   r™   r›   r!   r˜   r5   r¢   r£   r¥   r¬   rµ   r¶   r»   rÁ   ÚbackendrÂ   r   r   r   r   Ú<module>   sú   
ÿÿÿÿÿÿÿÿÿÿí


 ÿ
 þ
ÿþ
ÿÿÿÿ$ÿ÷
		 ÿÿ
 ÿ
#  ÿ
  ÿ
ýÿ

