
    e?                         d dl 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  G d
 de          ZdS )    N)AbbreviatedException)	NdOverlay)HoloMap)Points   )ParamLogStream   )TestMPLPlotmpl_rendererc                       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 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd 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 )'TestPointPlotc                    t          j        d          t          j        d          t          t          t          t          dd                              f}t          |dg                              d          }t                      5 }t          j
        |           d d d            n# 1 swxY w Y   |j                                        }d}|                     ||           d S )	N
   ^   h   zvdimsr   )
size_indexzThe `size_index` parameter is deprecated in favor of size style mapping, e.g. `size=dim('size')**2`.
z dimension is not numeric, cannot use to scale Points size.
)nparangelistmapchrranger   optsr   r   get_plotstreamreadassertEqual)selfdatapointsloglog_msgwarnings         Rlib/python3.11/site-packages/holoviews/tests/plotting/matplotlib/test_pointplot.py$test_points_non_numeric_size_warningz2TestPointPlot.test_points_non_numeric_size_warning   s   	"ry}}d3sE"SMM3J3J.K.KLSE***//1/== 	*!&)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	**//##e 	 	'*****s   B--B14B1c                    t          ddgddgf                              t          d                    }t          j        |                    dd                    }|                     |j        d	         j        d
           d S )Nr   r	      )r	   r   r   yTcolorbarcolor_indexcbarboth	r   redimdictr   r   r   r    handlesextendr!   imgplots      r'   test_points_cbar_extend_bothz*TestPointPlot.test_points_cbar_extend_both   s~    q!fq!f%&&,,t%/@/@/@,AA$SXXtX%K%KLLf-4f=====    c                    t          ddgddgf                              t          d                    }t          j        |                    dd                    }|                     |j        d	         j        d
           d S )Nr   r	   r*   )r	   Nr+   r,   Tr.   r1   minr3   r8   s      r'   test_points_cbar_extend_minz)TestPointPlot.test_points_cbar_extend_min!   ~    q!fq!f%&&,,t)/D/D/D,EE$SXXtX%K%KLLf-4e<<<<<r<   c                    t          ddgddgf                              t          d                    }t          j        |                    dd                    }|                     |j        d	         j        d
           d S )Nr   r	   r*   )Nr   r+   r,   Tr.   r1   maxr3   r8   s      r'   test_points_cbar_extend_maxz)TestPointPlot.test_points_cbar_extend_max&   r@   r<   c                     t          ddgddgf                              d          }t          j        |                    dd                    }|                     |j        d         j        d	           d S )
Nr   r	   r*   )NN)climTr.   r1   neither)r   r   r   r   r    r6   r7   r8   s      r'   test_points_cbar_extend_climz*TestPointPlot.test_points_cbar_extend_clim+   ss    q!fq!f%&&+++>>$SXXtX%K%KLLf-4i@@@@@r<   c                     t          ddi          } t          ddgddgf          j        di |}t          j        |           |                     t          j        d                    d S )Nztext.usetexTfig_rcparamsr   r	   r*    )r5   r   r   r   r   assertFalsepltrcParams)r!   r   r#   s      r'   #test_points_rcparams_do_not_persistz1TestPointPlot.test_points_rcparams_do_not_persist0   sv    -!6777.!Q!Q()).6666f%%%m455555r<   c                 :   t          ddi          } t          ddgddgf          j        di |}t          j        |          }|j        j        d         }|                                }|                     |d         	                                d           d S )Nz
grid.colorredrI   r   r	   r*   rK   )
r5   r   r   r   r   stateaxesget_xgridlinesr    	get_color)r!   r   r#   r:   axliness         r'   test_points_rcparams_usedz'TestPointPlot.test_points_rcparams_used6   s    ,!6777.!Q!Q()).6666$V,,Z_Q!!##q++--u55555r<   c                    t          g d                              d          }t          j        |          }|j        d                                         |j        d                                         }}|                     |d         d           |                     |d         d           |                     |d         d	           |                     |d         d
           d S )Nr	   r   r*   皙?paddingaxisr   皙ɿr	   皙@皙?皙	@r   r   r   r   r6   get_xlimget_ylimr    r!   r#   r:   x_rangey_ranges        r'   test_points_padding_squarez(TestPointPlot.test_points_padding_square>   s    			""'''44$V,,</88::DL<P<Y<Y<[<[T***S)))S)))S)))))r<   c                    t          g d                              d          }t          j        |          }|j        d                                         |j        d                                         }}|                     |d         d           |                     |d         d           |                     |d         d           |                     |d         d	           d S )
NrZ   ))r   r[   )r[   皙?r\   r^   r   r	   r`   ra   g333333@rc   )r!   curver:   rg   rh   s        r'   "test_curve_padding_square_per_axisz0TestPointPlot.test_curve_padding_square_per_axisG   s    yyy!!&&/E&FF$U++</88::DL<P<Y<Y<[<[Q'''S)))S)))S)))))r<   c                    t          g d          j                            d                              d          }t	          j        |          }|j        d                                         |j        d                                         }}| 	                    |d         d           | 	                    |d         d	           | 	                    |d         d
           | 	                    |d         d           d S NrZ   )r   r*   )xr[   r\   r^   r   r	   r*   ra   rb   )
r   r4   r   r   r   r   r6   rd   re   r    rf   s        r'   test_points_padding_hard_xrangez-TestPointPlot.test_points_padding_hard_xrangeP   s    			""(...88==c=JJ$V,,</88::DL<P<Y<Y<[<[Q'''Q'''S)))S)))))r<   c                    t          g d          j                            d                              d          }t	          j        |          }|j        d                                         |j        d                                         }}| 	                    |d         d           | 	                    |d         d	           | 	                    |d         d
           | 	                    |d         d           d S ro   )
r   r4   
soft_ranger   r   r   r6   rd   re   r    rf   s        r'   test_points_padding_soft_xrangez-TestPointPlot.test_points_padding_soft_xrangeY   s    			""(33f3==BB3BOO$V,,</88::DL<P<Y<Y<[<[Q'''Q'''S)))S)))))r<   c                    t          g d                              d          }t          j        |          }|j        d                                         |j        d                                         }}|                     |d         d           |                     |d         d           |                     |d         d	           |                     |d         d
           d S )NrZ   )g?r[   r\   r^   r   皙r	    @ra   rb   rc   rf   s        r'   test_points_padding_unequalz)TestPointPlot.test_points_padding_unequalb   s    			""'''<<$V,,</88::DL<P<Y<Y<[<[T***S)))S)))S)))))r<   c                    t          g d                              dd          }t          j        |          }|j        d                                         |j        d                                         }}|                     |d         d           |                     |d         d	           |                     |d         d
           |                     |d         d           d S )NrZ   r[   r   r]   aspectr^   r   rv   r	   rw   ra   rb   rc   rf   s        r'   test_points_padding_nonsquarez+TestPointPlot.test_points_padding_nonsquarek   s    			""''A'>>$V,,</88::DL<P<Y<Y<[<[T***S)))S)))S)))))r<   c                    t          g d                              dd          }t          j        |          }|j        d                                         |j        d                                         }}|                     |d         d           |                     |d         d	           |                     |d         d
           |                     |d         d           d S )N))r	   r	   )r   r   )r*   r*   r[   T)r]   logxr^   r   9r?r	   u
@ra   rb   rc   rf   s        r'   test_points_padding_logxz&TestPointPlot.test_points_padding_logxt   s    ///0055c5MM$V,,</88::DL<P<Y<Y<[<[%8999%7888S)))S)))))r<   c                    t          g d                              dd          }t          j        |          }|j        d                                         |j        d                                         }}|                     |d         d           |                     |d         d	           |                     |d         d
           |                     |d         d           d S )NrZ   r[   T)r]   logyr^   r   r_   r	   r`   r   r   rc   rf   s        r'   test_points_padding_logyz&TestPointPlot.test_points_padding_logy}   s    			""''$'??$V,,</88::DL<P<Y<Y<[<[T***S)))%8999%788888r<   c                     t          d t          dd          D                                           d          }t          j        |          }|j        d                                         |j        d                                         }}|                     |d         d           |                     |d         d	           |                     |d         d
           |                     |d         d           d S )Nc                 @    g | ]}t          j        d |z            |fS z2016-04-0%dr   
datetime64.0is     r'   
<listcomp>zETestPointPlot.test_points_padding_datetime_square.<locals>.<listcomp>   ,    TTT1"-(9::A>TTTr<   r	      r[   r\   r^   r   g3333~@ǧ@ra   rb   	r   r   r   r   r   r6   rd   re   r    rf   s        r'   #test_points_padding_datetime_squarez1TestPointPlot.test_points_padding_datetime_square   s    TTaQRTTTUUZZ [ 
 
 $V,,</88::DL<P<Y<Y<[<[W---W---S)))S)))))r<   c                    t          d t          dd          D                                           dd          }t          j        |          }|j        d                                         |j        d                                         }}|                     |d         d	           |                     |d         d
           |                     |d         d           |                     |d         d           d S )Nc                 @    g | ]}t          j        d |z            |fS r   r   r   s     r'   r   zHTestPointPlot.test_points_padding_datetime_nonsquare.<locals>.<listcomp>   r   r<   r	   r   r[   r   rz   r^   r   g~@gffff@ra   rb   r   rf   s        r'   &test_points_padding_datetime_nonsquarez4TestPointPlot.test_points_padding_datetime_nonsquare   s    TTaQRTTTUUZZ [ 
 
 $V,,</88::DL<P<Y<Y<[<[W---W---S)))S)))))r<   c                    t          d t          dd          D                       }t          j        |          }|j        d         }|                    d           |                     |                                t          j	        dg                     |                    d           |                     |                                t          j	        dg                     d S )	Nc                 `    i | ]+}|t          g d                               |dz            ,S )rZ   r   s)r   r   r   s     r'   
<dictcomp>zATestPointPlot.test_points_sizes_scalar_update.<locals>.<dictcomp>   s;    OOOa6))),,11AbD199OOOr<   r	   r*   artistr	   r   )r      )
r   r   r   r   r6   updater    	get_sizesr   array)r!   hmapr:   r   s       r'   test_points_sizes_scalar_updatez-TestPointPlot.test_points_sizes_scalar_update   s    OO5A;;OOOPP$T**h'D))++RXrd^^<<<D))++RXrd^^<<<<<r<   c           	         t          g dd                              d          }t          j        |          }|j        d         }|                     |                                t          j        g dg dg dg                     d S )	N)r   r   z#000000)r   r	   #FF0000)r   r   #00FF00colorr   r   r   r   r   r   r	   r	   r   r   r	   r   r	   r   r	   	r   r   r   r   r6   r    get_facecolorsr   r   r!   r#   r:   r   s       r'   test_point_color_opz!TestPointPlot.test_point_color_op   s    QQQ%' ' ''+t't':': 	$V,,h'..00<<<|||"LMM	O 	O 	O 	O 	Or<   c           	         t          t          g dd          t          g dd          d                              d          }t          j        |          }|j        d         }|                    d           |                     |                                t          j
        g d	g d
g dg                     d S )Nr   r   r   )r   r   z#0000FF)r   r	   r   )r   r   r   r   r	   r   r   r   r   r   r	   r	   r   r   )r   r   r   r   r   r6   r   r    r   r   r   r   s       r'   test_point_color_op_updatez(TestPointPlot.test_point_color_op_update   s    V$]$]$]*13 3 3#$]$]$]*13 3 34 4 5 5 6:TT5H5H 	 $V,,h'D..00<<<|||"LMM	O 	O 	O 	O 	Or<   c           	         t          g dd                              d          }t          j        |          }|j        d         }|                     |                                t          j        g dg dg dg                     d S )	Nr   r   r   
edgecolorsr   r   r   r   )	r   r   r   r   r6   r    get_edgecolorsr   r   r   s       r'   test_point_line_color_opz&TestPointPlot.test_point_line_color_op       QQQ%' ' ''+twt'?'? 	$V,,h'..00<<<|||"LMM	O 	O 	O 	O 	Or<   c           	         t          t          g dd          t          g dd          d                              d          }t          j        |          }|j        d         }|                    d           |                     |                                t          j
        g d	g d
g dg                     d S )Nr   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r6   r   r    r   r   r   r   s       r'   test_point_line_color_op_updatez-TestPointPlot.test_point_line_color_op_update   s    V$]$]$]*13 3 3#$]$]$]*13 3 34 4 5 5 6:TWT5M5M 	 $V,,h'D..00<<<|||"LMM	O 	O 	O 	O 	Or<   c           	         t          g dd                              d          }t          j        |          }|j        d         }|                     |                                t          j        g dg dg dg                     d S )	Nr   r   r   )
facecolorsr   r   r   r   r   r   s       r'   test_point_fill_color_opz&TestPointPlot.test_point_fill_color_op   r   r<   c                    t          g dd                              d          }t          j        |          }|j        d         }|                     t          j        |                                          t          j	        g d                     |                     |
                                d           d S )Nr   r   r   r   r	   r	   r   r   r   r   r   r   r   )r   r	   r   r   r   r   r   r   r   r6   r    r   asarray	get_arrayr   get_climr   s       r'   test_point_linear_color_opz(TestPointPlot.test_point_linear_color_op   s    999%' ' ''+t't':': 	$V,,h'F$4$4$6$677)))9L9LMMM**F33333r<   c                 @   t          t          g dd          t          g dd          d                              dd          }t          j        |          }|j        d         }|                     |                                d	           |                    d
           |                     t          j
        |                                          t          j        g d                     |                     |                                d           d S )Nr   r   r   )r   r         @)r   r	   r*   )r   r   333333?r   T)r   	framewiser   r   r   r   r*   r   )r   r*   )r   r   r   r   r   r6   r    r   r   r   r   r   r   r   s       r'   !test_point_linear_color_op_updatez/TestPointPlot.test_point_linear_color_op_update   s   V$E$E$E*13 3 3#$I$I$I*13 3 34 4 5 5 6:TSWT5X5X 	 $V,,h'**F333DF$4$4$6$677---9P9PQQQ**H55555r<   c                    t          g dd                              d          }t          j        |          }|j        d         }|                     t          j        |                                          t          j	        g d                     |                     |
                                d           d S )N)r   r   A)r   r	   B)r   r   r   r   r   r   r   )r   r	   r   r   r   r   s       r'   test_point_categorical_color_opz-TestPointPlot.test_point_categorical_color_op   s    ???%' ' ''+t't':': 	$V,,h'F$4$4$6$677)))9L9LMMM**F33333r<   c                    t          g dd                              dd          }t          j        |          }|j        d                                         }d |j        D             }|                     |dd	g           d S )
Nr   r   r   T)r   show_legendr^   c                 6    g | ]}|                                 S rK   get_textr   ls     r'   r   zHTestPointPlot.test_point_categorical_color_op_legend.<locals>.<listcomp>        999!999r<   r   r   r   r   r   r   r6   
get_legendtextsr    r!   r#   r:   leglegend_labelss        r'   &test_point_categorical_color_op_legendz4TestPointPlot.test_point_categorical_color_op_legend   s    ???%' ' ''+t'tt'L'L 	$V,,l6"--//99sy999c
33333r<   c                    t          g dd                              ddddd          }t          j        |          }|j        d	                                         }d
 |j        D             }|                     |ddg           d S )Nr   r   r   TzA pointzB point)r   r   )r   r   r   r^   c                 6    g | ]}|                                 S rK   r   r   s     r'   r   zTTestPointPlot.test_point_categorical_color_op_legend_with_labels.<locals>.<listcomp>   r   r<   r   r   s        r'   2test_point_categorical_color_op_legend_with_labelsz@TestPointPlot.test_point_categorical_color_op_legend_with_labels   s    ???wOOOTTtQZ;[;[ U ] ]$V,,l6"--//99sy999I(>?????r<   c                    t          g dd                              d          }t          j        |          }|j        d         }|                     |                                t          j        g d                     d S )N)r   r   r	   )r   r	   r   )r   r      sizer   r   r   r	   r   r   )	r   r   r   r   r6   r    r   r   r   r   s       r'   test_point_size_opz TestPointPlot.test_point_size_op  s    999$& & &&*dVdnn 	$V,,h'))++RXiii-@-@AAAAAr<   c                    t          t          g dd          t          g dd          d                              d          }t          j        |          }|j        d         }|                     |                                t          j	        g d                     |
                    d	           |                     |                                t          j	        g d
                     d S )N)r   r   r*   r   r   r   r   r   r   r   r   r*   r	   r   r   r   )r   r   r   r   r   r6   r    r   r   r   r   r   s       r'   test_point_size_op_updatez'TestPointPlot.test_point_size_op_update
  s    V$E$E$E*02 2 2#$I$I$I*02 2 23 3 4 4 59D6DNN 	 $V,,h'))++RXiii-@-@AAAD))++RXmmm-D-DEEEEEr<   c                     t          g dd                              d          }t          j        |          }|j        d         }|                     |                                g d           d S )Nr   
line_widthr   	linewidthr   r   )r   r   r   r   r6   r    get_linewidthsr   s       r'   test_point_line_width_opz&TestPointPlot.test_point_line_width_op  s|    999*, , ,,0D<D,H,H 	$V,,h'..00)))<<<<<r<   c                    t          t          g dd          t          g dd          d                              d          }t          j        |          }|j        d         }|                     |                                g d           |                    d	           |                     |                                g d
           d S )Nr   r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r6   r    r   r   r   s       r'   test_point_line_width_op_updatez-TestPointPlot.test_point_line_width_op_update  s    V$E$E$E*68 8 8#$I$I$I*68 8 89 9 : : ;?$$:V:V 	 $V,,h'..00)))<<<D..00---@@@@@r<   c                     t          g dd                              d          }d}t          j        t          |          5  t          j        |           d d d            d S # 1 swxY w Y   d S )N))r   r   circle)r   r	   triangle)r   r   squaremarkerr   r   z5ValueError: Mapping a dimension to the "marker" stylematchr   r   pytestraisesr   r   r   r!   r#   msgs      r'   test_point_marker_opz"TestPointPlot.test_point_marker_op'  s    PPP&( ( ((,H(=(= 	E]/s;;; 	* 	*!&)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*   A''A+.A+c                     t          g dd                              d          }d}t          j        t          |          5  t          j        |           d d d            d S # 1 swxY w Y   d S )N)r   )r   r	   rk   )r   r   gffffff?alphar   )r
  z4ValueError: Mapping a dimension to the "alpha" styler   r  r  s      r'   test_point_alpha_opz!TestPointPlot.test_point_alpha_op.  s    ===%' ' ''+t't':': 	D]/s;;; 	* 	*!&)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*r  c                    ddg}t          d t          |          D             d                              dd          }t          j        |          }t          |j                                        |          D ]\\  }}t          |j	        |j
                           }|                    |j        i |          }|                     |d         |           ]d S )Ndr   c                 X    i | ]'\  }}|t          t          j        |                    (S rK   )r   r   r   )r   r   r   s      r'   r   z9TestPointPlot.test_op_ndoverlay_value.<locals>.<dictcomp>7  sD     B B B!*F $VBIaLL%9%9 B B Br<   Markerr   r   r   )r   	enumerater   r   r   zipsubplotsvaluesr5   stylecyclic_index_apply_transformscurrent_framer    )r!   markersoverlayr:   subplotr   r  s          r'   test_op_ndoverlay_valuez%TestPointPlot.test_op_ndoverlay_value5  s    * B B.7.@.@B B B$& &&*d8Hd&E&E 	 $W--"4=#7#7#9#97CC 	6 	6OGVw';<==E--g.CROOEU8_f5555	6 	6r<   c                 ,   t          g dd                              dd          }t                      5 }t          j        |           d d d            n# 1 swxY w Y   |j                                        }d}|                     ||           d S )Nr   r   r   )r   r0   zThe `color_index` parameter is deprecated in favor of color style mapping, e.g. `color=dim('color')` or `line_color=dim('color')`
Cannot declare style mapping for 'color' option and declare a color_index; ignoring the color_index.
r   r   r   r   r   r   r   r    r!   r#   r$   r%   r&   s        r'   "test_point_color_index_color_clashz0TestPointPlot.test_point_color_index_color_clash@  s    999%' ' ''+t'wt'O'O 	 	*!&)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	**//##X 	
 	'*****   AAAc                 ,   t          g dd                              dd          }t                      5 }t          j        |           d d d            n# 1 swxY w Y   |j                                        }d}|                     ||           d S )Nr   r   r   )r   r   zThe `size_index` parameter is deprecated in favor of size style mapping, e.g. `size=dim('size')**2`.
Cannot declare style mapping for 's' option and declare a size_index; ignoring the size_index.
r  r  s        r'    test_point_size_index_size_clashz.TestPointPlot.test_point_size_index_size_clashM  s    999$& & &&*dVd&G&G 	 	*!&)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	**//##5 	
 	'*****r   N)(__name__
__module____qualname__r(   r;   r?   rC   rG   rO   rX   ri   rm   rq   rt   rx   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"  rK   r<   r'   r   r      s]       
+ 
+ 
+> > >
= = =
= = =
A A A
6 6 66 6 6* * ** * ** * ** * ** * ** * ** * *9 9 9	* 	* 	*	* 	* 	*= = =O O O	O 	O 	OO O O	O 	O 	OO O O4 4 4
6 
6 
64 4 44 4 4@ @ @B B B	F 	F 	F= = =	A 	A 	A* * ** * *	6 	6 	6+ + ++ + + + +r<   r   )matplotlib.pyplotpyplotrM   numpyr   r  holoviews.core.optionsr   holoviews.core.overlayr   holoviews.core.spacesr   holoviews.elementr   utilsr   	test_plotr
   r   r   rK   r<   r'   <module>r/     s               7 7 7 7 7 7 , , , , , , ) ) ) ) ) ) $ $ $ $ $ $ " " " " " " 0 0 0 0 0 0 0 0J+ J+ J+ J+ J+K J+ J+ J+ J+ J+r<   