
    ]e(                     8   d dl Z d dlmZ d dlZd dlZd dlZd dl	Zd dl
Zd dlZd dlmZ d dlmZmZ ej        Zej                            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 )    N)dedent)penguins)hvDataFrameExplorerhvGridExplorerair_temperaturec                      t          j        t                    } t          | t                    sJ | j        dk    sJ | j        dk    sJ | j        dk    sJ d S Nscatterindexspecies)hvplotexplorerdf
isinstancer   kindxyr   s    3lib/python3.11/site-packages/hvplot/tests/testui.pytest_explorer_basicr      sg    r""Hh 344444=I%%%%:    :""""""    c                      t          j        t                    } | j                            dddgdg           |                                 }|t          dgdddg          k    sJ d S )Nr
   bill_length_mmbill_depth_mmr   r   r   y_multiby)r   r   r   r   )r   r   r   paramupdatesettingsdict)r   r    s     r   test_explorer_settingsr"      s    r""HN
 !;	       ""Ht;

	        r   c                      t          j        t                    } | j                            dddgdg           |                                 }|dk    sJ |                     d          }|d	k    sJ d S )
Nr
   r   r   r   r   zdf.hvplot(
    by=['species'],
    kind='scatter',
    x='bill_length_mm',
    y=['bill_depth_mm'],
    legend='bottom_right',
    widget_location='bottom',
)	othername)var_namezothername.hvplot(
    by=['species'],
    kind='scatter',
    x='bill_length_mm',
    y=['bill_depth_mm'],
    legend='bottom_right',
    widget_location='bottom',
))r   r   r   r   r   	plot_code)r   hvplot_codes     r   test_explorer_plot_coder(   0   s    r""HN
 !;	     $$&&K 			
 		
 		
 		
 $$k$::K 			
 		
 		
 		
 		
 		
r   c                  4   t          j        t                    } | j                            dddg           |                                  }t          |t          j                  sJ |j        d         j	        dk    sJ |j
        d         j	        dk    sJ d S )Nr
   r   r   r   r   r   r   )r   r   r   r   r   r   hvScatterkdimsnamevdims)r   plots     r   test_explorer_hvplotr1   Y   s    r""HN
 !     ??DdBJ''''':a=!11111:a=000000r   c                     t          j        t                    }|j                            dddg           | dz  }|                    |           |                                sJ d S )Nr
   r   r   r*   z	plot.html)r   r   r   r   r   saveexists)tmp_pathr   outfiles      r   test_explorer_saver7   i   sv    r""HN
 !     $GMM'>>r   c                      t          j        t          dd          } | j        j        dk    sJ | j        j        dk    sJ d S )NDummy title   )titlewidth)r   r   r   labelsr;   axesr<   r   s    r   test_explorer_kwargs_controlsr?   y   sJ    rcBBBH? M1111=#%%%%%%r   c                      t          j        t          t          j        d                    5  t          j        t          dd            d d d            d S # 1 swxY w Y   d S )NzU__init__() got keyword(s) not supported by any control: {'not_a_control_kwarg': None})matchr9   )r;   not_a_control_kwarg)pytestraises	TypeErrorreescaper   r   r    r   r   1test_explorer_kwargs_controls_error_not_supportedrI      s    	ic
 

 
 
 K K 	-TJJJJK K K K K K K K K K K K K K K K K Ks   AAAc                  ,   t          j        t                    } t          | t                    sJ t          | j        t          j                  sJ | j        dk    sJ | j	        dk    sJ | j
        dk    sJ | j        g k    sJ | j        dgk    sJ d S )Nimagelatlontime)r   r   ds_air_temperaturer   r   _dataxr	DataArrayr   r   r   r   groupbyr   s    r   "test_explorer_hvplot_gridded_basicrT      s    122Hh/////hnbl33333=G####::;"x''''''r   c                  V   t                               d          } t          j        |           }t	          |t
                    sJ t	          |j        t          j                  sJ |j	        dk    sJ |j
        dk    sJ |j        dk    sJ |j        g k    sJ |j        g k    sJ d S )Nr   )rN   rK   rL   rM   )rO   iselr   r   r   r   rP   rQ   rR   r   r   r   r   rS   dsr   s     r   test_explorer_hvplot_gridded_2drY      s    		 	 a	 	(	(Br""Hh/////hnbl33333=G####::;"r!!!!!!r   c                     t                                           } | d         dz  | d<   t          j        |           }t	          |t
                    sJ t	          |j        t          j                  sJ t          |j        d                   ddgk    sJ |j
        dk    sJ |j        dk    sJ |j        dk    sJ |j        g k    sJ |j        ddgk    sJ d S )	Nair   airx2variablerK   rL   rM   rN   )rO   copyr   r   r   r   rP   rQ   rR   listr   r   r   r   rS   rW   s     r   *test_explorer_hvplot_gridded_two_variablesra      s    		 	 	"	"BU)a-BwKr""Hh/////hnbl33333z*++w/?????=G####::;"
3333333r   c                  <   t           d         } t          j        |           }t          |t                    sJ t          |j        t          j                  sJ |j        dk    sJ |j	        dk    sJ |j
        dk    sJ |j        g k    sJ |j        dgk    sJ d S )Nr[   rK   rL   rM   rN   )rO   r   r   r   r   rP   rQ   rR   r   r   r   r   rS   )dar   s     r   &test_explorer_hvplot_gridded_dataarrayrd      s    	E	"Br""Hh/////hnbl33333=G####::;"x''''''r   c                      t          j        t                    } | j        d         j                                        h dk    sJ d S )Nr   >   geomgridded	dataframe)r   r   rO   	_controlsgroupskeysr   s    r   $test_explorer_hvplot_gridded_optionsrl      sG    122Ha ',,..2R2R2RRRRRRRr   c                  6   t          j        d           t          j        dgdgd          } t	          j        | ddd          }|j        j        sJ |j        j        sJ |j        j	        d	gk    sJ |j        j
        d
k    sJ |j        j        d
k    sJ d S )NgeoviewsgufBbgyuRA)r   r   r   Tpoints)r   geor   	coastlineGOOGLE_MERCATOR)rC   importorskippd	DataFramer   r   
geographicrp   global_extentfeaturescrs
projection)r   r   s     r   test_explorer_hvplot_geor{      s    

###	./7H6IJJ	K	KBrSdBBBH"""",,,,'K=8888"&77777)->>>>>>>r   c                      t          j        t                    } | j        j        du sJ t          j        t          d          } | j        j        J d|                                 vsJ d S )NTF)live_updater}   )r   r   r   	statusbarr}   _hv_paneobjectr    r   s    r   test_explorer_live_update_initr      sq    r""H)T1111ru555H#+++ 1 1 3 3333333r   c                     t          j        t                    } | j        j        j        t          j        u sJ d| _        | j        j        j        t          j	        u sJ d| j
        _        d| _        | j        j        j        t          j	        u sJ d| j        vsJ d| j
        _        | j        j        j        t          j        u sJ d| j        v sJ d S )NlineFr
   T)r   r   r   r   r   typer+   r,   r   Curver~   r}   coder   s    r   $test_explorer_live_update_after_initr      s    r""H#(BJ6666HM#(BH4444%*H"HM#(BH4444HM))))%)H"#(BJ6666%%%%%%r   c                      t           j                                        } t          | t                    sJ | j        dk    sJ | j        dk    sJ | j        dk    sJ d S r	   r   r   r   r   r   r   r   r   r   s    r   test_explorer_method_dataframer      sk    y!!##Hh 344444=I%%%%:    :""""""r   c                      t           j                                        } t          | t                    sJ | j        dk    sJ | j        dk    sJ | j        dk    sJ d S )NrK   rL   rM   )rO   r   r   r   r   r   r   r   r   s    r   test_explorer_method_gridr      sk    !(1133Hh/////=G####::r   c                      t           j                            d          } t          | t                    sJ | j        dk    sJ | j        dk    sJ | j        dk    sJ d S )Nr
   r   r   r   r   r   s    r   test_explorer_method_kindr      sp    y!!y!11Hh 344444=I%%%%:    :""""""r   c                      t                               d          } t          | t                    sJ | j        dk    sJ | j        dk    sJ | j        dk    sJ d S )Nr   r   r
   r   r   )r   r   r   r   r   r   r   r   s    r   test_explorer_method_as_kindr     sk    yyjy))Hh 344444=I%%%%:    :""""""r   c                      t           j                            dd          } t          | t                    sJ | j        dk    sJ | j        dk    sJ | j        dk    sJ | j        j	        dk    sJ d S )Nr9   r   )r;   r   r
   r   )
r   r   r   r   r   r   r   r   r=   r;   r   s    r   &test_explorer_method_propagates_kwargsr     s    y!!9I!JJHh 344444=I%%%%:))))):""""? M111111r   c                      t          j        t          dd          } | j        t	          d          k    sJ | j        j        t	          d          k    sJ d S )Nr   ro   )r   r   z        df.hvplot(
            kind='points',
            x='bill_length_mm',
            y='species',
            legend='bottom_right',
            widget_location='bottom',
        )z        ```python
        df.hvplot(
            kind='points',
            x='bill_length_mm',
            y='species',
            legend='bottom_right',
            widget_location='bottom',
        )
        ```)r   r   r   r   r   
_code_paner   r   s    r   test_explorer_code_dataframer     s}    r%5HEEEH=F $       % 	1 
* 
* 
 
 
 
 
 
r   c                      t          j        t          ddd          } | j        }|t	          d          k    sJ | j        j        t	          d          k    sJ d S )NrM   rL   rK   r   r   r   z        ds['air'].hvplot(
            colorbar=True,
            groupby=['time'],
            kind='image',
            x='lon',
            y='lat',
            legend='bottom_right',
            widget_location='bottom',
        )a          ```python
        ds['air'].hvplot(
            colorbar=True,
            groupby=['time'],
            kind='image',
            x='lon',
            y='lat',
            legend='bottom_right',
            widget_location='bottom',
        )
        ```)r   r   rO   r   r   r   r   )r   r   s     r   test_explorer_code_griddedr   .  s    1Ue'RRRH=D6 	 	 	 	 	 	 	 % 1 * *      r   c                      t           d         } t          j        | ddd          }|j        }|t	          d          k    sJ |j        j        t	          d          k    sJ d S )Nr[   rM   rL   rK   r   z        da.hvplot(
            colorbar=True,
            groupby=['time'],
            kind='image',
            x='lon',
            y='lat',
            legend='bottom_right',
            widget_location='bottom',
        )a           ```python
        da.hvplot(
            colorbar=True,
            groupby=['time'],
            kind='image',
            x='lon',
            y='lat',
            legend='bottom_right',
            widget_location='bottom',
        )
        ```rO   r   r   r   r   r   r   rc   r   r   s      r   $test_explorer_code_gridded_dataarrayr   K  s    	E	"BrUe'BBBH=D6 	 	 	 	 	 	 	 % 1 * *      r   c                      t           d         } t          j        | dddddi          }|j        }|t	          d          k    sJ |j        j        t	          d	          k    sJ d S )
Nr[   rM   rL   rK   color_levels   )r   r   r   optsa          da.hvplot(
            colorbar=True,
            groupby=['time'],
            kind='image',
            x='lon',
            y='lat',
            legend='bottom_right',
            widget_location='bottom',
        ).opts(
            color_levels=3,
        )a,          ```python
        da.hvplot(
            colorbar=True,
            groupby=['time'],
            kind='image',
            x='lon',
            y='lat',
            legend='bottom_right',
            widget_location='bottom',
        ).opts(
            color_levels=3,
        )
        ```r   r   s      r   test_explorer_code_optsr   i  s    	E	"BrUe'YZH[\\\H=D6        % 1 * *      r   )/rF   textwrapr   	holoviewsr+   pandasrt   hvplot.pandasr   hvplot.xarrayxarrayrQ   rC   bokeh.sampledatar   	hvplot.uir   r   datar   tutorialopen_datasetrO   r   r"   r(   r1   r7   r?   rI   rT   rY   ra   rd   rl   r{   r   r   r   r   r   r   r   r   r   r   r   rH   r   r   <module>r      s&   				                            % % % % % % 9 9 9 9 9 9 9 9][--.?@@ # # #  (& & &R1 1 1    & & &K K K	( 	( 	(
" 
" 
"4 4 4
( 
( 
(S S S
? ? ?4 4 4& & & # # #  # # ## # #2 2 2  0  :  <    r   