o
    i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&id'd(d)d*d+ Ze
d,gd'd(d-d.d/ Ze
d0gd'd1d2d3 Ze
d4gd5d(d-d6d7 Ze
d8gd'd(e  d9krd nd:d;d<d= Z!e
d>d?gd'd1d@dA Z"dBdC Z#dDdE Z$ejdFdGe%dHfdIe&dJfd ggd ggg gdd'd fe&dKfd ggd ggd ggdd'd fe&dLfg edM'dNgdO d ggd'd R e&dPfgdQdR Z(dSdT Z)dUdV Z*ejdWg dXdYdZ Z+e
d[gd'd(d-d\d] Z,e
d^gd'd(d_d;d`da Z-e
dbgdcgd'd(dddedf Z.ejdgg dhdidj Z/dS )k    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   X/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/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   xg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   sP   t  \}}tjtt|d |j|   W d    d S 1 s!w   Y  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   sr   t d} t jd}t \}}tt}|j| | |g d W d    n1 s*w   Y  t	|dks7J d S )Nr	   r   levels   )
r   r   r   r   r   r!   warnsUserWarningr   lenr   r   r   r   recordr   r   r   test_contour_empty_levels?   s   
r1   c                  C   s`   t dd} t \}}|| d}t|jdksJ |j| dd}|j|jk s.J d S )N   r         r+   r)   )	r   r   reshaper   r   r   r.   r*   all)r   r   r   cs1cs2r   r   r   test_contour_NlevelsJ   s   r:   c                  C   s   t d} t d}t \}}ddi}tt}|j| | |dgd}|j	||d W d    n1 s5w   Y  t
|dksBJ d S )Nr	   r         ?z%1.2fr)   )fmtr+   )r   r   zerosr   r   r!   r,   r-   r   clabelr.   )r   r   r   r   r<   r0   csr   r   r   test_contour_badlevel_fmtU   s   

r@   c                  C   sl   t d} t d}t \}}tt}|| | | W d    n1 s'w   Y  t	|dks4J d S )Nr	   r   r+   )
r   r   onesr   r   r!   r,   r-   r   r.   r/   r   r   r   test_contour_uniform_ze   s   

rB   contour_manual_labelsdpi   Tmpl20)savefig_kwargremove_textstylec                  C   sz   t t ddt dd\} }t t t| t|gd}tjddd t| ||}t 	g d}tj
||d d S )	Nr   r         rJ   rE   )figsizerD   )      ?      @)rO   g@)rO   g      @)manualr   r   r   maxdstackabsr   figurer   arrayr>   r   r   r   r?   ptsr   r   r   test_contour_manual_labelsp   s    rZ   zcontour_labels_size_color.png)rH   rI   c                  C   s|   t t ddt dd\} }t t t| t|gd}tjdd t| ||}t 	g d}tj
||ddd	 d S )
Nr   r   rJ   rK   rM   rN   small)rg)rQ   fontsizecolorsrR   rX   r   r   r   test_contour_labels_size_color}   s    ra   z$contour_manual_colors_and_levels.png)rH   c                  C   s   t dd\} }tddd}g d}g d}t|jD ]F\}}|d dk}g d|d  }|rP|d	v r8d
nd }	|dv r@dnd }
|j|||	|
 ||d}n|j||d d ||d}t j	||d qd S )NrJ   r4   r2   r   )redyellowpinkblueblack)rJ   r4      r           )neitherminrS   both)rS   ri   r+   )rj   ri   )r`   r*   extendr   )
r   r   r   r   r6   	enumerateflatcontourfr   colorbar)_axsdatar`   r*   ir   filledrm   first_color
last_colorcr   r   r   $test_given_colors_levels_and_extends   s$   r{   zcontour_datetime_axis.pngFc                     s8  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 qqd S )Ng?g\(\?g333333?)hspacetop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   )axis      right   )r   rV   subplots_adjustr   r   rW   ranger   r   subplotr   rq   repeatnewaxisget_axesget_xticklabelsset_haset_rotation)r   r   r   z1z2r   r   labelr   r   r   test_contour_datetime_axis   s.   





r   z!contour_test_label_transforms.pngx86_64g{Gz?)rH   rI   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\}}	|	|||}
g d}g d}|
  |D ]\}}|
j	||dd d qm|D ]\}}|
j	||ddd q}d S )Ng?g      rP   g              @rJ   r+   rO         ?      $@))      )ig  i"  )i	  i  ))r   )r   g      )gffffff@r+   T)inline	transformF)
r   r   r   exppir   r   r   r>   add_label_near)deltar   r   XYZ1Z2Zr   r   CS
disp_units
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 qId S )N<   ffffff?r;   r+   r   r      rg   )mask)FT)corner_mask)r   r   seedr   linspacecossinrandmarW   r   rV   rq   )n
mask_level	noise_ampr   r   r   r   r   r   r   r   test_corner_mask   s   $.r   c                  C   sX   ddgddgg} t   tt t | ddg W d    d S 1 s%w   Y  d S )Ng?g333333?r   gffffff?r;   rh   )r   rV   r!   r"   
ValueErrorrq   )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 )	Nr2   r3   r4   T)nbins	symmetric)locatorir5   )	r   r   r6   r   MaxNLocatorrq   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+   rJ   r   r4   r5   rL   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 arraysr4   )rJ   rJ   r   zCIf mask is set it must be a 2D array with the same dimensions as x.c                 C   sR   ddl m} tj|t|d tjj|   W d    d S 1 s"w   Y  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   sr   ddl m}  ddgddgg}tj|||d dd}tjtdd |dd W d    d S 1 s2w   Y  d S )	Nr   r   r+   rJ   r   Tz(filled contour levels must be increasingr   )r   r   r   r   r!   r"   r   create_filled_contour)r   arr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   rJ   r4   )r   r   r   hypotr   rV   r   r>   )r   r   r]   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 u rRd| }n|}|D ]
}| |ks`J qV|D ]
}| |ksmJ qcd S )Nr   r   rJ   )ncols)zorder)r   use_clabeltext)r   r   r   rS   rT   rU   r   r   r   rq   r>   
get_zorder)r   contour_zorderclabel_zorderr   r   r   r   ax1ax2r?   	cs_filledclabels1clabels2expected_clabel_zorderr>   r   r   r   test_clabel_zorder%  s"    
r   zcontour_log_extension.pngc                  C   s<  t jdd} | jddd | 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szJ t j|	|d}|j dksJ t j|
|d}t|j ddgd d S )N)r   r5   r[   g?r   )leftr            g      g      #@i  r   r   (   g      g      @r   )vminvmax)normri   )r*   r   rm   rk   rn   )g:0yE>g    _B)g-C6?g    .AgTV ?geR HArJ   )r   rV   r   add_subplotr   r   powerr6   r   rq   r   rj   rS   rr   r   get_ylimr   )r   r   r   ax3data_expru   
levels_expr*   c1c2c3cbr   r   r   test_contourf_log_extension>  s8   


r   zcontour_addlines.pnggQ?c                  C   sp   t  \} }tjd tjddd }||}||d }| |}|	| t
|j ddgd d S )Ni,N,r   i'  i  gd]Kȓ\@g6>W'z@r   )r   r   r   r   r   r   
pcolormeshr   rr   	add_linesr   r   r   )r   r   r   pcmcontr   r   r   r   test_contour_addlinesc  s   


r   contour_unevenpng)baseline_images
extensionsrH   rI   c                  C   sz   t ddd} tdd\}}|d }|j| g dd}|j||d	d
 |d }|j| g dd}|j||dd
 d S )N   r4   rL   r+   rJ   r   )rJ   r4   rL   r   r   r)   proportional)r   spacinguniform)r   r   r6   r   r   rq   rr   )r   r   rt   r   r?   r   r   r   test_contour_unevens  s   r  zCrc_lines_linewidth, rc_contour_linewidth, call_linewidths, expected))Gz?NNr  )r  (\@Nr  )r  r  Gz@r  c                 C   sx   t | |dd* t \}}tddd}|j||d}|jd d |ks*J W d    d S 1 s5w   Y  d S )N)zlines.linewidthzcontour.linewidth)rcr2   r4   r   )
linewidthsr   )r   r   r   r   r   r6   r   tlinewidths)rc_lines_linewidthrc_contour_linewidthcall_linewidthsexpectedr   r   r   r?   r   r   r   test_contour_linewidth  s   	"r  )0r   platformr$   numpyr   numpy.testingr   r   r   matplotlib.testing.decoratorsr   r   r   r   matplotlib.colorsr   r!   r   r   markparametrizer   emptyr(   r1   r:   r@   rB   rZ   ra   r{   r   machiner   r   r   r   r#   r   r6   r   r   r   r   r   r   r  r  r   r   r   r   <module>   s    








,
		

#

