σ
mάJ]c        
   @` sG  d  Z  d d l m Z m Z m Z m Z d d l Z e j e  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 d d l m Z m Z d Z e d  Z d d  Z d d d d  Z d d d  Z d d d  Z  d d d d  Z! d d d d  Z" d d d d  Z# d   Z$ d   Z% d S(    u    Helper functions for applying client-side computations such as
transformations to data fields or ``ColumnDataSource`` expressions.

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNi   (   t   exprt   field(   t   CumSumt   Stack(   t   CategoricalColorMappert   CategoricalMarkerMappert   CategoricalPatternMappert   LinearColorMappert   LogColorMapper(   t   Dodget   Jitteru   cumsumu   dodgeu   factor_cmapu   factor_hatchu   factor_marku   jitteru   linear_cmapu   log_cmapu   stacku	   transformc         C` s   t  t d |  d |   S(   u}   Create a Create a ``DataSpec`` dict to generate a ``CumSum`` expression
    for a ``ColumnDataSource``.

    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 ``start_angle``, no initial zero will
        be added (i.e. the sums will start with the first angle value, and
        include the last).

    R   t   include_zero(   R   R   (   R   R   (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   cumsum7   s    c         C` s   t  |  t d | d |   S(   uς   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

        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:
        dict

    t   valuet   range(   R   R   (   t
   field_nameR   R   (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   dodgeL   s    u   grayc         C` s.   t  |  t d | d | d | d | d |   S(   uT   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 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)

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

    Returns:
        dict

    t   palettet   factorst   startt   endt	   nan_color(   R   R   (   R   R   R   R   R   R   (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   factor_cmap_   s
    c         C` s(   t  |  t d | d | d | d |   S(   uθ   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:
        dict

    Added in version 1.1.1

    t   patternsR   R   R   (   R   R
   (   R   R   R   R   R   (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   factor_hatch   s    c         C` s(   t  |  t d | d | d | d |   S(   uF   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:
        dict

    t   markersR   R   R   (   R   R	   (   R   R   R   R   R   (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   factor_mark   s    u   uniformc         C` s(   t  |  t d | d | d | d |   S(   u¦   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:
        dict

    t   meant   widtht   distributionR   (   R   R   (   R   R    R   R!   R   (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   jitter½   s    c         C` s4   t  |  t d | d | d | d | d | d |   S(   uh   Create a ``DataSpec`` dict that applyies 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")

    R   t   lowt   highR   t	   low_colort
   high_color(   R   R   (   R   R   R#   R$   R%   R&   R   (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   linear_cmapΨ   s    c         C` s4   t  |  t d | d | d | d | d | d |   S(   ud   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")

    R   R#   R$   R   R%   R&   (   R   R   (   R   R   R#   R$   R%   R&   R   (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   log_cmapϊ   s    c          G` s   t  t d |    S(   u   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``.

    t   fields(   R   R   (   R)   (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   stack  s    c         C` s   t  |  |  S(   u-   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:
        dict

    (   R   (   R   t	   transform(    (    s.   lib/python2.7/site-packages/bokeh/transform.pyR+   .  s    (
   u   cumsumu   dodgeu   factor_cmapu   factor_hatchu   factor_marku   jitteru   linear_cmapu   log_cmapu   stacku	   transform(&   t   __doc__t
   __future__R    R   R   R   t   loggingt	   getLoggert   __name__t   logt   core.propertiesR   R   t   models.expressionsR   R   t   models.mappersR   R	   R
   R   R   t   models.transformsR   R   t   __all__t   FalseR   t   NoneR   R   R   R   R"   R'   R(   R*   R+   (    (    (    s.   lib/python2.7/site-packages/bokeh/transform.pyt   <module>
   s6   "(           ""	