
    e7                         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
mZmZ ddlmZmZ  G d d	e          Z G d
 de          Z G d de          ZdS )    N)	NdOverlay)AbbreviatedException)HoloMap)ContoursPathPolygons   )TestMPLPlotmpl_rendererc                   &    e Zd Zd Zd Zd Zd ZdS )TestPathPlotc                    g d}|d d d         }g d}|||d}g d}g d}t          |gd                              d||	          }t          j        |          }|j        d
         }	|                     t          j        |	                                          t          j	        |                     |                     |	
                                d           d S )Nr	            )    r     )xycolor)r   &   I   _   n         r   )z#5ebaffz#00faf4z#ffffccz#ffe775z#ffc140z#ff8f20z#ff6060r   vdims)r   color_levelscmapartist)r   r   )r   optsr   get_plothandlesassertEqualnpasarray	get_arrayarrayget_clim)
selfxsysr   datalevelscolorspathplotr$   s
             Qlib/python3.11/site-packages/holoviews/tests/plotting/matplotlib/test_pathplot.py'test_path_continuously_varying_color_opz4TestPathPlot.test_path_continuously_varying_color_op   s    \\"X$$$b511444^^^TF'***//V 0 = =$T**h'F$4$4$6$677%III**J77777    c                    g d}|d d d         }g d}|||d}t          |gd                              d          }d}t          j        t          |	          5  t          j        |           d d d            d S # 1 swxY w Y   d S )
Nr   r   )g?ffffff?333333?g?)r   r   alphar<   r    r<   4ValueError: Mapping a dimension to the "alpha" stylematch)r   r%   pytestraisesr   r   r&   )r.   r/   r0   r<   r1   r4   msgs          r6   'test_path_continuously_varying_alpha_opz4TestPathPlot.test_path_continuously_varying_alpha_op   s    \\"X$$$b511TF'***//g/>>D]/s;;; 	( 	(!$'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   A??BBc                    g d}|d d d         }g d}|||d}t          |gd                              d          }t          j        |          }|j        d         }|                     |                                |           d S )	Nr   r   r	      r   r   r   r   
line_widthrI   r    	linewidthr$   )r   r%   r   r&   r'   r(   get_linewidths)r.   r/   r0   rI   r1   r4   r5   r$   s           r6   ,test_path_continuously_varying_line_width_opz9TestPathPlot.test_path_continuously_varying_line_width_op&   s    \\"X!\\
b
;;TF,///44|4LL$T**h'..00*=====r8   c           	         g d}|d d d         }t          t          ||g ddgd          t          ||g ddgd          d                              d	          }t          j        |          }|j        d
         }|                     |                                g d           |                    d           |                     |                                g d           d S )Nr   r   rF   rH   rI   r    )r      r   r   r   r	   rJ   r$   r	   )	r   r   r%   r   r&   r'   r(   rL   update)r.   r/   r0   r4   r5   r$   s         r6   3test_path_continuously_varying_line_width_op_updatez@TestPathPlot.test_path_continuously_varying_line_width_op_update0   s   \\"X2BlllCCDLYYY2BlllCCDLYYY
 
   4,4'' 	 $T**h'..00,,,???D..00,,,?????r8   N)__name__
__module____qualname__r7   rD   rM   rS    r8   r6   r   r      sU        8 8 8( ( (> > >@ @ @ @ @r8   r   c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )TestPolygonPlotc                    t          d t          d          D                       }t          j        |          }t	          |j                                                  D ]\  }}|j        d         }|                     t          j
        |                                          t          j        |g                     |                     |                                d           d S )Nc           	      h    i | ].t          fd t          d          D             gd          /S )c                      g | ]
}|z  |fS rW   rW   ).0ijs     r6   
<listcomp>zDTestPolygonPlot.test_polygons_colored.<locals>.<dictcomp>.<listcomp>A   s#    +L+L+LQQT1aL+L+L+Lr8   
   Valuer    )r   range)r]   r_   s    @r6   
<dictcomp>z9TestPolygonPlot.test_polygons_colored.<locals>.<dictcomp>A   sW     1 1 1"#  +L+L+L+L%))+L+L+L*MU\!]!]!] 1 1 1r8      r$   )r   r   )r   rc   r   r&   	enumeratesubplotsvaluesr'   r(   r)   r*   r+   r,   r-   )r.   polygonsr5   r_   splotr$   s         r6   test_polygons_coloredz%TestPolygonPlot.test_polygons_colored@   s     1 1',Qxx1 1 1 2 2$X..!$-"6"6"8"899 	8 	8HAu]8,FRZ(8(8(:(:;;RXqc]]KKKV__..7777	8 	8r8   c                    g d}g d}g dg dgg}t          |||dg          }t          j        |          }|j        d         }|                                }|                     t          |          d           |d         }|                     |j        t          j	        g d	                     |                     |j
        t          j	        g d
                     d S )N)r	   r   r   )r   r   rG   g      ?r   r   r   皙?rq   g @g      @g      @re   gffffff@g      @)r   r   holesr$   r	   r   r	   r   )r   r   r   rG   rx   rn   ro   rp   rn   rs   rt   ru   rs   r	   r   r   O   r	   r   r   r{   r	   r   r   r{   )r   r   r&   r'   	get_pathsr(   lenverticesr)   r,   codes)	r.   r/   r0   rv   polyr5   r$   pathsr4   s	            r6   test_polygon_with_hole_plotz+TestPolygonPlot.test_polygon_with_hole_plotI   s	   YYYY0002T2T2TUVrU;;<==$T**h'  ""UQ'''Qx 2D 2D 2D )E )E 	
 	
 	
 	RX.U.U.U%V%VWWWWWr8   c                 z   dddt           j        dddg}dddt           j        dddg}g dg d	gg g}t          |||dd
gdg          }t          j        |          }|j        d         }|                     t          j        |                                          t          j	        ddg                     |
                                }|                     t          |          d           |d         }|                     |j        t          j	        g d                     |                     |j        t          j	        g d                     |d         }	|                     |	j        t          j	        g d                     |                     |	j        t          j	        g d                     d S )Nr	   r   r   rG      r   re   rm   rr   )r   r   rv   valuer   r    r$   rw   rz   )r   r   )rG   re   )r   rG   r   )r	   r   r   r{   )r)   nanr   r   r&   r'   r(   r*   r+   r,   r|   r}   r~   r   )
r.   r/   r0   rv   r   r5   r$   r   r4   path2s
             r6   test_multi_polygon_hole_plotz,TestPolygonPlot.test_multi_polygon_hole_plotY   s   Arvq!Q'Arvq!Q'+++-O-O-OP
 rUQGGHQXPYZZZ$T**h'F$4$4$6$6771a&9I9IJJJ  ""UQ'''Qx 2D 2D 2D )E )E 	
 	
 	
 	RX.U.U.U%V%VWWWa2R2R2R)S)STTTbh}}}&=&=>>>>>r8   c                 .   t          g dddg dddgd                              d          }t          j        |          }|j        d	         }t          j        g d
g dg          }|                     |                                |           d S N)r   r   rP   r	   r   greenr   r   r   r   )r	   r	   rP   redr   r    r   r$   )        3ۃ?r         ?)r   r   r   r   )	r   r%   r   r&   r'   r)   r,   r(   get_facecolorsr.   ri   r5   r$   r3   s        r6   test_polygons_color_opz&TestPolygonPlot.test_polygons_color_opp       111GDD111EBB
    $W$-- 	 $X..h'444///1 2 2..00&99999r8   c           	      2   t          t          g dddg dddgd          t          g dddg dddgd          d	                              d
          }t          j        |          }|j        d         }t          j        g dg dg          }|                     |	                                |           |
                    d           t          j        g dg dg          }|                     |	                                |           d S Nr   r   r   r   r   r   r    bluerP   r   r$   )r   r   r   r	   )r	   r   r   r	   rQ   )r   r   r	   r	   )r   r   r%   r   r&   r'   r)   r,   r(   r   rR   r   s        r6   test_polygons_color_op_updatez-TestPolygonPlot.test_polygons_color_op_update{   r   555HH555FF    555GG555HH   	
 	
 	 	 4g4 	 $X..h'...'<<) * *..00&999D<<<...0 1 1..00&99999r8   c                    t          g dddg dddgd                              d          }t          j        |          }|j        d	         }|                     t          j        |                                          t          j	        ddg                     |                     |
                                d
           d S Nr   rG   r   r   r   r   r    r   r$   ry   r   r%   r   r&   r'   r(   r)   r*   r+   r,   r-   r.   ri   r5   r$   s       r6   test_polygons_linear_color_opz-TestPolygonPlot.test_polygons_linear_color_op       111A>>111A>>
    $W$-- 	 $X..h'F$4$4$6$6771a&9I9IJJJ**F33333r8   c           	         t          t          g dddg dddgd          t          g dddg dd	dgd          d
                              dd          }t          j        |          }|j        d         }|                     t          j        |	                                          t          j
        ddg                     |                     |                                d           |                    d           |                     t          j        |	                                          t          j
        dd	g                     |                     |                                d           d S Nr   rG   r   r   r   r   r    r   re   rP   T)r   	framewiser$   ry   rQ   )r   re   )r   r   r%   r   r&   r'   r(   r)   r*   r+   r,   r-   rR   r   s       r6   $test_polygons_linear_color_op_updatez4TestPolygonPlot.test_polygons_linear_color_op_update      555BB555BB    555BB555BB   	
 	
 	 	 4g4.. 	 $X..h'F$4$4$6$6771a&9I9IJJJ**F333DF$4$4$6$6771a&9I9IJJJ**F33333r8   c                    t          g dddg dddgd                              d          }t          j        |          }|j        d	         }|                     t          j        |                                          t          j	        d
dg                     |                     |
                                d           d S Nr   br   r   ar   r    r   r$   r   r	   rP   r   r   s       r6   "test_polygons_categorical_color_opz2TestPolygonPlot.test_polygons_categorical_color_op       111C@@111C@@
    $W$-- 	 $X..h'F$4$4$6$6771a&9I9IJJJ**F33333r8   c                     t          g dddg dddgd                              d          }d	}t          j        t          |
          5  t          j        |           d d d            d S # 1 swxY w Y   d S Nr   r:   )r   r<   r   r;   r<   r    r=   r>   r?   )r   r%   rA   rB   r   r   r&   )r.   ri   rC   s      r6   test_polygons_alpha_opz&TestPolygonPlot.test_polygons_alpha_op       111C@@111C@@
    $W$-- 	 E]/s;;; 	, 	,!(+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,   A11A58A5c                     t          g dddg dddgd                              d          }t          j        |          }|j        d	         }|                     |                                ddg           d S 
Nr   rG   r   rI   r   r   rI   r    rJ   r$   )r   r%   r   r&   r'   r(   rL   r   s       r6   test_polygons_line_width_opz+TestPolygonPlot.test_polygons_line_width_op       111CC111CC
     $tlt;; 	 $X..h'..001a&99999r8   N)rT   rU   rV   rk   r   r   r   r   r   r   r   r   r   rW   r8   r6   rY   rY   >   s        8 8 8X X X ? ? ?.	: 	: 	:: : :*4 4 44 4 4&4 4 4, , ,: : : : :r8   rY   c                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )TestContoursPlotc                    t          d dD             d                              d          }t          j        |          }|j        d         }|                     t          j        |                                          t          j	        g d                     |                     |
                                d           d S )	Nc                 T    g | ]%}t           j                            d d          |d&S )ra   r   )r   z)r)   randomrand)r]   cats     r6   r`   zDTestContoursPlot.test_contours_categorical_color.<locals>.<listcomp>   s@     1 1 1 ')innR&;&;#FF 1 1 1r8   )BAr   r   r    )color_indexr$   )r   r	   r   rP   r   r%   r   r&   r'   r(   r)   r*   r+   r,   r-   )r.   r4   r5   r$   s       r6   test_contours_categorical_colorz0TestContoursPlot.test_contours_categorical_color   s     1 1 /1 1 1  #tt44 	 $T**h'F$4$4$6$677)))9L9LMMM**F33333r8   c                 .   t          g dddg dddgd                              d          }t          j        |          }|j        d	         }t          j        g d
g dg          }|                     |                                |           d S r   )	r   r%   r   r&   r'   r)   r,   r(   get_edgecolorsr.   contoursr5   r$   r3   s        r6   test_contours_color_opz'TestContoursPlot.test_contours_color_op   r   r8   c           	      2   t          t          g dddg dddgd          t          g dddg dddgd          d	                              d
          }t          j        |          }|j        d         }t          j        g dg dg          }|                     |	                                |           |
                    d           t          j        g dg dg          }|                     |	                                |           d S r   )r   r   r%   r   r&   r'   r)   r,   r(   r   rR   r   s        r6   test_contours_color_op_updatez.TestContoursPlot.test_contours_color_op_update   r   r8   c                    t          g dddg dddgd                              d          }t          j        |          }|j        d	         }|                     t          j        |                                          t          j	        ddg                     |                     |
                                d
           d S r   r   r.   r   r5   r$   s       r6   test_contours_linear_color_opz.TestContoursPlot.test_contours_linear_color_op   r   r8   c           	         t          t          g dddg dddgd          t          g dddg dd	dgd          d
                              dd          }t          j        |          }|j        d         }|                     t          j        |	                                          t          j
        ddg                     |                     |                                d           |                    d           |                     t          j        |	                                          t          j
        dd	g                     |                     |                                d           d S r   )r   r   r%   r   r&   r'   r(   r)   r*   r+   r,   r-   rR   r   s       r6   $test_contours_linear_color_op_updatez5TestContoursPlot.test_contours_linear_color_op_update   r   r8   c                    t          g dddg dddgd                              d          }t          j        |          }|j        d	         }|                     t          j        |                                          t          j	        d
dg                     |                     |
                                d           d S r   r   r   s       r6   "test_contours_categorical_color_opz3TestContoursPlot.test_contours_categorical_color_op  r   r8   c                     t          g dddg dddgd                              d          }d	}t          j        t          |
          5  t          j        |           d d d            d S # 1 swxY w Y   d S r   )r   r%   rA   rB   r   r   r&   )r.   r   rC   s      r6   test_contours_alpha_opz'TestContoursPlot.test_contours_alpha_op  r   r   c                     t          g dddg dddgd                              d          }t          j        |          }|j        d	         }|                     |                                ddg           d S r   )r   r%   r   r&   r'   r(   rL   r   s       r6   test_contours_line_width_opz,TestContoursPlot.test_contours_line_width_op&  r   r8   c           	         t          t          g dddg dddgd          t          g dddg dd	dgd          d
                              dd          }t          j        |          }|j        d         }|                     |                                ddg           |                    d           |                     |                                dd	g           d S )Nr   rG   r   r   r   rI   r    r   re   rP   T)rK   r   r$   rQ   )	r   r   r%   r   r&   r'   r(   rL   rR   r   s       r6   "test_contours_line_width_op_updatez3TestContoursPlot.test_contours_line_width_op_update/  s1   555QGG555QGG "# # # 555QGG555QGG "# # #	
 	
 	 	 4,$477 	 $X..h'..001a&999D..001a&99999r8   N)rT   rU   rV   r   r   r   r   r   r   r   r   r   rW   r8   r6   r   r      s        4 4 4	: 	: 	:: : :*4 4 44 4 4&4 4 4, , ,: : :: : : : :r8   r   )numpyr)   rA   holoviews.corer   holoviews.core.optionsr   holoviews.core.spacesr   holoviews.elementr   r   r   	test_plotr
   r   r   rY   r   rW   r8   r6   <module>r      s*        $ $ $ $ $ $ 7 7 7 7 7 7 ) ) ) ) ) ) 6 6 6 6 6 6 6 6 6 6 0 0 0 0 0 0 0 0/@ /@ /@ /@ /@; /@ /@ /@dI: I: I: I: I:k I: I: I:Zs: s: s: s: s:{ s: s: s: s: s:r8   