o
    tBhI                     @   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g edG&dHgdI d ggd%d R e%dJfgdKdL Z'dMdN Z(dOdP Z)ejdQg dRdSdT Z*e
dUgd%d&dVd5dWdX Z+e
dYgd%d&dZd5d[d\ Z,e
d]gd^gd%d&d_d`da Z-ejdbg dcddde Z.ej/dfdgdh Z0e
digd^gd%djdkdl Z1dmdn Z2e
dogd^gd%djdpdq Z3e
drgd^gd%djdsdt Z4dudv Z5dwdx Z6ej78dydzd{ Z9dS )|    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   t/var/www/html/riverr-enterprise-integrations-main/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_labelsT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 	g d}tj
||d t 	g d	}tj
||d
dd d S )Nr   r      )   rG      )figsizedpi))r;         @)r;   皙@)r;         @)manual))       @rL   )rP   rM   )rP   rN   small)rg)rO   fontsizecolors)r   r   r   maxdstackabsr   figurer   arrayr>   )r   r   r   r?   ptsr   r   r   test_contour_manual_labelsp   s    r\   z$contour_manual_colors_and_levels.png)rE   c                  C   s   dt jd< t dd\} }tddd}g d}g d}t|jD ]F\}}|d d	k}g d
|d  }|rU|dv r=dnd }	|dv rEdnd }
|j|||	|
 ||d}n|j	||d d ||d}t j
||d q#d S )NFpcolormesh.snaprG   r4   r2   r   )redyellowpinkblueblack)rG   r4      r           )neitherminrV   both)rV   re   r+   )rf   re   )rU   r*   extendr   )r   rcParamsr   r   r   r6   	enumerateflatcontourfr   colorbar)_axsdatarU   r*   ir   filledri   first_color
last_colorcr   r   r   $test_given_colors_levels_and_extends}   s&   
rx   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   rY   subplots_adjustr}   r   rZ   ranger   r   subplotr   rn   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?)rE   rF   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      rL   g       rP   rG   r+   g      ?      ?      $@))      )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   rP      rc   mask)FTcorner_mask)r   r   seedr   linspacecossinrandmarZ   r   rY   rn   )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   ffffff?r;   rd   )r   rY   r!   r"   
ValueErrorrn   )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   MaxNLocatorrn   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+   rG   r   r4   r5   rH   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   rG   rG   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+   rG   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   rG   r4   )r   r   r   hypotr   rY   r   r>   )r   r   rR   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   rG   )ncols)zorder)r   use_clabeltext)r   r   r   rV   rW   rX   r   r   r   rn   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.pnggv?c                  C   s   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swJ t j|	|d}|j dksJ t j|
|d}d S )NFr]   r+   r   )r   r5   rJ   g?r   )leftr   g      g      #@i  r   r   (   g      g      @r   )vminvmax)normre   )r*   r   ri   rg   rj   )g:0yE>g    _B)-C6?g    .A)r   rk   r   r   r   r   powerr6   r   rn   r   rf   rV   ro   r   get_ylim)r   r   r   ax3data_exprr   
levels_expr*   c1c2c3cbr   r   r   test_contourf_log_extension7  s.   
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 )
NFr]   i,N,r   i'  i  gd]Kȓ\@g6>W'z@r   )r   rk   r   r   r   r   r   
pcolormeshr   ro   	add_linesr   r   r   )r   r   r   pcmcontr   r   r   r   test_contour_addlines[  s   



r   contour_unevenpng)baseline_images
extensionsrE   rF   c                  C   s   dt jd< 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 )NFr]      r4   rH   r+   rG   r   )rG   r4   rH   r   r   r)   proportional)r   spacinguniform)r   rk   r   r   r6   r   rn   ro   )r   r   rq   r   r?   r   r   r   test_contour_unevenn  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  pdfc                   C   s    t t ddgddgg d S )Nr+   rG   r   r4   )r   r>   r   r   r   r   r   test_label_nonagg  s    r  contour_closed_line_loop)r   r   rE   c                  C   s^   g dg dg dg dg} t jdd\}}|j| dgdgdd	 |d
d |d
d d S )N)r   r   r   )r   rG   r   )rG   r+   rG   r   r   r   r   r   )r  alphagg @g@)r   r   r   set_xlimset_ylim)r   r   r   r   r   r   test_contour_closed_line_loop  s
   r  c                  C   sx   t ddgddg\} }| | }t \}}|| ||}|| ||}|j|jks,J |||}|j|jks:J d S )Nrd   r;   )r   r   r   r   rn   r   _contour_generator)r   r   r   r   r   qcs1qcs2qcs3r   r   r   test_quadcontourset_reuse  s   r  contour_manualc            
      C   sr  ddl m}  tjdd\}}d}ddgddgddggg}ddgddggddgdd	ggg}ddgdd	gddgddgddggg}ddgddgddgddgddggdd	gdd	gddggg}| |g d
||gd|d | |ddg||gdddgd d	dgddgddgd	dgd	dgddgddgddgddgddgg
g}g dg}	| |ddg|g|	gd|d | |dg|g|	gddd d S )Nr   )
ContourSet)r4   r4   r   viridisrG   r+   r   r4   r   r+   rG   T)rt   cmaprR   k)r  rU   r   r5   rH   )
r+   rG   rG   rG   O   r+   rG   rG   rG   r!  )rU   r  )matplotlib.contourr  r   r   )
r  r   r   r  lines0lines1filled01filled12segskindsr   r   r   test_contour_manual  s"    $ 
r)  !contour_line_start_on_corner_edgec            	      C   s   t jdd\} }tg dg d\}}d|d d  |d d  }tj|td}d	 |d
< |d< tjj||d}|j|||d	d}| 	|}|j
|||d	dd}|| d S )N)rH   r5   r   )r   r+   rG   r   r4   r  g333333?rG   r+   )dtypeT)r+   r+   )r+   r   r   r   r   )r   rU   )r   r   r   r   
zeros_likeboolr   rZ   rn   ro   r   r   )	r   r   r   r   r   r   rt   cbarlinesr   r   r   &test_contour_line_start_on_corner_edge  s   
r0  c                  C   s   t d} t t j t | d d dd  }t|d}|jdddd	}d
}t|| |jdddd	}d}t|| |jdddd	}d}t|| |jddddd}d}t|| d S )N   r2  r5   rG   r         9@r   r+   Fpixel)r+   r   !   YİØt?r7  gb?rc   )r+   r   r5   g`3@gDlpf?gݓ?)r   r      gͰQo&?ghW!@g|o^}?r5   r   indicesr5  )r5   r      gA*Ŏ@g      @gA?)	r   r;  r   r   sumr   r   find_nearest_contourr   )xyimgr?   nearest_contourexpected_nearestr   r   r   test_find_nearest_contour  s$   
&


rC  c                  C   s   t d} t t j t | d d dd  }t|d}tjt	dd |j
d	d	d
d W d    n1 s8w   Y  tjt	dd |j
d	ddd
d W d    n1 sXw   Y  tjt	dd |j
ddddd W d    d S 1 syw   Y  d S )Nr1  r5   rG   r   r3  r   z(Method does not support filled contours.r   r+   Fr4  r9  r:  )rG   r   T)r   r;  r   r   r=  r   rn   r!   r"   r   r>  )r?  r@  r?   r   r   r   #test_find_nearest_contour_no_filled  s$   
&"rD  defaultc                  C   sZ   t   } t jtdddddg dd}| | dd | jD h d	ks+J d S )
Ngư>r   d   r   )gh㈵>gh㈵>gh㈵?r)   c                 S   s   h | ]}|  qS r   )get_text)r   textr   r   r   	<setcomp>
  s    z<test_contour_autolabel_beyond_powerlimits.<locals>.<setcomp>>   0.251.004.00)	r   rY   add_subplotr   r   	geomspacer6   r>   texts)r   r?   r   r   r   )test_contour_autolabel_beyond_powerlimits  s   
 rP  ):r}   platformr$   numpyr   numpy.testingr   r   r   matplotlib.testing.decoratorsr   r   r   r   matplotlib.colorsr   r!   r   r   markparametrizer   emptyr(   r1   r:   r@   rB   r\   rx   r   machiner   r   r   r   r#   r   r6   r   r   r   r   r   r   r  r  backendr  r  r  r)  r0  rC  rD  rF   contextrP  r   r   r   r   <module>   s   






,
		

!









