
mJ]c           @` s  d  d l  m Z m Z m Z m Z d  d l Z e j e  Z d  d l	 m
 Z
 d  d l m Z e j Z e j Z d  d l Z d  d l 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 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( m) Z) m* Z* m+ Z+ m, Z, m- Z- m. Z. m/ Z/ m0 Z0 m1 Z1 m2 Z2 m3 Z3 m4 Z4 m5 Z5 m6 Z6 m7 Z7 m8 Z8 m9 Z9 m: Z: m; Z; m< Z< m= Z= m> Z> m? Z? m@ Z@ mA ZA mB ZB mC ZC mD ZD d d lE mF ZF d d	 lG mH ZH d d
 lI mJ ZJ mK ZK mL ZL mM ZM d d lN mO ZO d d lP mQ ZQ d d lR mS ZS eQ d  ZT d f ZU eV d  ZW d   ZX d   ZY d   ZZ d d d d d d d g Z[ d   Z\ d d d  Z] d   Z^ d  Z_ d!   Z` d"   Za d#   Zb d$   Zc d%   Zd d&   Ze d'   Zf i$ d(   d) 6d*   d+ 6d,   d- 6d.   d/ 6d0   d1 6d2   d3 6d4   d5 6d6   d7 6d8   d9 6d:   d; 6d<   d= 6d>   d? 6d@   dA 6dB   dC 6dD   dE 6dF   dG 6dH   dI 6dJ   dK 6dL   dM 6dN   dO 6dP   dQ 6dR   dS 6dT   dU 6dV   dW 6dX   dY 6dZ   d[ 6d\   d] 6d] d^ 6d_   d` 6da   db 6dc   dd 6de   df 6dg   dh 6di   dj 6dk   dl 6dm   dn 6Zg do   Zh dp   Zi eV dq  Zj dr   Zk ds   Zl dt Zm du   Zn dv Zo dw Zp dx   Zq eV dy  Zr d S(z   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   OrderedDict(   t   collections_abc(   t   string_typest   reraisei   (*   t   BoxSelectToolt   BoxZoomToolt   CategoricalAxist   MercatorAxist   TapToolt   CrosshairToolt   DataRange1dt   DatetimeAxist   FactorRanget   Gridt   HelpToolt	   HoverToolt   LassoSelectToolt   Legendt
   LegendItemt
   LinearAxist   LogAxist   PanToolt
   ZoomInToolt   ZoomOutToolt   PolySelectToolt   ContinuousTickert   SaveToolt   Ranget   Range1dt   UndoToolt   RedoToolt	   ResetToolt   Toolt   WheelPanToolt   WheelZoomToolt   ColumnarDataSourcet   ColumnDataSourcet   LogScalet   LinearScalet   CategoricalScalet   Circlet	   MultiLinet   BoxEditToolt   PointDrawToolt   PolyDrawToolt   PolyEditTool(   t   Marker(   t   GlyphRenderer(   t	   ColorSpect   Datetimet   valuet   field(   t   stack(   t   import_optional(   t	   nice_joinu   pandasu   get_default_colorc         C` s   d d d d d d d d d	 d
 d d d d d d d d g } |  r |  j  } g  | D] } | j d k rR | ^ qR } t |  } | | S| d Sd  S(   Nu   #1f77b4u   #ff7f0eu   #ffbb78u   #2ca02cu   #98df8au   #d62728u   #ff9896u   #9467bdu   #c5b0d5u   #8c564bu   #c49c94u   #e377c2u   #f7b6d2u   #7f7f7fu   #bcbd22u   #dbdb8du   #17becfu   #9edae5u   GlyphRendereri    (   t	   rendererst   __view_model__t   len(   t   plott   colorsR;   t   xt   num_renderers(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   get_default_colorJ   s     	(c         K` sS  | | k r t  d |   n  d   | j   D } t |  d k r t |  d k rx t  d t t |     n  | j   t |   k r t  d   q n  g  } g  } x t |   D] \ } } i | d 6} | j |  t |   | | <xJ | j	   D]< \ }	 }
 t
 |
 t t f  r0|
 | | |	 <q |
 | |	 <q W| j |  q W| S(   Nu1   Stack property '%s' cannot appear in keyword argsc         S` s1   h  |  ]' } t  | t t f  r t |   q S(    (   t
   isinstancet   listt   tupleR=   (   t   .0R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <setcomp>g   s   	 i    i   uY   Keyword argument sequences for broadcasting must all be the same lengths. Got lengths: %ruO   Keyword argument sequences for broadcasting must be the same length as stackersu   name(   t
   ValueErrort   valuesR=   t   sortedRD   t   popt	   enumeratet   appendR8   t   itemsRC   RE   (   t   stackerst   spect   kwt   lengthst   st   _kwt   it   valt   dt   kt   v(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _single_stackc   s(    c         K` s  x3 | | f D]% } | | k r t  d |   q q Wd   | j   D } t |  d k r t |  d k r t  d t t |     n  | j   t |   k r t  d   q n  g  } g  } g  } x t |   D] \ }	 }
 i |
 d 6} t |  } | j |
  t |   | | <t |   | | <xJ | j	   D]< \ } } t
 | t t f  ri| |	 | | <q7| | | <q7W| j |  q W| S(   Nu1   Stack property '%s' cannot appear in keyword argsc         S` s1   h  |  ]' } t  | t t f  r t |   q S(    (   RC   RD   RE   R=   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <setcomp>   s   	 i    i   uY   Keyword argument sequences for broadcasting must all be the same lengths. Got lengths: %ruO   Keyword argument sequences for broadcasting must be the same length as stackersu   name(   RG   RH   R=   RI   RD   RJ   RK   RL   R8   RM   RC   RE   (   RN   t   spec0t   spec1RP   t   nameRQ   t   s0t   s1RS   RT   RU   RV   RW   RX   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _double_stack   s0    c         ` s  t  |  t  s y t |   }  Wq t k
 r{ } d j d t t |    d | j  } t t t |  t	 j
   d  q Xn  t  | t  s y t |  } Wq t k
 r } d j d t t |   d | j  } t t t |  t	 j
   d  q Xn  t d     D  r,t t   d d } n d  } t d     D  r`t t   d d	 } n d  } t d
     D  rt t   d d } n d  } t t   d d } t t   d d }	 t d     D  rt t   d d }
 n d  }
 t d     D  r&t t   d d } n d  } t d     D  rZt t   d d } n d  } t t   d d } t t   d d } d     j   j   D } t t | |	  } t t | |  } t t | |  } t t | |  } t t | |  } t d | d | d | d | d | d |   } d     j   j   D } t t | |  } t t | |  } t t | |
  } t t | |  } t t | |  } t d | d | d | d | d | d |  } d d d  d! d" d# d$ g }   f d%   | D } | | d& <| | d' <| S((   NuN   Failed to auto-convert {curr_type} to ColumnDataSource.
 Original error: {err}t	   curr_typet   erri   c         s` s   |  ] } | j  d   Vq d S(   u   node_selection_N(   t
   startswith(   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>   s    t   prefixu   node_selection_c         s` s   |  ] } | j  d   Vq d S(   u   node_hover_N(   Rb   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>   s    u   node_hover_c         s` s   |  ] } | j  d   Vq d S(   u   node_muted_N(   Rb   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>   s    u   node_muted_u   node_nonselection_u   node_c         s` s   |  ] } | j  d   Vq d S(   u   edge_selection_N(   Rb   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>   s    u   edge_selection_c         s` s   |  ] } | j  d   Vq d S(   u   edge_hover_N(   Rb   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>   s    u   edge_hover_c         s` s   |  ] } | j  d   Vq d S(   u   edge_muted_N(   Rb   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>   s    u   edge_muted_u   edge_nonselection_u   edge_c         S` sC   i  |  ]9 \ } } | j  d   t j   k r | | j  d    q S(   u   node_(   t   lstripR,   t
   properties(   RF   RW   RX   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys
   <dictcomp>   s   	 t   glypht   nonselection_glypht   selection_glypht   hover_glypht   muted_glypht   data_sourcec         S` sC   i  |  ]9 \ } } | j  d   t j   k r | | j  d    q S(   u   edge_(   Rd   R-   Re   (   RF   RW   RX   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys
   <dictcomp>   s   	 u   nameu   levelu   visibleu   x_range_nameu   y_range_nameu   selection_policyu   inspection_policyc         ` s.   i  |  ]$ } |   k r   j  |  |  q S(    (   RJ   (   RF   t   attr(   t   kwargs(    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys
   <dictcomp>
  s   	 u   node_rendereru   edge_renderer(   RC   R'   R(   RG   t   formatt   strt   typet   messageR   t   syst   exc_infot   anyt   _pop_colors_and_alphaR,   t   NoneR-   t   copyRM   t   _make_glyphR3   (   t   node_sourcet   edge_sourceRm   Ra   t   msgt   snode_cat   hnode_cat   mnode_cat	   nsnode_cat   node_cat   sedge_cat   hedge_cat   medge_cat	   nsedge_cat   edge_cat   node_kwargst
   node_glypht   nsnode_glypht   snode_glypht   hnode_glypht   mnode_glypht   node_renderert   edge_kwargst
   edge_glypht   nsedge_glypht   sedge_glypht   hedge_glypht   medge_glypht   edge_renderert   _RENDERER_ARGSt   renderer_kwargs(    (   Rm   s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _graph   s    	'	'		

u   nameu   x_range_nameu   y_range_nameu   levelu   viewu   visibleu   mutedc         ` s3     f d   t  D }   j d t    | d <| S(   Nc         ` s.   i  |  ]$ } |   k r   j  |  |  q S(    (   RJ   (   RF   Rl   (   Rm   (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys
   <dictcomp>  s   	u   sourceu   data_source(   R   RJ   R(   (   Rm   t   result(    (   Rm   s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _pop_renderer_args  s    
u    g      ?c         C` s   t    } | j | d t    } x@ d
 D]8 } | |  j   k rG q) n  | j | | |  | | <q) Wd |  j   k r | j | d d  | d <n  | j | d |  } x@ d D]8 } | |  j   k r q n  | j | | |  | | <q W| S(   u   
    Given a kwargs dict, a prefix, and a default value, looks for different
    color and alpha fields of the given prefix, and fills in the default value
    if it doesn't exist.
    u   coloru
   fill_coloru
   line_coloru
   text_coloru   blacku   alphau
   fill_alphau
   line_alphau
   text_alpha(   u
   fill_coloru
   line_color(   u
   fill_alphau
   line_alphau
   text_alpha(   t   dictRJ   RB   Re   (   t
   glyphclassRm   Rc   t   default_alphaR   t   colort   argnamet   alpha(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyRu     s    	c         C` s   |  j  d d   } |  j d  } d  } | r t | t  r t |  } | d  k	 r t | d  r | | j k r t |  } q q q | } n  | S(   Nu   legendu   sourceu   column_names(	   RJ   Rv   t   getRC   R   R6   t   hasattrt   column_namesR7   (   Rm   t   legendt   sourcet   legend_item_label(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _get_legend_item_label>  s    	uH  

Expected %s to reference fields in the supplied data source.

When a 'source' argument is passed to a glyph method, values that are sequences
(like lists or arrays) must come from references to data columns in the source.

For instance, as an example:

    source = ColumnDataSource(data=dict(x=a_list, y=an_array))

    p.circle(x='x', y='y', source=source, ...) # pass column names and a source

Alternatively, *all* data sequences may be provided as literals as long as a
source is *not* provided:

    p.circle(x=a_list, y=an_array, ...)  # pass actual sequences and no source

c         C` s  g  } |  j    } x | j   D] \ } } t | t  s@ q n  t | t  rU q n  | | k rg q n  t | t  r| q n  t | | j t  r t | t  r q n  t | t	 j
  r | j d k r t d |   n  | r | j |  q | j | d | | | | <q W| S(   Ni   u!   Columns need to be 1D (%s is not)R\   (   t   dataspecs_with_propsRM   RC   t   IterableR   R   t   propertyR4   RE   t   npt   ndarrayt   ndimt   RuntimeErrorRL   t   add(   R   Rm   R   t   is_user_sourcet    incompatible_literal_spec_valuest	   dataspecst   varRU   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _process_sequence_literalsd  s(    %!c         C` s3   | d  k r d  S| j   } | j |  |  |   S(   N(   Rv   Rw   t   update(   R   t   kwst   extra(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyRx     s
    c         C` s2  |  j  d t  } | s1 t   } |  j |  n/ t |  d k rP | d } n t d |    t } x | j D] } | j | k rp | j j d  r | j	 j
 |  t } Pn  | j j d  r | j | j	 d j k r | j	 j
 |  t } Pq qp qp W| s.t d | d | g  } | j j
 |  n  d  S(	   NRp   i   i    u5   Plot %s configured with more than one legend rendereru   valueu   fieldt   labelR;   (   t   selectR   t
   add_layoutR=   R   t   FalseRM   R   R   R;   RL   t   TrueRk   R   (   R>   R   t   glyph_renderert   legendsR   t   addedt   itemt   new_item(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _update_legend  s,    	c         C` s0  |  d  k r t   St rS t |  t j j j  rS t d t t	 |  j
 j      St |  t  rf |  St r t |  t j  r |  j }  n  t |  t t j f  rt d   |  D  r t d t	 |    St |   d k ry t d |  d d |  d  SWqt k
 rqXqn  t d t |     d  S(	   Nt   factorsc         s` s   |  ] } t  | t  Vq d  S(   N(   RC   R   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>  s    i   t   starti    t   endi   u   Unrecognized range input: '%s'(   Rv   R   t   pdRC   t   coret   groupbyt   GroupByR   RI   RD   t   groupst   keysR   t   SeriesRH   t   SequenceR   R   t   allR=   R    RG   Ro   (   t   range_input(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt
   _get_range  s"    "
c         C` s   t  |  t t f  r( | d k r( t   St  |  t t f  rP | d k rP t   St  |  t  rf t   St d t	 |     d  S(   Nu   linearu   datetimeu   mercatoru   autou   logu*   Unable to determine proper scale for: '%s'(   u   linearu   datetimeu   mercatoru   autoN(
   RC   R   R    Rv   R*   R)   R   R+   RG   Ro   (   R   t	   axis_type(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt
   _get_scale  s    !!c         C` s  |  d  k r d  i  f S|  d k r, t i  f S|  d k rB t i  f S|  d k rX t i  f S|  d k r t i | d k r| d n d d 6f S|  d	 k r t | t  r t i  f St | t  r y$ t	 j
 t	   | j  t i  f SWq t k
 r q Xn  t i  f St d
 |    d  S(   Nu   linearu   logu   datetimeu   mercatori    u   lonu   latu	   dimensionu   autou   Unrecognized axis_type: '%r'(   Rv   R   R   R   R   RC   R   R
   R    R5   t   validateR   RG   (   R   R   t   dim(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _get_axis_class  s*    



#

c         C` sb   t  | t  r. | d k r* t d   n  | S| d  k r> d S| d k r^ |  t k rZ d Sd Sd  S(   Ni   u   num_minor_ticks must be > 1i    u   autoi
   i   (   RC   t   intRG   Rv   R   (   t
   axis_classt   num_minor_ticks(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _get_num_minor_ticks  s    c           C` s   t  d d  S(   Nt
   dimensionsu   both(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   <lambda>  t    u   panc           C` s   t  d d  S(   NR   u   width(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   xpanc           C` s   t  d d  S(   NR   u   height(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   ypanc           C` s   t  d d  S(   Nt	   dimensionu   width(   R%   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u
   xwheel_panc           C` s   t  d d  S(   NR   u   height(   R%   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u
   ywheel_panc           C` s   t  d d  S(   NR   u   both(   R&   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u
   wheel_zoomc           C` s   t  d d  S(   NR   u   width(   R&   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   xwheel_zoomc           C` s   t  d d  S(   NR   u   height(   R&   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   ywheel_zoomc           C` s   t  d d  S(   NR   u   both(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   zoom_inc           C` s   t  d d  S(   NR   u   width(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   xzoom_inc           C` s   t  d d  S(   NR   u   height(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   yzoom_inc           C` s   t  d d  S(   NR   u   both(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR      R   u   zoom_outc           C` s   t  d d  S(   NR   u   width(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u	   xzoom_outc           C` s   t  d d  S(   NR   u   height(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u	   yzoom_outc           C` s   t  d d  S(   Nt   behavioru   inspect(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   clickc           C` s   t    S(   N(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   tapc           C` s   t    S(   N(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u	   crosshairc           C` s   t    S(   N(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u
   box_selectc           C` s   t  d d  S(   NR   u   width(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   xbox_selectc           C` s   t  d d  S(   NR   u   height(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   ybox_selectc           C` s   t    S(   N(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR   	  R   u   poly_selectc           C` s   t    S(   N(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR   
  R   u   lasso_selectc           C` s   t  d d  S(   NR   u   both(   R	   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   box_zoomc           C` s   t  d d  S(   NR   u   width(   R	   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u	   xbox_zoomc           C` s   t  d d  S(   NR   u   height(   R	   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u	   ybox_zoomc           C` s   t  d d d	 d
 g  S(   Nt   tooltipsu   indexu   $indexu   data (x, y)u   ($x, $y)u   screen (x, y)u
   ($sx, $sy)(   u   indexu   $index(   u   data (x, y)u   ($x, $y)(   u   screen (x, y)u
   ($sx, $sy)(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     s   u   hoverc           C` s   t    S(   N(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   saveu   previewsavec           C` s   t    S(   N(   R!   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   undoc           C` s   t    S(   N(   R"   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   redoc           C` s   t    S(   N(   R#   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   resetc           C` s   t    S(   N(   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   helpc           C` s   t    S(   N(   R.   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u   box_editc           C` s   t    S(   N(   R/   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u
   point_drawc           C` s   t    S(   N(   R0   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u	   poly_drawc           C` s   t    S(   N(   R1   (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR     R   u	   poly_editc         C` s   t  t j    } |  | k rK t |  } t | t  rD t | } n  |   St j |  j   |  d } } | s | d } } n  t d |  | t	 |  f   d S(   u=    Takes a string and returns a corresponding `Tool` instance. u   similaru   possibleu*   unexpected tool name '%s', %s tools are %sN(
   RI   t   _known_toolsR   RC   R   t   difflibt   get_close_matchest   lowerRG   R:   (   R\   t   known_toolst   tool_fnt   matchest   text(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _tool_from_string   s    
c         C` s   t  | | |  \ } } | r | |   }	 t |	 j t  rT t | |  |	 j _ n  | } | rl | |	 _ n  t d | d |	 j  }
 |  j |
 d  | d  k	 r t
 |  |  j |	  q n  d  S(   NR   t   tickeru   center(   R   RC   R   R   R   R   t
   axis_labelR   R   Rv   t   getattrRL   (   R>   R   t   axis_locationt   minor_ticksR   t   rngR   t   axisclst   axiskwt   axist   grid(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _process_axis_and_grid4  s    c         C` s  g  } i  } d } g  } t  | t t f  r xY | D]Q } t  | t  rY | j |  q4 t  | t  ry | | d 7} q4 t d   q4 W| } n  xU t j d | j	    D]; } | d k r q n  t
 |  } | j |  | | | <q WxU t j t d   | D   D]4 \ }	 }
 t t |
   d k r
| j |	  q
q
W| ret j d d j |   n  | d	 k	 rxC | D]" } t  | t  rx| | _ PqxqxW| j t d |   n  | | f S(
   u    Adds tools to the plot object

    Args:
        plot (Plot): instance of a plot object
        tools (seq[Tool or str]|str): list of tool types or string listing the
            tool names. Those are converted using the _tool_from_string
            function. I.e.: `wheel_zoom,box_zoom,reset`.
        tooltips (string or seq[tuple[str, str]], optional):
            tooltips to use to configure a HoverTool

    Returns:
        list of Tools objects added to plot, map of supplied string names to tools
    u    u   ,u4   tool should be a string or an instance of Tool classu   \s*,\s*c         s` s   |  ] } | j  j Vq d  S(   N(   t	   __class__t   __name__(   RF   t   tool(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>o  s    i   u   %s are being repeatedR   N(   RC   RD   RE   R$   RL   R   RG   t   ret   splitt   stripR   t	   itertoolsR   RI   R=   t   warningst   warnt   joinRv   R   R   (   R>   t   toolsR   t	   tool_objst   tool_mapt   temp_tool_strt   repeated_toolsR   t   tool_objt   typenamet   group(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _process_tools_argH  s>    		#	c         C` sf  | d k s t | t  r' | |  _ n, | | k rC | | |  _ n t d |   | d	 k s t | t  s t d   | D  r | |  _ n, | | k r | | |  _ n t d |   | d
 k s t | t  r | |  _ n, | | k r | | |  _ n t d |   | d k s*t | t  r6| |  _ n, | | k rR| | |  _ n t d |   d S(   u   Adds tools to the plot object

    Args:
        toolbar (Toolbar): instance of a Toolbar object
        tools_map (dict[str]|Tool): tool_map from _process_tools_arg
        active_drag (str or Tool): the tool to set active for drag
        active_inspect (str or Tool): the tool to set active for inspect
        active_scroll (str or Tool): the tool to set active for scroll
        active_tap (str or Tool): the tool to set active for tap

    Returns:
        None

    Note:
        This function sets properties on Toolbar
    u   autouU   Got unknown %r for 'active_drag', which was not a string supplied in 'tools' argumentc         s` s   |  ] } t  | t  Vq d  S(   N(   RC   R$   (   RF   t   t(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>  s    uX   Got unknown %r for 'active_inspect', which was not a string supplied in 'tools' argumentuW   Got unknown %r for 'active_scroll', which was not a string supplied in 'tools' argumentuT   Got unknown %r for 'active_tap', which was not a string supplied in 'tools' argumentN(   u   autoN(   u   autoN(   u   autoN(   u   autoN(	   Rv   RC   R$   t   active_dragRG   R   t   active_inspectt   active_scrollt
   active_tap(   t   toolbarR   R  R  R  R	  (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _process_active_tools  s(    1c         C` s   t    } x |  j D] } i  } t |  |  } | j rb d j t j | j  j d   | d <n
 d | d <| j |   | d <| j	 j
   | d <| | | <q W| S(   Nu	   
        u   
u   descu    u   defaultu   type(   R   t   _argsR   t   __doc__R   t   textwrapt   dedentR   t   class_defaultR   t   _sphinx_type(   R   t   argspecst   argRO   t
   descriptor(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _get_argspecs  s    		+
u@   
def %s(self, %s, **kwargs):
%s
    return func(self, **kwargs)
c         C` s   g  } xU | j    D]G \ } } | d d  k r? | j |  q | j d | | d f  q Wd j |  } d j d   | D  } t |  | | f } t | d d  }	 i  }
 t |	 i | d 6|
  |
 |  S(	   Nu   defaultu   %s=%ru   , u   
c         s` s   |  ] } d  | | f Vq d S(   u       kwargs[%r] = %sN(    (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>  s    u
   fakesourceu   execu   func(   RM   Rv   RL   R   t   _sigfunc_templatet   compilet   eval(   t	   func_namet   funcR  t   func_args_with_defaultsR  RO   t	   args_textt   kwargs_assign_textt	   func_textt	   func_codet   func_globals(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _get_sigfunc  s    u'       %s (%s) : %s
        (default: %r)
u?   Configure and add :class:`~bokeh.models.%s.%s` glyphs to this Figure.

Args:
%s

Keyword Args:
%s

Other Parameters:
    alpha (float) : an alias to set all alpha keyword args at once
    color (Color) : an alias to set all color keyword args at once
    source (ColumnDataSource) : a user supplied data source
    legend (str) : a legend tag for this glyph
    x_range_name (str) : name an extra range to use for mapping x-coordinates
    y_range_name (str) : name an extra range to use for mapping y-coordinates
    level (Enum) : control the render level order for this glyph

It is also possible to set the color and alpha parameters of a "nonselection"
glyph. To do so, prefix any visual parameter with ``'nonselection_'``.
For example, pass ``nonselection_alpha`` or ``nonselection_fill_alpha``.

Returns:
    GlyphRenderer
c         C` s  | j  |  _  d d d h } g  } | j   t |  } x | D] } | | k rV q> n  t | |  } | j j   }	 | j r d j t j	 | j  j
 d   }
 n d }
 | j t | |	 |
 | j |  f  q> Wt | d i   } x: | j   D], \ } \ }	 }
 | j d | |	 |
 f  q W| j   g  } xC | j   D]5 \ } } | j t | | d	 | d
 | d f  q@Wt | t  rd n d } t | |  j  d j |  d j |  f |  _ | r|  j | 7_ n  d  S(   Nu   js_event_callbacksu   js_property_callbacksu   subscribed_eventsu	   
        u   
u    u
   _extra_kwsu       %s (%s) : %su   typeu   descu   defaultu   markersu   glyphs(   R   Re   t   setR   R   R  R  R   R  R  R   RL   t   _arg_templateR  RM   t   sortt
   issubclassR2   t   _doc_template(   R  R  R   t
   extra_docst	   omissionst   kwlinesR   RP   R  t   typt   desct	   extra_kwst   arglinesR  RO   t   mod(    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _add_sigfunc_info  s0     	'*
-.c         ` sV     f d   } t     } t   j j   | |  } t | _ t | |   |  | S(   Nc         ` s  | j  d d   d  k	 } | r | d } t | t  s y t |  } WnZ t k
 r } d j d t t |   d | j	  } t
 t t |  t j   d  n X| | d <q n  t |  } t |  } | d } d | k r  j d k r| d | d <n  t   |  } g  }	 |	 t   | | |  7}	 |	 t   | | |  7}	 |	 rnt t t |	 d d   n  t   | d d d d }
 t d   | D  rt   | d d } n d  } t d   | D  rt   | d d } n d  } t d   | D  rt   | d d } n d  } t   | |  } t   | |
  } t   | |  } t   | |  } t   | |  } t d | d | d | d | d | |  } | rt |  | |  n  |  j j |  | S(   Nu   sourceuN   Failed to auto-convert {curr_type} to ColumnDataSource.
 Original error: {err}R`   Ra   i   u   data_sourceu   alphau   Imageu	   ImageRGBAu   ImageURLu   global_alphat
   conjuctionu   andRc   u   nonselection_R   g?c         s` s   |  ] } | j  d   Vq d S(   u
   selection_N(   Rb   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>H  s    u
   selection_c         s` s   |  ] } | j  d   Vq d S(   u   hover_N(   Rb   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>N  s    u   hover_c         s` s   |  ] } | j  d   Vq d S(   u   muted_N(   Rb   (   RF   R@   (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pys	   <genexpr>T  s    u   muted_Rf   Rg   Rh   Ri   Rj   (   u   Imageu	   ImageRGBAu   ImageURL(   R   Rv   RC   R'   R(   RG   Rn   Ro   Rp   Rq   R   Rr   Rs   R   R   R   Ru   R   R   t   _GLYPH_SOURCE_MSGR:   Rt   Rx   R3   R   R;   RL   (   t   selfRm   R   R   Ra   R{   R   t   renderer_kwst   glyph_caR   t
   nsglyph_cat	   sglyph_cat	   hglyph_cat	   mglyph_caRf   t   nsglypht   sglypht   hglypht   mglyphR   (   R   (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyR    s`    
	$
	(   R  R!  R   R   R   t   glyph_methodR/  (   R   R'  R  R  t   sigfunc(    (   R   s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   _glyph_function  s    P	(s   t
   __future__R    R   R   R   t   loggingt	   getLoggerR   t   logt   collectionsR   t   bokeh.util.futureR   R   R   R   R   R   R  R   t   numpyR   Rr   t   sixR   R   t   modelsR   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R+   R,   R-   R.   R/   R0   R1   t   models.markersR2   t   models.renderersR3   t   core.propertiesR4   R5   R6   R7   t	   transformR8   t   util.dependenciesR9   t   util.stringR:   R   t   __all__Rv   RB   RY   R_   R   R   R   Ru   R   R1  R   Rx   R   R   R   R   R   R   R   R   R  R  R  R  R!  R#  R&  R/  R?  (    (    (    s5   lib/python2.7/site-packages/bokeh/plotting/helpers.pyt   <module>   s   "		 
"		!	%	i		 	#	%						

































		9	-			 