
    I.e$                        d 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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mZmZmZmZmZ  eej                            e d
d                    Z!i Z"	 ddZ#ddZ$ddZ%ddZ& G d d          Z' e'            Z( e(             d Z)ej*        +                    e)           eZ,d Z-dS )u  
hvPlot makes data analysis and visualization simple
===================================================

hvPlot provides a familiar, high-level API for interactive data exploration and visualization,
based on the Pandas `.plot` API and the innovative `.interactive` API.

hvPlot

- supports a wide range of data sources including Pandas, Dask, XArray
Rapids cuDF, Streamz, Intake, Geopandas, NetworkX and Ibis.
- supports the plotting backends Bokeh (default), Matplotlib and Plotly.
- exposes the powerful tools from the HoloViz ecosystem in a familiar and convenient API, while
letting you drop down into the underlying HoloViz tools when more power or flexibility is needed.

hvPlot is the recommend entrypoint to the HoloViz ecosystem.

To learn more check out https://hvplot.holoviz.org/. To report issues or contribute go to
https://github.com/holoviz/hvplot. To join the community go to
https://discourse.holoviz.org/.

How to use hvPlot in 3 simple steps
-----------------------------------

Work with the data source you already know and ❤️

>>> import pandas as pd, numpy as np
>>> idx = pd.date_range('1/1/2000', periods=1000)
>>> df  = pd.DataFrame(np.random.randn(1000, 4), index=idx, columns=list('ABCD')).cumsum()

Import the hvplot extension for your data source and optionally set the plotting backend

>>> import hvplot.pandas
>>> # hvplot.extension('matplotlib')

Use the `.hvplot` API as you would use the Pandas `.plot` API.

>>> df.hvplot()

In a Jupyter Notebook, this will display a line plot of the A, B, C and D time series.

For more check out the user guide https://hvplot.holoviz.org/user_guide/index.html

How to get help
---------------

To see the available arguments for a specific `kind` of plot run

>>> import hvplot
>>> hvplot.help(kind='scatter')

In a notebook or ipython environment the usual

- `help` and `?` will provide you with documentation.
- `TAB` and `SHIFT+TAB` completion will help you navigate.

To ask the community go to https://discourse.holoviz.org/.
To report issues go to https://github.com/holoviz/holoviews.
    N)Storerender   )HoloViewsConverterInteractive)explorer)hvplot_extensionoutputsaveshow)hvPlothvPlotTabularandrews_curveslag_plotparallel_coordinatesscatter_matrixplotz$Format:%h$hvplot)fpatharchive_commitreponameFTc                 ,   t           }t          | |          }|j                            |g           }	|j        |         }
d}|rd}|r|r|dz  }|dz  }|r|r|dz  }|dz  }t
          j        pt          j        }|
t          j	        |         v r%t          j	        |         |
         j
        }|r|dz  }ng }dd                    t          |                    z   }g }t          j        j                            ||	z   |j        z   |j        z             }|pt'          j        |          }t+          |j                                                  dd          D ],\  }}|j        dk    r|                    ||j        f           -d	 |j                                        D             fd
|D             }|z   t'          j        dt&          j        j                  gz   }t'          j        |          }|d |D             z  }d                    d |D                       }t?          j         |j!                  }tD                              ||j!                  }|tD          |<   |#                    ||t?          j         |          ||          }||fS )N zhvplot.{kind}({completions})
z{docstring}z	{options}z
{style}zStyle options
-------------

r   c                 F    g | ]}|j         t          j        j        k    |S  )kindinspect	ParameterVAR_KEYWORD.0ps     /lib/python3.11/site-packages/hvplot/__init__.py
<listcomp>z*_get_doc_and_signature.<locals>.<listcomp>{   s7     H H H v):)FFF FFF    c                 t    g | ]4}|d  D             vt          j        |t           j        j                  5S )c                     g | ]	}|j         
S r   )namer"   s     r%   r&   z5_get_doc_and_signature.<locals>.<listcomp>.<listcomp>   s     D D DA D D Dr'   )r   r    KEYWORD_ONLY)r#   kfiltered_signatures     r%   r&   z*_get_doc_and_signature.<locals>.<listcomp>}   sT     F F F D D1C D D DDD %a):)GHHDDDr'   kwargsc                     g | ]}|d fS Nr   )r#   os     r%   r&   z*_get_doc_and_signature.<locals>.<listcomp>   s    333At9333r'   z, c                 "    g | ]\  }}| d | S )=r   )r#   nvs      r%   r&   z*_get_doc_and_signature.<locals>.<listcomp>   s&    ???DAqZZAZZ???r'   )r   completions	docstringoptionsstyle)$r   getattr_kind_optionsget_kind_mappingr
   compatibilityr   current_backendregistry
style_optsjoinsorted_hvcoreutilunique_iterator_axis_options_op_optionsr   	signaturelist
parametersitemsr   appenddefaultvaluesr    r!   	Signaturetextwrapdedent__doc___METHOD_DOCSformat)clsr   r6   r7   genericr9   rJ   	convertermethod	kind_optseltype	formatterbackend
valid_optsrA   rL   extra_kwargssigr*   r$   extra_params
all_paramsr8   
method_docr-   s                           @r%   _get_doc_and_signaturere   R   s    #IS$F'++D"55I$T*FI 32	 # 	I]"	 ! 	I[ 	 ,E0EG(((^G,V4?
 	%$I
3diiz@R@R6S6SSJJ8=00Y!889;PP L 
0w(00C,,..//3 1 1a6Q;;tQY/000H HS^%:%:%<%< H H HF F F F)F F FL %|3(73D3PQQRSJ!*--I33l3333J))??J???@@Koi/00G!!$77J#L  {hoj6Q6Qz ! + +I ir'   c                 \    t          t          | |||          \  }}t          |           dS )a  
    Provide a docstring with all valid options which apply to the plot
    type.

    Parameters
    ----------
    kind: str
        The kind of plot to provide help for
    docstring: boolean (default=True)
        Whether to display the docstring
    generic: boolean (default=True)
        Whether to provide list of generic options
    style: boolean (default=True)
        Whether to provide list of style options
    )rW   r   r7   rX   r9   N)re   r   print)r   r7   rX   r9   docra   s         r%   helpri      s:      &&t097RWY Y YHC	#JJJJJr'   bokehc                 j    | r.t          t          j        dd          st          | |           d S d S d S )N_loadedF)logo)r:   rD   	extensionr
   )rn   rm   s     r%   
post_patchro      sL     /	5AA /....../ / / /r'   c                 n    t          | |          }t          | |d|          \  }}||_        ||_        d S )NFrJ   )r:   re   rT   __signature__)rW   r   rJ   rZ   r7   s        r%   
_patch_docrs      sA    S$F1#tUiXXXIyFN$Fr'   c                       e Zd Zd Zd ZdS )_PatchHvplotDocstringsc                     i }t           t          fD ]L}t          j        D ]=}t	          ||          r+t          ||          }t          j        |          }||||f<   >M|| _        d S r0   )	r   r   r   r=   hasattrr:   r   rJ   orig_signatures)self
signaturesrW   _kindrZ   ra   s         r%   __init__z_PatchHvplotDocstrings.__init__   s     
M* 	3 	3C+9 3 33&& 3$S%00F!+F33C/2JU|,	3
  *r'   c                     t           t          fD ]B}t          j        D ]3}t	          ||          r!| j        ||f         }t          |||           4Cd S )Nrq   )r   r   r   r=   rw   rx   rs   )ry   rW   r{   rJ   s       r%   __call__z_PatchHvplotDocstrings.__call__   sx    M* 	@ 	@C+9 @ @3&& @ $ 4c5\ BIsEY????@	@ 	@r'   N)__name__
__module____qualname__r|   r~   r   r'   r%   ru   ru      s7        
* 
* 
*@ @ @ @ @r'   ru   c                 &    ddl m}  |             d S )Nr   )_patch_hvplot_docstrings)r   r   )r^   r   s     r%   _hook_patch_docstringsr      s+     +*****r'   c                 F    t          j        | g|R i |fd_        S )a  
    Returns a *reactive* function that can be used to start your `.interactive` pipeline by running
    a model or loading data depending on inputs from widgets, parameters or python objects.

    The widgets can be Panel or ipywidgets.

    Reference: https://hvplot.holoviz.org/user_guide/Interactive.html#functions-as-inputs

    Parameters
    ----------
    function : callable
        The function to bind constant or dynamic args and kwargs to.
    args : object, param.Parameter, panel.widget.Widget, or ipywidget
        Positional arguments to bind to the function.
    kwargs : object, param.Parameter, panel.widget.Widget, or ipywidget
        Keyword arguments to bind to the function.

    Returns
    -------
    Returns a new function with the args and kwargs bound to it and
    annotated with all dependencies. This function has an `interactive`
    attribute that can be called to instantiate an `Interactive` pipeline.

    Examples
    --------

    Develop your **algorithm** or data extraction method with the tools you know and love.

    >>> import pandas as pd
    >>> import numpy as np

    >>> def algorithm(alpha):
    ...     # An example algorithm that uses alpha ...
    ...     return pd.DataFrame({"output": (np.array(range(0,100)) ** alpha)*50})

    Make it **interactive** using `.bind`, `.interactive` and widgets.

    >>> import hvplot
    >>> import panel as pn

    >>> alpha = pn.widgets.FloatSlider(value=0.5, start=0, end=1.0, step=0.1, name="Alpha")
    >>> top = pn.widgets.RadioButtonGroup(value=10, options=[5, 10, 25], name="Top")
    >>> interactive_table = (
    ...     hvplot
    ...     .bind(algorithm, alpha=alpha)
    ...     .interactive()
    ...     .head(n=top)
    ... )
    >>> interactive_table

    In a notebook or data app you can now select the appropriate `alpha` and `top` values via
    widgets and see the `top` results of the algorithm in a table depending on the value of `alpha`
    selected.
    c                      t          fi | S r0   r   )r.   bounds    r%   <lambda>zbind.<locals>.<lambda>  s    U)E)Ef)E)E r'   )_pnbindinteractive)functionargsr.   r   s      @r%   r   r      s;    n HX//////EEEEEELr'   )FTTTN)NTTT)rj   Fr0   ).rT   r   rR   parampanelr   	holoviewsrD   r   r   rY   r   r   r   uir	   	utilitiesr
   r   r   r   plottingr   r   r   r   r   r   r   strversionVersion__file____version__rU   re   ri   ro   rs   ru   r   r   _backend_switch_hooksrN   rn   r   r   r'   r%   <module>r      sL  : :v            # # # # # # # # ) ) ) ) ) ) $ $ $ $ $ $       ; ; ; ; ; ; ; ; ; ; ; ;C C C C C C C C C C C C C C C C C C c%-''h}19 ( ; ; < <  W[:  :  :  : z   */ / / /
% % % %@ @ @ @ @ @ @ @, 2133           " "#9 : : :	9 9 9 9 9r'   