U
    FvfŢ                     @   s  d dl m Z  d dlZd dlZd dlmZ d dlZd dlmZm	Z	 d dl
Z
d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZmZ d dl m!Z!m"Z" dd Z#e"d	gd
d Z$e"dgdd Z%e"dgdd Z&e"dgdd Z'e"dgdd Z(e"dgdd Z)e"dgdd Z*e"dgdd  Z+e"d!gd"d# Z,e"d$gd%d& Z-e"d'd'd(gd)d* Z.e"d+gd,d- Z/d.d/ Z0d0d1 Z1d2d3 Z2d4d5 Z3ej45d6e!d7gd8d9d: Z6d;d< Z7d=d> Z8e"d?gd@dAdBdC Z9e"dDgd@dAdEdF Z:e"dGgd@dAdHdI Z;e"dJgd@dAdKdL Z<dMdN Z=dOdP Z>dQdR Z?dSdT Z@dUdV ZAdWdX ZBe"dYgd@dAdZd[ ZCd\d] ZDej45d^d_d` ZEdadb ZFej45d^dcdd ZGej45d^dedf ZHe"dggdhdi ZIe"djgd@d^dkdldm ZJdndo ZKdpdq ZLdrds ZMdtdu ZNdvdw ZOdxdy ZPdzd{ ZQe
jRSd|d}d~gdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[ej45d^e
jRSdej\ej]gdd Z^dd Z_dd Z`dd Zadd Zbdd Zcdd Zde"dgd7gd@d6ddd Zee!d7gd8dd Zfdd ZgdS )    )datetimeN)SimpleNamespace)assert_array_equalassert_array_almost_equal)
CollectionLineCollectionEventCollectionPolyCollection)check_figures_equalimage_comparisonc               
   C   s   t ddddddddg} t d	d
dg}d}d}d}d}ddddg}d}d}t| |||||||d}	t \}
}||	 |d | ||||||||d	}|dd |dd ||	|fS )z,Generate the initial collection and plot it.              ?       @      @g      @g       @g      *@g      5@g      A@g     K@g     @V@
horizontal         ?   r   solidT)orientation
lineoffset
linelength	linewidthcolor	linestyleantialiasedzEventCollection: default)		positionsextra_positionsr   r   r   r   r   r   r      )	nparrayr   pltsubplotsadd_collection	set_titleset_xlimset_ylim)r   r   r   r   r   r   r   r   r   collfigaxprops r,   E/tmp/pip-unpacked-wheel-7vhvci0g/matplotlib/tests/test_collections.pygenerate_EventCollection_plot   sD    



r.   ZEventCollection_plot__defaultc                  C   s   t  \} }}t||d |d |d |d  tj|d |  |d | ksVt| sbt|d |	 ksvt|d |
 kst| dgkst| f| D ]}tj||d  qd S )Nr   r   r   r   r   Nr   )r.   check_segmentsr    testingr   get_positionsget_orientationAssertionErroris_horizontalget_linelengthget_lineoffsetZget_linestyle	get_color
get_colors)_r(   r+   r   r,   r,   r-    test__EventCollection__get_props=   s    r;   Z#EventCollection_plot__set_positionsc                  C   st   t  \} }}t|d |d g}|| tj||  t|||d |d |d  | d | 	dd d S )	Nr   r   r   r   r   zEventCollection: set_positionsr   Z   )
r.   r    hstackZset_positionsr1   r   r2   r0   r%   r&   spltr(   r+   new_positionsr,   r,   r-   $test__EventCollection__set_positionsW   s    

rA   Z#EventCollection_plot__add_positionsc                  C   s   t  \} }}t|d |d d g}|  ||d d  |  tj||  t|||d |d |d  | 	d | 
dd	 d S )
Nr   r   r   r   r   r   zEventCollection: add_positionsr   #   )r.   r    r=   switch_orientationZadd_positionsr1   r   r2   r0   r%   r&   r>   r,   r,   r-   $test__EventCollection__add_positionse   s     


rD   Z&EventCollection_plot__append_positionsc                  C   s   t  \} }}t|d |d d g}||d d  tj||  t|||d |d |d  | d | 	dd	 d S )
Nr   r   r   r   r   r   z!EventCollection: append_positionsr   r<   )
r.   r    r=   Zappend_positionsr1   r   r2   r0   r%   r&   r>   r,   r,   r-   'test__EventCollection__append_positionsw   s    


rE   Z&EventCollection_plot__extend_positionsc                  C   s   t  \} }}t|d |d dd  g}||d dd   tj||  t|||d |d |d  | d | 	dd	 d S )
Nr   r   r   r   r   r   z!EventCollection: extend_positionsr   r<   )
r.   r    r=   Zextend_positionsr1   r   r2   r0   r%   r&   r>   r,   r,   r-   'test__EventCollection__extend_positions   s    

rF   Z(EventCollection_plot__switch_orientationc                  C   sz   t  \} }}d}|  || ks(t| r4t| }t|||d |d | | d | dd | 	dd d S )	Nverticalr   r   z#EventCollection: switch_orientationr   r   r   r   )
r.   rC   r3   r4   r5   r2   r0   r%   r'   r&   )r?   r(   r+   new_orientationr@   r,   r,   r-   )test__EventCollection__switch_orientation   s     
rI   Z,EventCollection_plot__switch_orientation__2xc                  C   s   t  \} }}|  |  | }|d | ks8t| sDttj|d | t	|||d |d |d  | 
d dS )zc
    Check that calling switch_orientation twice sets the orientation back to
    the default.
    r   r   r   r   z&EventCollection: switch_orientation 2xN)r.   rC   r2   r3   r4   r5   r    r1   r   r0   r%   r>   r,   r,   r-   ,test__EventCollection__switch_orientation_2x   s    rJ   Z%EventCollection_plot__set_orientationc                  C   sx   t  \} }}d}|| || ks*t| r6tt||d |d |d | | d | dd | dd	 d S )
NrG   r   r   r   z EventCollection: set_orientationr   r   r   r   )	r.   Zset_orientationr3   r4   r5   r0   r%   r'   r&   )r?   r(   r+   rH   r,   r,   r-   &test__EventCollection__set_orientation   s    

rK   Z$EventCollection_plot__set_linelengthc                  C   s`   t  \} }}d}|| || ks*tt||d ||d |d  | d | dd d S )N   r   r   r   zEventCollection: set_linelengthi   )r.   Zset_linelengthr6   r4   r0   r%   r'   )r?   r(   r+   Znew_linelengthr,   r,   r-   %test__EventCollection__set_linelength   s    

rN   Z$EventCollection_plot__set_lineoffsetc                  C   s`   t  \} }}d}|| || ks*tt||d |d ||d  | d | dd d S )Ng      r   r   r   zEventCollection: set_lineoffseti)r.   Zset_lineoffsetr7   r4   r0   r%   r'   )r?   r(   r+   Znew_lineoffsetr,   r,   r-   %test__EventCollection__set_lineoffset   s    

rP   Z#EventCollection_plot__set_linestyleZ#EventCollection_plot__set_linewidthc                  C   sj   dddgfdddgfdfD ]J\} }}t  \}}}|jf | |i t|| |ksTt|d|   qd S )Nr   dashed)r   )      @rR   )r      rS   zEventCollection: set_)r.   setr"   Zgetpr4   r%   )propvalueexpectedr?   r(   r:   r,   r,   r-   test__EventCollection__set_prop   s    

rX   ZEventCollection_plot__set_colorc                  C   s\   t  \} }}tddddg}|| | f| D ]}tj|| q:| d d S )Nr   r   zEventCollection: set_color)	r.   r    r!   	set_colorr8   r9   r1   r   r%   )r?   r(   r:   Z	new_colorr   r,   r,   r-    test__EventCollection__set_color   s    
rZ   c           
      C   s   |   }| dks(| dks(|dkr2d}d}n| dkrHd}d}ntdt|D ]p\}}	|	d|f ||d  ks|t|	d|f ||d  kst|	d|f || kst|	d|f || ksXtqXdS )	zp
    Test helper checking that all values in the segment are correct, given a
    particular set of inputs.
    r   noneNr   r   rG   z.orientation must be 'horizontal' or 'vertical'r   )get_segmentslower
ValueError	enumerater4   )
r(   r   r   r   r   segmentsZpos1pos2isegmentr,   r,   r-   r0     s"    
r0   c                  C   s4   t g } | t }t| tj   d S N)	mcollectionsPathCollectionget_datalimmtransformsIdentityTransformr   
get_pointsBboxnull)colZcol_data_limr,   r,   r-   test_null_collection_datalim!  s
    
rn   c                  C   sR   t  } ttddgg}| | |t	 }t
| tj   d S )Nr   r   )r   r   )r"   axesre   rf   mpathPathr$   rg   rh   ri   r   rj   rk   rl   )r*   r(   Zcoll_data_limr,   r,   r-   test_no_offsets_datalim(  s    
rs   c                  C   sL   t   t  } | ddgddg | jj}| g g  | jj|ksHtd S )Nr   r   )r"   figurerp   scatterdataLimboundsr4   )r*   rw   r,   r,   r-   test_add_collection3  s    rx   Zmpl20Zpng)
extensionsc                 C   s   ddddddddd	d
dddddg}dddddddddddddg}t ||\}}| }| }|  }|d |d d|_||| | }|d |d |j||dd d! d S )"Ng+c>g`8F>gq[;u>gy7/>g9̗>gW!>g-I>g\p5>gdjD>gyK'?g~+=?gFEAL ?g|0j?gGKe?gލ=B?r   皙?gK?gsh|??gS?g?r   gQ@g(\@g333333(@g      6@gC@g33333Q@logr   o )markerls)	r    meshgridflattenr#   Z
set_xscaleZ
set_yscaleZmarginsru   Zplot)fig_testfig_refZx_valsZy_valsxyax_testax_refr,   r,   r-   test_collection_log_datalim>  s8    
         



r   c                  C   s   t  } tdtd }}tddddd }}t ||||}|| jj	dks^t
t   t  } tddd}tdd	d}t||\}}t d
d| j }t j||t|t||d | jj	dkst
d S )N   
   r   P   )r   r   g      @g      "@rM             	transform)g      4@g      >@g      .@rR   )r"   rp   r    arangelinspacereshapeZquiverrg   	transDatarw   r4   rt   r   rh   Affine2D	translatesincosrv   )r*   r   r   uvqtransr,   r,   r-   test_quiver_limitsX  s     r   c                  C   s   t  } tddd}tddd}t||\}}t dd| j }t j	||t
|t||d t| jjd	d
d d S )Nr   r   rM   r   r   r   r   r   )rM      rL      r   decimal)r"   rp   r    r   r   rh   r   r   r   Zbarbsr   r   r   rv   rw   )r*   r   r   r   r,   r,   r-   test_barb_limitsi  s     
r   z EllipseCollection_test_image.pngT)remove_textc               	   C   s   t  \} }td}td}t||\}}t| | fj}||d  }||d  }t|d }	t	j
|||	d||jdd}
||
 |  d S )Nr      r   rM   r   r[   )unitsoffsetsoffset_transform
facecolors)r"   r#   r    r   r   ZvstackravelTZ	ones_likere   EllipseCollectionr   r$   autoscale_view)r)   r*   r   r   XYZXYZwwhhaaecr,   r,   r-   test_EllipseCollectionw  s&    

     
r   zpolycollection_close.pngc                  C   sN  ddl m}  ddgddgddgddggddgddgddgddggddgddgddgddggddgddgddgddggg}t }|| |}dd	d
ddg}ttd}tj|t	| dd}|
d g }g }t||D ]0\}	}
||	gt	|  ||
gt	|  q|| |j||dd |dd |dd |dd d S )Nr   )Axes3Dr   r   r   r         @rgbr   krS         ?r   gffffff?)zsZzdirr   r   )Zmpl_toolkits.mplot3dr   r"   rt   Zadd_axeslistrangere   r	   len	set_alphazipextendrY   Zadd_collection3dZ
set_xlim3dZ
set_zlim3dZ
set_ylim3d)r   Z	vertsQuadr)   r*   colorsZzposZpolyr   cszcr,   r,   r-   test_polycollection_close  s2    
 

r   z regularpolycollection_rotate.pngc            	      C   s   t jd dd df \} }t |  | g}t ddt j t|}t \}}t	||D ].\}}t
jdd||g|jd}|j|dd q^|  d S )	Nr   r   r   r   )d   )sizesrotationr   r   TZautolim)r    ZmgridZ	transposer   r   pir   r"   r#   r   re   RegularPolyCollectionr   r$   r   )	xxyyZ	xy_pointsZ	rotationsr)   r*   xyalpharm   r,   r,   r-   !test_regularpolycollection_rotate  s       r   zregularpolycollection_scale.pngc                  C   sd   G dd dt j} t \}}dg}tjd g}| |||jd}|j|dd |dd	dd	g d S )
Nc                       s$   e Zd Z fddZdd Z  ZS )z:test_regularpolycollection_scale.<locals>.SquareCollectionc                    s    t  jddtjd i| d S )Nr   r   r   )r   )super__init__r    r   )selfkwargs	__class__r,   r-   r     s    zCtest_regularpolycollection_scale.<locals>.SquareCollection.__init__c                 S   sJ   | j }d|jj }||jj |jj }||jj |jj }t 	||S )z4Return transform scaling circle areas to data space.g      R@)
rp   rt   dpiZbboxwidthZviewLimheightrh   r   Zscale)r   r*   Z
pts2pixelsZscale_xZscale_yr,   r,   r-   get_transform  s
    zHtest_regularpolycollection_scale.<locals>.SquareCollection.get_transform)__name__
__module____qualname__r   r   __classcell__r,   r,   r   r-   SquareCollection  s   r   ro   r   )r   r   r   Tr   r   r   )	re   r   r"   r#   r    r   r   r$   Zaxis)r   r)   r*   r   Zcircle_areasZsquaresr,   r,   r-    test_regularpolycollection_scale  s      r   c                  C   sn   t  \} }|jdgdgdgdd}| jt | jd tddd}||\}}|sZt	t
|d	 dg d S )
Nr   i  T)Zpicker)r   iE     )r   r   ind)r"   r#   ru   ZsavefigioBytesIOr   r   containsr4   r   )r)   r*   rm   mouse_eventfoundindicesr,   r,   r-   test_picking  s    r   c                  C   s   t d} | d d d f | d d d f  }t \}}||}|  d\}}| ||f\} }t||| |d}|	|\}	}
|	st
t|
d dg d\}}| ||f\} }t||| |d}|	|\}	}
|	st
t|
d dg d S )Nr   r   r   xdataydatar   r   r   r         ?r   rS   )r    r   r"   r#   
pcolormeshdraw_without_renderingr   r   r   r   r4   r   )r   r   r)   r*   meshr   r   r   r   r   r   r,   r,   r-   test_quadmesh_contains  s"    
 
r   c                  C   s   ddgddgg} ddgddgg}t  \}}|| |dgg}|  ddddg}|D ]N}|\}}}	| ||f\} }t||| |d}
||
\}}||	ksVtqVd S )	Nr   r   r   )      r   T)r   r   F)r   r   T)r   g      пTr   )	r"   r#   r   r   r   r   r   r   r4   )r   r   r)   r*   r   ZpointsZpointr   r   rW   r   r   r   r,   r,   r-   test_quadmesh_contains_concave  s     
r   c            	      C   s   t d} | d d d f | d d d f  }t \}}||}d |_|  d\}}| ||f\} }t	||| |d}|
|d kst|t |j t|
|dg d S )Nr   r   r   r   )r    r   r"   r#   r   Z_Ar   r   r   r   get_cursor_datar4   	set_arrayonesshaper   )	r   r   r)   r*   r   r   r   r   r   r,   r,   r-   test_quadmesh_cursor_data  s    
 
r   c                  C   s|   ddddg} t  \}}|| | td}|  d\}}| ||f\} }t||| |d}t	|
|td d S )Nr   r   r   r   r   r   	   )r"   r#   r   r    r   r   r   r   r   r   r   )r   r)   r*   r   r   r   r   r   r,   r,   r-   )test_quadmesh_cursor_data_multiple_points%  s    r   c                   C   s0   t jdddgdddgdddgfd t   d S )Nr   r   r   r   r   )r   )r"   ru   drawr,   r,   r,   r-   test_linestyle_single_dashes1  s    $r  zsize_in_xy.pngc                  C   s`   t  \} }d\}}}d}ddg}tj|||d||jd}|| |dd |dd d S )N)r   r   r   r   r  )rL   rL   r   )r   r   r   r   r   )r"   r#   re   r   r   r$   r&   r'   )r)   r*   ZwidthsZheightsZanglescoordser,   r,   r-   test_size_in_xy6  s    
    
r  c                 C   s   dddg}| j dddg|d }}| j dd	d
g|d}| j dddg|d}| j dddg|d}t|d t|d t|d t|d t|d d S )N         redZblueZgreen)indexr   r   r   r   rQ   ZdashdotTF)
edgecolors)r   )
linewidths)Z
linestyles)Zantialiaseds)ZSeriesr   )pdr  r   ZfcZlwr   r   r,   r,   r-   test_pandas_indexingG  s    




r  defaultc                  C   s   t g } | ddg | dddg |  dgd ks>t|  dddgd ksXt| dddg |  dgd ks~t|  dddgk std S )N-r   r   r   r/   r   )re   rf   Zset_linestylesZset_linewidthsZget_linestylesr4   Zget_linewidthsallrm   r,   r,   r-   test_lslw_bcastX  s    
r  c               	   C   s.   t  } tjtdd | d W 5 Q R X d S )Nz"Do not know how to convert 'fuzzy'matchZfuzzy)r   pytestraisesr^   Zset_linestyler   r,   r,   r-   test_set_wrong_linestylef  s    r  c                  C   s<   t jg dd} |  dkst| d |  dks8td S )Nround)ZcapstyleZbutt)re   rf   Zget_capstyler4   set_capstyler  r,   r,   r-   test_capstylel  s    
r  c                  C   s<   t jg dd} |  dkst| d |  dks8td S )Nr  )Z	joinstylemiter)re   rf   Zget_joinstyler4   set_joinstyler  r,   r,   r-   test_joinstylet  s    
r   zcap_and_joinstyle.pngc                  C   s   t  \} }|ddg |ddg tdddg}tdgdgdggtdddgg }td}||d d d d df< ||d d d d d	f< t|d
ddgd}|d |	d |
| |d d S )Nr   r         @r   r   r   )r   r   r   r   r   r   rL   rM   r   r  r  z2Line collection with customized caps and joinstyle)r"   r#   r&   r'   r    r!   zerosr   r  r  r$   r%   )r)   r*   r   ZysZsegsZline_segmentsr,   r,   r-   test_cap_and_joinstyle_image|  s    (



r#  zscatter_post_alpha.png)r   stylec                  C   s6   t  \} }|jtdtdtdd}|d d S )NrS   r  rz   )r"   r#   ru   r   r   )r)   r*   scr,   r,   r-   test_scatter_post_alpha  s    r&  c                  C   s  t d} | d }td\}\}}|j| | | |d}|j| | | d}|| t  t| d d df | t| d d df | td\}\}}|j| | dddd	d
g|d}|j| | d|d}t  t| d d df | t| d d df | td\}\}}|j| | dddd	d
gd}|| |j| | dd}|| t  t| d d df | t| d d df | d S )NrS   r   )r   r   r  r   r   r   r   r   m)r   r   )r   )	r    r   r"   r#   ru   r   r  r   get_facecolors)r   r   r)   ax0ax1Zsc0Zsc1r,   r,   r-   test_scatter_alpha_array  s.    



r+  c                  C   s|  t jd t jdd\} }t jd}t jjdddd}t jjdddd}t \}}|j| |||dd	dd
}|jdd\}}t	|dkst
|dddddgkst
t dd |D }	|t dd }
t|	|
 |j||dd}|jdd\}}t	|dkst
|j||dd}|jdddd\}}tdd |D sHt
tdd |D s`t
|j||dd}|jddd d!d" d#\}}d$d |D }t t |td }t|| |j||d%d}tjjdd&ddd'd%dd(d&dgd)}|j|d\}}t	|t	|kst
d*dd+d,g}|j|ddd-\}}d.d |D |dd  ksPt
||||fD ]}|| q\|j  d S )/N!N,r   r   r   rS   )sizei,  Zjetr|   )r   scmapr~   r  z{x:g})fmt01234c                 S   s   g | ]}|  qS r,   )r8   .0liner,   r,   r-   
<listcomp>  s     z7test_pathcollection_legend_elements.<locals>.<listcomp>r   r   )locr   )numr   r   r
  )rU   r   r   c                 s   s   | ]}|  d kV  qdS )r   N)Z	get_alphar6  r,   r,   r-   	<genexpr>  s     z6test_pathcollection_legend_elements.<locals>.<genexpr>c                 s   s   | ]}|  d kV  qdS )r
  N)Zget_markerfacecolorr6  r,   r,   r-   r<    s     z{x:.2f}c                 S   s   d|  S )Nr   r,   )r   r,   r,   r-   <lambda>      z5test_pathcollection_legend_elements.<locals>.<lambda>)rU   r;  r0  funcc                 S   s   g | ]}|  qS r,   Zget_markersizer6  r,   r,   r-   r9    s     r   r   r!  r   )ZnbinsZmin_n_ticksZstepsr   g33333K@i  )r;  rU   r0  c                 S   s   g | ]}t |qS r,   )float)r7  lr,   r,   r-   r9    s     )r    randomseedZrandrandintr"   r#   ru   legend_elementsr   r4   r!   r/  r   r   Zlegendr  sqrtrA  r   mplZtickerZMaxNLocatorZ
add_artistcanvasr  )r   r   r   r.  r)   r*   r%  hrB  r   Zcolors2l1h2Zlab2l2l3ZactsizesZlabeledsizesl4r:  h5Zlab5levelsh6Zlab6r,   r,   r-   #test_pathcollection_legend_elements  sN    




 rS  c               	   C   s:   t ddddg} t| }t j| t ddddg d S )Nr   r   r   r   )r    r!   r   r1   r   )Zarrr(   r,   r,   r-   test_EventCollection_nosort  s    rT  c                  C   s  t jdt jdddd} t| }tt| }t|jt|jksFtt	|j|jD ]0\}}t 
|j|jsptt 
|j|jsTtqTt jdtd}dd | D |d d < t|}t|jt|jkstt	|j|jD ]0\}}t 
|j|jstt 
|j|jstqd S )Nr   )Zdtyper   r   r   c                 S   s   g | ]}t d d |D qS )c                 s   s   | ]}t |V  qd S rd   tuple)r7  r   r,   r,   r-   r<    s     z=test_collection_set_verts_array.<locals>.<listcomp>.<genexpr>rU  r7  r   r,   r,   r-   r9    s     z3test_collection_set_verts_array.<locals>.<listcomp>)r    r   doubler   r	   r   r   Z_pathsr4   r   array_equalZ	_vertices_codesemptyobject)ZvertsZcol_arrZcol_listZaplpZverts_tupleZcol_arr_tupleZatpr,   r,   r-   test_collection_set_verts_array  s    r^  c               	   C   sb   t d} t }||  tjtdd |d W 5 Q R X d| d< t| | 	 s^t
d S )Nr   z^Image data of dtyper  Zwrong_input-   rS   )r   r   r   r  r  	TypeErrorr    	not_equal	get_arrayanyr4   )valsr   r,   r,   r-   test_collection_set_array  s    

re  c                  C   s   dddg} d}t t | dt d|gt| g}|t| ddg}t \}}t	|j
|j}|t||d |jddd	 t j| d
dg d S )Nr   r   r   皙?r   r   TF)ZscalexZscaleyr   r   )r    column_stackrepeattiler   r   r"   r#   rh   Zblended_transform_factoryr   	transAxesr$   r   r   r1   assert_allcloseget_xlim)ar   Zxy_pairsZ	line_segsfr*   r   r,   r,   r-   test_blended_collection_autolim  s    
&ro  c                  C   sH   t  \} }|dd tj| ddg tj| ddg d S )Nr   gQgQ?)r"   r#   ru   r    r1   rk  get_ylimrl  )r)   r*   r,   r,   r-   test_singleton_autolim  s    rq  ztransform, expected)r   )r   g      @)rj  )gffffff@g	@c                 C   sV   t  \}}|jddt|| d |dd tj| | tj| | d S )Nr   r   r   )	r"   r#   ru   getattrr    r1   rk  rp  rl  )r   rW   r)   r*   r,   r,   r-   test_autolim_with_zeros$  s
    	rs  c               	   C   s  t d} t d}t jd}t \}}|| ||}tjtt	
dd ||dd W 5 Q R X t dd	}tjtt	
d
d || W 5 Q R X tjtt	
dd ||  W 5 Q R X t d}tjtt	
dd || W 5 Q R X t d}tjtt	
dd || W 5 Q R X t d}tjtt	
dd || W 5 Q R X t d} t d}t jd}t \}}|j| ||dd}d S )Nr  r   )   r   zuFor X (11) and Y (8) with flat shading, A should have shape (7, 10, 3) or (7, 10, 4) or (7, 10) or (70,), not (10, 7)r  r   rt  6   )r   r   ztFor X (11) and Y (8) with flat shading, A should have shape (7, 10, 3) or (7, 10, 4) or (7, 10) or (70,), not (6, 9)zsFor X (11) and Y (8) with flat shading, A should have shape (7, 10, 3) or (7, 10, 4) or (7, 10) or (70,), not (54,))r   r   r   zwFor X (11) and Y (8) with flat shading, A should have shape (7, 10, 3) or (7, 10, 4) or (7, 10) or (70,), not (9, 6, 3))r   r   r   zwFor X (11) and Y (8) with flat shading, A should have shape (7, 10, 3) or (7, 10, 4) or (7, 10) or (70,), not (9, 6, 4))rt  r   r   zxFor X (11) and Y (8) with flat shading, A should have shape (7, 10, 3) or (7, 10, 4) or (7, 10) or (70,), not (7, 10, 2)gouraudZshading)r    r   rC  r"   r#   r   r  r  r^   reescaper   r   r   r   r   r   r   r)   r*   r(   r,   r,   r-   "test_quadmesh_set_array_validation4  sL    


















r{  c                  C   sd   dddg} dddg}t jdd}t | |\}}t|||}t |j|jgj}t| | d S )Nr   r   r   r   r   )r   r   )r   )	r    r   r   r"   r   stackr   r   Zget_coordinates)r   r   r   r   r   r(   r  r,   r,   r-   test_quadmesh_get_coordinatesd  s    

r}  c                  C   s<  t d} t d}t dd}t \}}|| |t |j}|| |j	
  t | |snt|t d |j	
  t | t dstt dd}t \}}|j| |t |jdd}|| |j	
  t | |st|t d |j	
  t | t ds8td S )Nr   r   r      )r   r   rv  rw  )r    r   r   r"   r#   r   r   r   r   rI  r  rY  rb  r4   rz  r,   r,   r-   test_quadmesh_set_arrayp  s(    







r  c                  C   s   t  \} }tjd }tjjddd}|jdgg||d}| j  t	
| dd d f ||dsltd\|_|_| j  t	
| dd d f ||dstd S )NZplasmar   r   )vminvmax)r/  norm)r   r   )r"   r#   rH  Z	colormapsr   Z	Normalizer   rI  r  r    rY  r(  r4   r  r  )r)   r*   r/  r  r(   r,   r,   r-   test_quadmesh_vmin_vmax  s    

(
r  c            
      C   s,  t d} t d}t dd}||  }| }td\}\}}|j| |||d}|| ||}	|	| t	  t
| d d df | t
|	 d d df | td\}\}}|j| |||d}|| ||}	|	| t	  t
| d d df | t
|	 d d df | d S )Nr   r   r   r   )r   r   )r    r   r   maxr   r"   r#   r   r   r  r   r(  )
r   r   r   r   Z
alpha_flatr)   r)  r*  Zcoll1Zcoll2r,   r,   r-   test_quadmesh_alpha_array  s&    



r  c               	   C   sV   t  \} }|tdd}tjtdd |	ddg |
  W 5 Q R X d S )Nr  )r   r   z^Data array shaper  r   333333?)r"   r#   r   r    r   r   r  r  r^   r   update_scalarmappable)r)   r*   pcr,   r,   r-   test_alpha_validation  s
    r  c                  C   s   t jd t jd} t jd}dt jd }d| }ddddg}t \}}|j| ||d	}|jd
|dd d\}}	dd |D }
dd |
D }
t|
|dd dS )z|
    Ensure legend markers scale appropriately when label and size are
    inversely related.
    Here label = 5 / size
    r,  2   r   rS   rf  g?r  g?r.  r   c                 S   s   d|  S )NrS   r,   r  r,   r,   r-   r=    r>  z=test_legend_inverse_size_label_relationship.<locals>.<lambda>)rU   r;  r?  c                 S   s   g | ]}|  qS r,   r@  rW  r,   r,   r-   r9    s     z?test_legend_inverse_size_label_relationship.<locals>.<listcomp>c                 S   s   g | ]}d |d  qS )rS   r   r,   rW  r,   r,   r-   r9    s     r   N)r    rC  rD  r"   r#   ru   rF  r   )r   r   CSZlegend_sizesr)   r*   r%  ZhandleslabelsZhandle_sizesr,   r,   r-   +test_legend_inverse_size_label_relationship  s       
r  pcfuncc                 C   s  t ddd}| |ddd}|  t| }| ||	 }t
| ds`t| |}|d |d |  t
| dstt
| ddddggst|d	 |  t
| dddd	ggst|d  |  t
| ddddggst|d  |  t
| |s@t|d  |  t
| |shtt
| ds~t|d  |  t
| dstt
| |st||	  |  t
| |stt
| dst| |d
dd}|  t
| |s*tt
| ddddggsJt| |d
t dd}|  t
| |s|tt
| ddddggst|d  |  t
| t dstt
| ddddggst| |d
t dd}|  t
| |stt
| ddddggs<t|d  |  t
| t dsjtt
| ddddggstd S )Nr  r   r   r
  r[   )r  r   r   r   r   )r   r   r   )r   r   r   )r  r   )r  r   )r    r   r   r  mcolorsZto_rgba_arrayZ_get_default_facecolorZget_cmapr  r   
same_colorget_edgecolorr4   Zset_facecolorZset_edgecolorget_facecolorr   r   r   )r  r   r  Zface_defaultZmappedr,   r,   r-   test_color_logic  sj    



 


  
  
r  c               	   C   s   t d dddddddgd} |  d dks.tt|  dsBt|  dksRtt|  ddddggsptt d d d} t|  dstd S )	Ng@r   r   r   r   )r   Z	edgecolorZzorderr   )Z	facecolorr[   )r   Zget_linewidthr4   r  r  r  Z
get_zorderr  )lcr,   r,   r-   test_LineCollection_args   s     
r  c               	   C   s   t ddd} t| }tjtdd ||  |	  W 5 Q R X t
| }||  |	  t dddd} ||  d S )Nr  r   r   z^Collections can only mapr  $   )r    r   r   r"   pcolorr  r  r^   r   r  r   )r   r  r,   r,   r-   test_array_wrong_dimensions.  s    



r  c                  C   sB   t t ddddj} t| g}| \}t | |ks>td S )Nr   r      )r   r   )r    ri  r   r   r   r\   r  r4   )r`   r  Zreadbackr,   r,   r-   test_get_segments<  s    

r  c                  C   s~   t  } dg}tj|d}tj|dd}tj|d}|d || j}|| j}|| j}||ksnt||ksztd S )Nr   )r   r  )r   r   )rh   ri   re   ZCircleCollectionset_offsetsrg   rw   r4   )identityr   rl   initlateZnull_boundsZinit_boundsZlate_boundsr,   r,   r-   test_set_offsets_lateE  s    
r  c                  C   sT   t  dd} tj| d}t }||  | |   krJ| ksPn td S )Nr   )r   )rh   r   skewre   r   Zset_offset_transformZget_offset_transformr4   )r  r  r  r,   r,   r-   test_set_offset_transformZ  s
    
r  c                  C   s   t ddd} t | }| t dd t d }t||}| }|t	t
|| t j||  t \}}|||}| }|t	t
|| t j||  d S )Nr   r   rS      rJ  z
2021-11-29)r    r   r   Ztimedelta64Z
datetime64r"   ru   get_offsetsr  r   r   r1   rk  r#   )r   r   dr%  Zoff0r)   r*   r,   r,   r-   test_set_offset_unitsd  s    
r  test_check_masked_offsets)Zbaseline_imagesry   r   r$  c                  C   s   t ddddddt ddddddt ddddddt dddddd	t dddddd
g} tjjdddddgdddddgd}t \}}|| | d S )Ni  r  rL   r   1   4   5   ru  7   8   r   r   r   rS   r   mask)r   r    mar!   r"   r#   ru   )Z
unmasked_xZmasked_yr)   r*   r,   r,   r-   r  x  s    $c                 C   s   t jjdddddgdddddgd}t dd}| }|||}|t j||g |g  |	g  |  }|dddgdddg |g  |	g  d S 	Nr   r   r   r   rS   r   r  r   )
r    r  r!   r   Zadd_subplotru   r  rg  Z
set_xticksZ
set_yticks)r   r   r   r   r   scatr   r,   r,   r-   test_masked_set_offsets  s    $


r  c                  C   s   t jjdddddgdddddgd} t dd}t \}}|| |}t j| |g}|| t	|
 t|sxtt | |g}|| t	|
 t|std S r  )r    r  r!   r   r"   r#   ru   rg  r  
isinstancer  typer4   )r   r   r)   r*   r  Zmasked_offsetsZunmasked_offsetsr,   r,   r-   test_check_offsets_dtype  s    $

r  )hr   r   rx  typesr   Znumpyr    Znumpy.testingr   r   r  Z
matplotlibrH  Zmatplotlib.pyplotZpyplotr"   Zmatplotlib.collectionscollectionsre   Zmatplotlib.colorsr   r  Zmatplotlib.pathpathrq   Zmatplotlib.transformsZ
transformsrh   r   r   r   r	   Zmatplotlib.testing.decoratorsr
   r   r.   r;   rA   rD   rE   rF   rI   rJ   rK   rN   rP   rX   rZ   r0   rn   rs   rx   r$  contextr   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r   r#  r&  r+  rS  rT  r^  re  ro  rq  markZparametrizers  r{  r}  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r,   r,   r,   r-   <module>   s   (











	



$










 
1
0	
D	
  


