
    -e5%                    >   d Z ddlmZ ddlZ ej        e          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mZmZmZmZmZmZmZmZmZ dd	lmZ d
Ze G d de                      Z G d de          Z G d de          Z  G d de          Z!e G d de                      Z" G d de"          Z# G d de"          Z$e G d de                      Z% G d de%          Z&e G d de                      Z' G d d e'          Z( G d! d"e'          Z)dS )#ag   Represent array expressions to be computed on the client (browser) side
by BokehJS.

Expression models are useful as ``DataSpec`` values when it is desired that
the array values be computed in the browser:

.. code-block:: python

    p.circle(x={'expr': some_expression}, ...)

or using the ``expr`` convenience function:

.. code-block:: python

    from bokeh.core.properties import expr

    p.circle(x=expr(some_expression), ...)

In this case, the values of the ``x`` coordinates will be computed in the
browser by the JavaScript implementation of ``some_expression`` using a
``ColumnDataSource`` as input.

    )annotationsN)inf   )	Direction)abstract)	AngleSpecAnyRefBoolDictEnumFloatInstanceNullable
NumberSpecRequiredSeqStringfield)Model)CumSumCustomJSExpr
ExpressionPolarTransformStackc                  $     e Zd ZdZd fdZ xZS )r   a   Base class for ``Expression`` models that represent a computation
    to be carried out on the client-side.

    JavaScript implementations should implement the following methods:

    .. code-block

        v_compute(source: ColumnarDataSource): Arrayable {
            # compute and return array of values
        }

    .. note::
        If you wish for results to be cached per source and updated only if
        the source changes, implement ``_v_compute: (source)`` instead.

    returnNonec                :     t                      j        |i | d S Nsuper__init__selfargskwargs	__class__s      8lib/python3.11/site-packages/bokeh/models/expressions.pyr"   zExpression.__init__f   %    $)&)))))    r   r   __name__
__module____qualname____doc__r"   __classcell__r'   s   @r(   r   r   R   sG         $* * * * * * * * * *r*   r   c                  Z     e Zd ZdZd
 fdZ eeed          Z edd	          Z	 xZ
S )r   a`   Evaluate a JavaScript function/generator.

    .. warning::
        The explicit purpose of this Bokeh Model is to embed *raw JavaScript
        code* for a browser to execute. If any part of the code is derived
        from untrusted user inputs, then you must take appropriate care to
        sanitize the user input prior to passing to Bokeh.

    r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zCustomJSExpr.__init__v   r)   r*   a  
    A mapping of names to Python objects. In particular those can be bokeh's models.
    These objects are made available to the callback's code snippet as the values of
    named parameters to the callback. There is no need to manually include the data
    source of the associated glyph renderer, as it is available within the scope of
    the code via `this` keyword (e.g. `this.data` will give access to raw data).
    help a  
    A snippet of JavaScript code to execute in the browser. The code is made into
    the body of a generator function, and all of of the named objects in ``args``
    are available as parameters that the code can use. One can either return an
    array-like object (array, typed array, nd-array), an iterable (which will
    be converted to an array) or a scalar value (which will be converted into
    an array of an appropriate length), or alternatively yield values that will
    be collected into an array.
    defaultr6   r+   )r-   r.   r/   r0   r"   r   r   r	   r%   coder1   r2   s   @r(   r   r   j   s{         * * * * * * 4 & 	 	 	D 6" $ 	 	 	DDDDDr*   r   c                  X     e Zd ZdZd
 fdZ eed          Z edd	          Z	 xZ
S )r   zs An expression for generating arrays by cumulatively summing a single
    column from a ``ColumnDataSource``.

    r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zCumSum.__init__   r)   r*   zW
    The name of a ``ColumnDataSource`` column to cumulatively sum for new values.
    r5   Fa  
    Whether to include zero at the start of the result. Note that the length
    of the result is always the same as the input column. Therefore if this
    property is True, then the last value of the column will not be included
    in the sum.

    .. code-block:: python

        source = ColumnDataSource(data=dict(foo=[1, 2, 3, 4]))

        CumSum(field='foo')
        # -> [1, 3, 6, 10]

        CumSum(field='foo', include_zero=True)
        # -> [0, 1, 3, 6]

    r8   r+   )r-   r.   r/   r0   r"   r   r   r   r
   include_zeror1   r2   s   @r(   r   r      sy         * * * * * * HV # 	 	 	E 4 - 	 	 	LLLLLr*   r   c                  @     e Zd ZdZd fdZ eeg d          Z xZS )r   z An expression for generating arrays by summing different columns from
    a ``ColumnDataSource``.

    This expression is useful for implementing stacked bar charts at a low
    level.

    r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zStack.__init__   r)   r*   a=  
    A sequence of fields from a ``ColumnDataSource`` to sum (elementwise). For
    example:

    .. code-block:: python

        Stack(fields=['sales', 'marketing'])

    Will compute an array of values (in the browser) by adding the elements
    of the ``'sales'`` and ``'marketing'`` columns of a data source.
    r8   r+   )	r-   r.   r/   r0   r"   r   r   fieldsr1   r2   s   @r(   r   r      s\         * * * * * * S 
+ 
	 
	 
	FFFFFr*   r   c                  $     e Zd ZdZd fdZ xZS )ScalarExpressionz( Base class for for scalar expressions. r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zScalarExpression.__init__   r)   r*   r+   r,   r2   s   @r(   rB   rB      sC        22* * * * * * * * * *r*   rB   c                  T     e Zd ZdZd fdZ ee          Z ee	e
          Z xZS )Minimumz3 Computes minimum value of a data source's column. r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zMinimum.__init__   r)   r*   r9   r+   r-   r.   r/   r0   r"   r   r   r   r   r   r   initialr1   r2   s   @r(   rE   rE      s\        ==* * * * * * HVEhuc***GGGGGr*   rE   c                  V     e Zd ZdZd fdZ ee          Z ee	e
           Z xZS )Maximumz3 Computes maximum value of a data source's column. r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zMaximum.__init__   r)   r*   rG   r+   rH   r2   s   @r(   rK   rK      s^        ==* * * * * * HVEhusd+++GGGGGr*   rK   c                  P     e Zd ZdZd fdZed             Zed             Z xZS )CoordinateTransformz' Base class for coordinate transforms. r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zCoordinateTransform.__init__   r)   r*   c                "    t          |           S N)	transform)
XComponentr$   s    r(   xzCoordinateTransform.x       D))))r*   c                "    t          |           S rQ   )
YComponentrT   s    r(   yzCoordinateTransform.y   rV   r*   r+   )	r-   r.   r/   r0   r"   propertyrU   rY   r1   r2   s   @r(   rN   rN      sy        11* * * * * * * * X* * * X* * * * *r*   rN   c                       e Zd ZdZd fdZ e ed          d          Z e ed          d	          Z	 e
eej        d
          Z xZS )r   z0 Transform from polar to cartesian coordinates. r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zPolarTransform.__init__   r)   r*   radiusz
    The radial coordinate (i.e. the distance from the origin).

    Negative radius is allowed, which is equivalent to using positive radius
    and changing ``direction`` to the opposite value.
    r8   anglezJ
    The angular coordinate (i.e. the angle from the reference axis).
    zY
    Whether ``angle`` measures clockwise or anti-clockwise from the reference axis.
    r+   )r-   r.   r/   r0   r"   r   r   r]   r   r^   r   r   	anticlock	directionr1   r2   s   @r(   r   r      s        ::* * * * * * Zh 7 	 	 	F IeeGnn 4 	 	 	E Y	(; C 	 	 	IIIIIr*   r   c                  :     e Zd ZdZd fdZ ee          Z xZS )XYComponentz( Base class for bi-variate expressions. r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zXYComponent.__init__  r)   r*   r+   )	r-   r.   r/   r0   r"   r   rN   rR   r1   r2   s   @r(   rb   rb     sI        22* * * * * * ,--IIIIIr*   rb   c                  $     e Zd ZdZd fdZ xZS )rS   zH X-component of a coordinate system transform to cartesian coordinates. r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zXComponent.__init__  r)   r*   r+   r,   r2   s   @r(   rS   rS     C        RR* * * * * * * * * *r*   rS   c                  $     e Zd ZdZd fdZ xZS )rX   zH Y-component of a coordinate system transform to cartesian coordinates. r   r   c                :     t                      j        |i | d S r   r    r#   s      r(   r"   zYComponent.__init__%  r)   r*   r+   r,   r2   s   @r(   rX   rX   !  rf   r*   rX   )*r0   
__future__r   logging	getLoggerr-   logmathr   
core.enumsr   core.has_propsr   core.propertiesr   r	   r
   r   r   r   r   r   r   r   r   r   r   modelr   __all__r   r   r   r   rB   rE   rK   rN   r   rb   rS   rX    r*   r(   <module>rt      s`   6 # " " " " " g!!       # " " " " " % % % % % %                                    
* * * * * * * 
*.	 	 	 	 	: 	 	 	D	 	 	 	 	Z 	 	 	B	 	 	 	 	J 	 	 	4 
* * * * *u * * 
*+ + + + + + + +, , , , , , , , 
* * * * ** * * 
* 	 	 	 	 	( 	 	 	. 
. . . . .* . . 
.* * * * * * * ** * * * * * * * * *r*   