B
    @\                 @   s,  d Z ddlmZmZmZmZ ddlZeeZ	ddl
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 ddlmZ d	d
lmZ dZeG dd deZeG dd deZeG dd deZ G dd de eZ!G dd de Z"eG dd deZ#G dd de#Z$G dd de#Z%dS )z Models for mapping values from one range or space to another in the client.

Mappers (as opposed to scales) are not presumed to be invertible.

    )absolute_importdivisionprint_functionunicode_literalsN   )palettes)abstract)	ColorEitherEnumFloatInt
MarkerTypeSeqStringTuple)Palette   )	Transform)MapperColorMapperCategoricalMapperCategoricalColorMapperCategoricalMarkerMapperContinuousColorMapperLinearColorMapperLogColorMapperc               @   s   e Zd ZdZdS )r   z Base class for mappers.

    N)__name__
__module____qualname____doc__ r!   r!   3lib/python3.7/site-packages/bokeh/models/mappers.pyr   8   s   r   c                   sJ   e Zd ZdZeeddeedd Z	edddZ
d fd
d	Z  ZS )r   z) Base class for color mapper types.

    z
    A sequence of colors to use as the target palette for mapping.

    This property can also be set as a ``String``, to the name of any of the
    palettes shown in :ref:`bokeh.palettes`.
    )helpc             C   s
   t t| S )N)getattrr   )Zpalr!   r!   r"   <lambda>J   s    zColorMapper.<lambda>ZgrayzV
    Color to be used if data is NaN or otherwise not mappable. (Default: 'gray')
    )defaultr#   Nc                s&   |d k	r||d< t t| jf | d S )Npalette)superr   __init__)selfr'   kwargs)	__class__r!   r"   r)   P   s    zColorMapper.__init__)N)r   r   r   r    r   r	   Zacceptsr   r   r'   	nan_colorr)   __classcell__r!   r!   )r,   r"   r   ?   s   r   c               @   sR   e Zd ZdZeeeeeeeeeeeedddZe	dddZ
e	ddZdS )	r   zK Base class for mappers that map categorical factors to other values.

    Na=  
    A sequence of factors / categories that map to the some target range. For
    example the following color mapper:

    .. code-block:: python

        mapper = CategoricalColorMapper(palette=["red", "blue"], factors=["foo", "bar"])

    will map the factor ``"foo"`` to red and the factor ``"bar"`` to blue.
    )r&   r#   r   aw  
    A start index to "slice" data factors with before mapping.

    For example, if the data to color map consists of 2-level factors such
    as ``["2016", "sales"]`` and ``["2016", "marketing"]``, then setting
    ``start=1`` will perform color mapping only based on the second sub-factor
    (i.e. in this case based on the department ``"sales"`` or ``"marketing"``)
    a  
    A start index to "slice" data factors with before mapping.

    For example, if the data to color map consists of 2-level factors such
    as ``["2016", "sales"]`` and ``["2017", "marketing"]``, then setting
    ``end=1`` will perform color mapping only based on the first sub-factor
    (i.e. in this case based on the year ``"2016"`` or ``"2017"``)

    If ``None`` then all sub-factors from ``start`` to the end of the
    factor will be used for color mapping.
    )r#   )r   r   r   r    r
   r   r   r   factorsr   startendr!   r!   r!   r"   r   U   s   $	
r   c                   s    e Zd ZdZ fddZ  ZS )r   z Map categorical factors to colors.

    Values that are passed to this mapper that are not in the factors list
    will be mapped to ``nan_color``.

    c                sf   t t| jf | | j}| j}|d k	rb|d k	rbt|t|k rb|t|d  }td|| jf  d S )NzVPalette length does not match number of factors. %s will be assigned to `nan_color` %s)	r(   r   r)   r'   r/   lenwarningswarnr-   )r*   r+   r'   r/   Zextra_factors)r,   r!   r"   r)      s    zCategoricalColorMapper.__init__)r   r   r   r    r)   r.   r!   r!   )r,   r"   r   |   s   r   c               @   s(   e Zd ZdZeeddZedddZdS )r   a1   Map categorical factors to marker types.

    Values that are passed to this mapper that are not in the factors list
    will be mapped to ``default_value``.

    .. note::
        This mappers is primarily only useful with the ``Scatter`` marker
        glyph that be parameterized by marker type.

    zF
    A sequence of marker types to use as the target for mapping.
    )r#   Zcirclez\
    A marker type to use in case an unrecognized factor is passed in to be
    mapped.
    )r&   r#   N)r   r   r   r    r   r   ZmarkersZdefault_valuer!   r!   r!   r"   r      s
   
r   c               @   s<   e Zd ZdZeddZeddZedddZedddZ	dS )	r   z4 Base class for continuous color mapper types.

    zo
    The minimum value of the range to map into the palette. Values below
    this are clamped to ``low``.
    )r#   zp
    The maximum value of the range to map into the palette. Values above
    this are clamped to ``high``.
    Nz
    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.
    )r&   r#   z
    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.
    )
r   r   r   r    r   ZlowZhighr	   Z	low_colorZ
high_colorr!   r!   r!   r"   r      s   r   c               @   s   e Zd ZdZdS )r   a   Map numbers in a range [*low*, *high*] linearly into a sequence of
    colors (a palette).

    For example, if the range is [0, 99] and the palette is
    ``['red', 'green', 'blue']``, the values would be mapped as follows::

             x < 0  : 'red'     # values < low are clamped
        0 >= x < 33 : 'red'
       33 >= x < 66 : 'green'
       66 >= x < 99 : 'blue'
       99 >= x      : 'blue'    # values > high are clamped

    N)r   r   r   r    r!   r!   r!   r"   r      s   r   c               @   s   e Zd ZdZdS )r   a   Map numbers in a range [*low*, *high*] into a sequence of colors
    (a palette) on a natural logarithm scale.

    For example, if the range is [0, 25] and the palette is
    ``['red', 'green', 'blue']``, the values would be mapped as follows::

                x < 0     : 'red'     # values < low are clamped
       0     >= x < 2.72  : 'red'     # math.e ** 1
       2.72  >= x < 7.39  : 'green'   # math.e ** 2
       7.39  >= x < 20.09 : 'blue'    # math.e ** 3
       20.09 >= x         : 'blue'    # values > high are clamped

    .. warning::
        The ``LogColorMapper`` only works for images with scalar values that are
        non-negative.

    N)r   r   r   r    r!   r!   r!   r"   r      s   r   )&r    Z
__future__r   r   r   r   ZloggingZ	getLoggerr   logr3    r   Zcore.has_propsr   Zcore.propertiesr	   r
   r   r   r   r   r   r   r   Z
core.enumsr   Z
transformsr   __all__r   r   r   r   r   r   r   r   r!   r!   r!   r"   <module>   s,   
,&