a
    =Df9                  
   @  s  U d Z ddlmZ ddlZeeZddlmZm	Z	m
Z
 ddlmZmZ ddlmZmZ ddlmZmZmZmZmZmZ dd	lmZmZ erd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Z$ere
e	e% e	e&e%e%f  e	e&e%e%e%f  f Z'de(d< dAddddddZ)dBdddddddZ*dCdd ddd!d!d"dd#d$d%Z+dDdd ddd&d"dd'd(d)Z,dEdd*ddd&dd+d,d-Z-dFdd*ddd&dd.d/d0Z.dGdddd2ddd3d4d5Z/dHdd ddd!d!d"dd#d6d7Z0dIdd ddd!d!d"dd#d8d9Z1ddd:d;d<Z2dd=dd>d?d@Z3dS )Jz Helper functions for applying client-side computations such as
transformations to data fields or ``ColumnDataSource`` expressions.

    )annotationsN)TYPE_CHECKINGSequenceUnion   )ExprField)CumSumStack)CategoricalColorMapperCategoricalMarkerMapperCategoricalPatternMapperEqHistColorMapperLinearColorMapperLogColorMapper)DodgeJitter)	TypeAlias)	ColorLike)JitterRandomDistributionType)Range)	Transform)cumsumdodgeeqhist_cmapfactor_cmapfactor_hatchfactor_markjitterlinear_cmaplog_cmapstack	transformr   FactorsFstrboolr   )
field_nameinclude_zeroreturnc                 C  s   t t| |dS )a+   Create a ``DataSpec`` dict to generate a ``CumSum`` expression
    for a ``ColumnDataSource``.

    Args:
        field_name (str) : a field name to configure ``CumSum`` with

        include_zero (bool, optional) : whether to include zero in the sum
            (default: False)

    Examples:

        .. code-block:: python

            p.wedge(start_angle=cumsum('angle', include_zero=True),
                    end_angle=cumsum('angle'),
                    ...)

        will generate a ``CumSum`` expressions that sum the ``"angle"`` column
        of a data source. For the ``start_angle`` value, the cumulative sums
        will start with a zero value. For ``end_angle``, no initial zero will
        be added (i.e. the sums will start with the first angle value, and
        include the last).

    )fieldr'   )r   r	   )r&   r'    r*   \/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/bokeh/transform.pyr   I   s    r   floatzRange | Noner   )r&   valueranger(   c                 C  s   t | t||dS )a   Create a ``DataSpec`` dict that applies a client-side ``Dodge``
    transformation to a ``ColumnDataSource`` column.

    Args:
        field_name (str) : a field name to configure ``DataSpec`` with

        value (float) : the fixed offset to add to column data

        range (Range, optional) : a range to use for computing synthetic
            coordinates when necessary, e.g. a ``FactorRange`` when the
            column data is categorical (default: None)

    Returns:
        Field

    )r-   r.   )r   r   )r&   r-   r.   r*   r*   r+   r   d   s    r   grayzSequence[ColorLike]zColorLike | Noner   )r&   palettelowhigh	low_color
high_color	nan_colorr(   c              
   C  s   t | t||||||dS )ag   Create a ``DataSpec`` dict that applies a client-side
    ``EqHistColorMapper`` transformation to a ``ColumnDataSource`` column.

    Args:
        field_name (str) : a field name to configure ``DataSpec`` with

        palette (seq[color]) : a list of colors to use for colormapping

        low (float) : a minimum value of the range to map into the palette.
            Values below this are clamped to ``low``.

        high (float) : a maximum value of the range to map into the palette.
            Values above this are clamped to ``high``.

        low_color (color, optional) : color to be used if data is lower than
            ``low`` value. If None, values lower than ``low`` are mapped to the
            first color in the palette. (default: None)

        high_color (color, optional) : color to be used if data is higher than
            ``high`` value. If None, values higher than ``high`` are mapped to
            the last color in the palette. (default: None)

        nan_color (color, optional) : a default color to use when mapping data
            from a column does not succeed (default: "gray")

    r0   r1   r2   r5   r3   r4   )r   r   r&   r0   r1   r2   r3   r4   r5   r*   r*   r+   r   w   s    #r   zfloat | None)r&   r0   factorsstartendr5   r(   c              	   C  s   t | t|||||dS )aT   Create a ``DataSpec`` dict that applies a client-side
    ``CategoricalColorMapper`` transformation to a ``ColumnDataSource``
    column.

    Args:
        field_name (str) : a field name to configure ``DataSpec`` with

        palette (seq[color]) : a list of colors to use for colormapping

        factors (seq) : a sequence of categorical factors corresponding to
            the palette

        start (int, optional) : a start slice index to apply when the column
            data has factors with multiple levels. (default: 0)

        end (int, optional) : an end slice index to apply when the column
            data has factors with multiple levels. (default: None)

        nan_color (color, optional) : a default color to use when mapping data
            from a column does not succeed (default: "gray")

    Returns:
        Field

    )r0   r8   r9   r:   r5   )r   r   )r&   r0   r8   r9   r:   r5   r*   r*   r+   r      s    !r   zSequence[str])r&   patternsr8   r9   r:   r(   c                 C  s   t | t||||dS )a   Create a ``DataSpec`` dict that applies a client-side
    ``CategoricalPatternMapper`` transformation to a ``ColumnDataSource``
    column.

    Args:
        field_name (str) : a field name to configure ``DataSpec`` with

        patterns (seq[string]) : a list of hatch patterns to use to map to

        factors (seq) : a sequences of categorical factors corresponding to
            the palette

        start (int, optional) : a start slice index to apply when the column
            data has factors with multiple levels. (default: 0)

        end (int, optional) : an end slice index to apply when the column
            data has factors with multiple levels. (default: None)

    Returns:
        Field

    Added in version 1.1.1

    )r;   r8   r9   r:   )r   r   )r&   r;   r8   r9   r:   r*   r*   r+   r      s    r   )r&   markersr8   r9   r:   r(   c                 C  s   t | t||||dS )aG   Create a ``DataSpec`` dict that applies a client-side
    ``CategoricalMarkerMapper`` transformation to a ``ColumnDataSource``
    column.

    .. note::
        This transform is primarily only useful with ``scatter``, which
        can be parameterized by glyph type.

    Args:
        field_name (str) : a field name to configure ``DataSpec`` with

        markers (seq[string]) : a list of markers to use to map to

        factors (seq) : a sequences of categorical factors corresponding to
            the palette

        start (int, optional) : a start slice index to apply when the column
            data has factors with multiple levels. (default: 0)

        end (int, optional) : an end slice index to apply when the column
            data has factors with multiple levels. (default: None)

    Returns:
        Field

    )r<   r8   r9   r:   )r   r   )r&   r<   r8   r9   r:   r*   r*   r+   r      s    !r   uniformr   )r&   widthmeandistributionr.   r(   c                 C  s   t | t||||dS )a   Create a ``DataSpec`` dict that applies a client-side ``Jitter``
    transformation to a ``ColumnDataSource`` column.

    Args:
        field_name (str) : a field name to configure ``DataSpec`` with

        width (float) : the width of the random distribution to apply

        mean (float, optional) : an offset to apply (default: 0)

        distribution (str, optional) : ``"uniform"`` or ``"normal"``
            (default: ``"uniform"``)

        range (Range, optional) : a range to use for computing synthetic
            coordinates when necessary, e.g. a ``FactorRange`` when the
            column data is categorical (default: None)

    Returns:
        Field

    )r?   r>   r@   r.   )r   r   )r&   r>   r?   r@   r.   r*   r*   r+   r   &  s    r   c              
   C  s   t | t||||||dS )ag   Create a ``DataSpec`` dict that applies a client-side
    ``LinearColorMapper`` transformation to a ``ColumnDataSource`` column.

    Args:
        field_name (str) : a field name to configure ``DataSpec`` with

        palette (seq[color]) : a list of colors to use for colormapping

        low (float) : a minimum value of the range to map into the palette.
            Values below this are clamped to ``low``.

        high (float) : a maximum value of the range to map into the palette.
            Values above this are clamped to ``high``.

        low_color (color, optional) : color to be used if data is lower than
            ``low`` value. If None, values lower than ``low`` are mapped to the
            first color in the palette. (default: None)

        high_color (color, optional) : color to be used if data is higher than
            ``high`` value. If None, values higher than ``high`` are mapped to
            the last color in the palette. (default: None)

        nan_color (color, optional) : a default color to use when mapping data
            from a column does not succeed (default: "gray")

    r6   )r   r   r7   r*   r*   r+   r   L  s    #r   c              
   C  s   t | t||||||dS )ad   Create a ``DataSpec`` dict that applies a client-side ``LogColorMapper``
    transformation to a ``ColumnDataSource`` column.

    Args:
        field_name (str) : a field name to configure ``DataSpec`` with

        palette (seq[color]) : a list of colors to use for colormapping

        low (float) : a minimum value of the range to map into the palette.
            Values below this are clamped to ``low``.

        high (float) : a maximum value of the range to map into the palette.
            Values above this are clamped to ``high``.

        low_color (color, optional) : color to be used if data is lower than
            ``low`` value. If None, values lower than ``low`` are mapped to the
            first color in the palette. (default: None)

        high_color (color, optional) : color to be used if data is higher than
            ``high`` value. If None, values higher than ``high`` are mapped to
            the last color in the palette. (default: None)

        nan_color (color, optional) : a default color to use when mapping data
            from a column does not succeed (default: "gray")

    r6   )r   r   r7   r*   r*   r+   r    {  s    #r    )fieldsr(   c                  G  s   t t| dS )a   Create a Create a ``DataSpec`` dict to generate a ``Stack`` expression
    for a ``ColumnDataSource``.

    Examples:

        .. code-block:: python

            p.vbar(bottom=stack("sales", "marketing"), ...

        will generate a ``Stack`` that sums the ``"sales"`` and ``"marketing"``
        columns of a data source, and use those values as the ``top``
        coordinate for a ``VBar``.

    rA   )r   r
   rB   r*   r*   r+   r!     s    r!   r   )r&   r"   r(   c                 C  s
   t | |S )a.   Create a ``DataSpec`` dict that applies an arbitrary client-side
    ``Transform`` to a ``ColumnDataSource`` column.

    Args:
        field_name (str) : A field name to configure ``DataSpec`` with

        transform (Transform) : A transforms to apply to that field

    Returns:
        Field

    )r   )r&   r"   r*   r*   r+   r"     s    r"   )F)N)NNr/   )r   Nr/   )r   N)r   N)r   r=   N)NNr/   )NNr/   )4__doc__
__future__r   logging	getLogger__name__logtypingr   r   r   Zcore.property.vectorizationr   r   Zmodels.expressionsr	   r
   Zmodels.mappersr   r   r   r   r   r   Zmodels.transformsr   r   Ztyping_extensionsr   colorsr   Z
core.enumsr   Zmodels.rangesr   r   __all__r$   tupler#   __annotations__r   r   r   r   r   r   r   r   r    r!   r"   r*   r*   r*   r+   <module>   s^   
 4   3   0  -  .   +   4   /