a
    Df                    @   s  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Zd dl	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dlmZ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,m-Z- ddl.m/Z/ dd Z0G dd de	j1Z2e2ddZ3dd Z4dd Z5dd Z6dddZ7dd Z8dddZ9dd  Z:dd"d#Z;dd$d%Z<dd&d'Z=d(d) Z>d*d+ Z?d,d- Z@d.d/ ZAd0d1 ZBd2d3 ZCd4d5 ZDd6d7 ZEd8d9 ZFd:d; ZGdd=d>ZHd?d@ ZIddAdBZJddCdDZKddEdFZLddHdIZMdJdK ZNg ZOedLg dMZPg dNZQddOdPZRdQdR ZSddSdTZTeSdUdVdWdXg dY eSdZdVd[d\g d] eSd^dVd_d\d`dag eSd^dVd_dXg db eSd^dVd_dcg dd eSdedVd[d\g df eSdedVd_d\g dg eSdhdVd[dcg di eSdhdVdjdcg dk eSdldVd_dXdmdng eSdldVd_dcg do eSdpdVd_dXg dq eSdpdVd_dcdrdsg eSdUdtdudXg dv eSdUdtdudcg dw eSdxdtdud\g dy eSdxdtdudXdzd{g eSdxdtdud|d}g eSd~dtdudcg d eSdUddWdXg d eSdZdd[d\g d eSdedd[d\g df eSdhddjdcg d eSdhdd[dcg di eSdhdd_dcdg eSddtdudcg d eSddtdudXdg eSddtdud\dg dddZUdddZVdddZWdd ZXdddZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`G dd deZaebdZcdddddddddd	Zdg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg d¢g dâg dĢg dŢg dƢg dǢg dȢg dɢg dʢg dˢg d̢g d͢g d΢g dϢg dТg dѢg dҢg dӢg dԢg dբg d֢g dעg dآg d٢g dڢg dۢg dܢg dݢg dޢg dߢg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg d g dg dg dg dg dg dg dg dg d	g d
g dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg d g d!g d"g d#g d$g d%g d&g d'g d(g d)g d*g d+g d,g d-g d.g d/g d0g d1g d2g d3g d4g d5g d6g d7g d8g d9g d:g d;g d<g d=g d>g d?g d@g dAg dBg dCg dDg dEg dFg dGg dHg dIg dJg dKg dLg dMg dNg dOg dPg dQg dRg dSg dTg dUg dVg dWg dXg dYg dZg d[g d\g d]g d^g d_g d`g dag dbg dcg ddg deg dfg dgg dhg dig djg dkg dlg dmg dng dog dpg dqg drg dsg dtg dug dvg dwg dxg dyg dzg d{g d|g d}g d~g dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg  ZeZfdd eeD ZgG dd deZhG dd deZidS (      N)defaultdict
namedtuple)Version   )	AdjointLayoutCompositeOverlay
DynamicMap	GridSpaceHoloMapLayoutNdLayout	NdOverlayOverlay)
item_check)	Operation)CallbackErrorCycle)get_nested_streams)	arraylike_typesclosest_matchdisable_constantget_overlay_spec	is_numberisfinite
match_specunique_iterator
wrap_tuple)Points)LinkedStreamParamsdimc                 C   sp   t | tr tdd | D r dS t | tr<| jttttfvS t | tttfrl| 	 D ]}t
|sT dS qTdS dS )z
    Predicate that returns whether the object is displayable or not
    (i.e. whether the object obeys the nesting hierarchy)
    c                 s   s   | ]}t |tttfV  qd S N)
isinstancer
   r	   r   .0o r'   d/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/holoviews/plotting/util.py	<genexpr>/   s   zdisplayable.<locals>.<genexpr>FT)r#   r   anyr
   typer   r	   r   r   valuesdisplayable)objelr'   r'   r(   r-   *   s    
r-   c                   @   s   e Zd ZdS )WarningN)__name__
__module____qualname__r'   r'   r'   r(   r0   <       r0   namec              
   C   sD  t | tr4tdd | D }tjd|  |  S t | trh| jtt	fv r`| jj
}td| |  S t | t	rtjd| jj
t| j
 |  S t | ttfr4zTtjd g }|  D ]0}t |t	rt|st| }||  qt|W S  ty0 } ztt| |W Y d }~n
d }~0 0 ntt| d S )Nc                 s   s(   | ] }t |tttfrt|jV  qd S r"   )r#   r
   r	   r   r+   r1   r$   r'   r'   r(   r)   A   s   zcollate.<locals>.<genexpr>a  Nesting %ss within an Overlay makes it difficult to access your data or control how it appears; we recommend calling .collate() on the Overlay in order to follow the recommended nesting structure shown in the Composing Data user guide (http://goo.gl/2YS8LJ)zNesting a %s inside a DynamicMap is not supported. Ensure that the DynamicMap callback returns an Element or (Nd)Overlay. If you have applied an operation ensure it is not dynamic by setting dynamic=False.zNesting {0}s within a {1} makes it difficult to access your data or control how it appears; we recommend calling .collate() on the {1} in order to follow the recommended nesting structure shown in the Composing Data user guide (https://goo.gl/2YS8LJ)zLayout contains HoloMaps which are not nested in the recommended format for accessing your data; calling .collate() on these objects will resolve any violations of the recommended nesting presented in the Composing Data tutorial (https://goo.gl/2YS8LJ))r#   r   nextdisplay_warningparamwarningcollater   r+   r
   r1   	Exceptionformatr   r   r,   r-   extendundisplayable_info)r.   Znested_typeZobj_nameexpandedr/   Zcollated_layouter'   r'   r(   r;   ?   sH    



&r;   c                 C   s   t | tot | jtS )zP
    Determines whether object is a DynamicMap returning (Nd)Overlay types.
    )r#   r   lastr   r.   r'   r'   r(   isoverlay_fnq   s    rD   c                 C   s:   t | tr2t | jtr t| jS | jdu r.dS dS dS dS )zg
    Computes the depth of a DynamicMap overlay if it can be determined
    otherwise return None.
    N   )r#   r   rB   r   lenrC   r'   r'   r(   overlay_depthx   s    


rG   c                 C   s  |du rg }|| g }t t}t| tst| trRt| D ]\}}|| g||< q:nt| tr|  D ]R}t|trt||	 D ]\}}||  || g 7  < qqd|d  | |g7  < qdn| |d vr|d 
|  |S t| jt}| jj}	| |d vr|s|d 
|  t| }
| jjr(| jjng }t|D ]\}}d}tdd |D rbt|rbd}t|}|
dur|dur|
|k r|
dkrq4nd}|	r|nd}t||d}t| }|	 D ]<\}}|r|| n
|| | }tt|| | ||< qʐq4td	d |D }td
d | jD }|s>|r|r|	st| }t| jD ]L\}}|r|r|||  
|  ||||  vr`|||  
| q`|S )a  
    Traverses an overlayable composite container to determine which
    objects are associated with specific (Nd)Overlay layers by
    z-order, making sure to take DynamicMap Callables into
    account. Returns a mapping between the zorders of each layer and a
    corresponding lists of objects.

    Used to determine which overlaid subplots should be linked with
    Stream callbacks.
    Nr   Fc                 s   s"   | ]}t |p|jd u  V  qd S r"   )rD   rB   r%   pr'   r'   r(   r)      r4   z.compute_overlayable_zorders.<locals>.<genexpr>TrE   )pathc                 s   s    | ]}t |to|jjV  qd S r"   )r#   r   callback_is_overlayrH   r'   r'   r(   r)      r4   c                 s   s"   | ]}t |ttfo|jV  qd S r"   )r#   r   r   linked)r%   sr'   r'   r(   r)      s   )r   listr#   r   r   	enumerater
   r,   compute_overlayable_zordersitemsappendrB   rK   rL   rG   link_inputsinputsr*   rD   maxkeysr   streams)r.   rJ   Z
zorder_mapzr&   r/   kvZ	isoverlayZisdynoverlaydepthZdmap_inputsinpZno_zorder_incrementZinput_depthZdeep_zordersoffsetZdzobjsZglobal_zfoundrM   r'   r'   r(   rQ      sd    





 rQ   c                 C   s4   t | tsdS | jjrdS tdd | jjD S dS )z
    Traverses a DynamicMap graph and determines if any components
    were overlaid dynamically (i.e. by * on a DynamicMap).
    FTc                 s   s   | ]}t |V  qd S r"   )is_dynamic_overlayr%   dmr'   r'   r(   r)      r4   z%is_dynamic_overlay.<locals>.<genexpr>N)r#   r   rK   rL   r*   rU   )dmapr'   r'   r(   ra      s
    
ra   c                 C   s   g }t | trt|  t| jtrB|sB| j D ]}||  q0ndt| jt	r| j
jrt| r| j
jD ]}|t||d 7 }qfq| j D ]}||  qn
||  |S t | t	r|  D ]\}}|| qn
||  |S )a  
    Splits a DynamicMap into the original component layers it was
    constructed from by traversing the graph to search for dynamically
    overlaid components (i.e. constructed by using * on a DynamicMap).
    Useful for assigning subplots of an OverlayPlot the streams that
    are responsible for driving their updates. Allows the OverlayPlot
    to determine if a stream update should redraw a particular
    subplot.
    rE   )r#   r   initialize_dynamic
issubclassr+   r   rB   r,   rS   r   rK   rU   ra   split_dmap_overlayrR   )r.   r\   Zlayers_r]   Z_kr[   r'   r'   r(   rg      s&    




rg   c                 C   s>   | j dd tgd}|D ] }|jr$qt|s||   qdS )zD
    Initializes all DynamicMap objects contained by the object
    c                 S   s   | S r"   r'   xr'   r'   r(   <lambda>  r4   z$initialize_dynamic.<locals>.<lambda>)specsN)traverser   	unboundedrF   Z_initial_key)r.   Zdmapsrd   r'   r'   r(   re     s    re   Fc              
      s   | j r2t| j dkr2| j d dkr2t| ts2| jS t fdd| j D }|| jv rb|rb| j| S z
| | W S  ty   Y dS  tt	fy } z|W Y d}~n(d}~0  t
y   tt  Y dS 0 dS )aA  Returns the current frame in a mapping given a key mapping.

    Args:
        obj: Nested Dimensioned object
        key_map: Dictionary mapping between dimensions and key value
        cached: Whether to allow looking up key in cache

    Returns:
        The item in the mapping corresponding to the supplied key.
    rE   r   Framec                 3   s"   | ]}|j  v r |j  V  qd S r"   r5   )r%   kdkey_mapr'   r(   r)      r4   z!get_plot_frame.<locals>.<genexpr>N)kdimsrF   r#   r   rB   tupledataKeyErrorStopIterationr   r<   print	traceback
format_exc)Zmap_objrr   cachedkeyrA   r'   rq   r(   get_plot_frame  s     "

r}   c              	      s   |  dd }t| dd |dd D ]H\}}t|tr,t|j |jj|j_W d   q,1 sj0    Y  q,td. |j  fddtt	gddW  d   S 1 s0    Y  dS )a  Extracts a single frame from a nested object.

    Replaces any HoloMap or DynamicMap in the nested data structure,
    with the item corresponding to the supplied key.

    Args:
        obj: Nested Dimensioned object
        key_map: Dictionary mapping between dimensions and key value
        cached: Whether to allow looking up key in cache

    Returns:
        Nested datastructure where maps are replaced with single frames
    c                 S   s   | S r"   r'   ri   r'   r'   r(   rk   =  r4   z'get_nested_plot_frame.<locals>.<lambda>c                 S   s   | S r"   r'   ri   r'   r'   r(   rk   A  r4   NFc                    s   t |  dS )N)r{   )r}   ri   r{   rr   r'   r(   rk   F  r4   )clone)
mapziprm   r#   r   r   rK   rU   r   r
   )r.   rr   r{   r   Zit1Zit2r'   r~   r(   get_nested_plot_frame/  s    &
,
r   c                 C   s   |rdnd}d}t | tr8d| jj d}d| d}n6t | trTd}d| d	}nt | trnd
}d| d	}|s| d| d| S djdd| |d| gdS dS )z:Generate helpful message regarding an undisplayable objectz<tt>collate</tt>r;   zVFor more information, please consult the Composing Data tutorial (http://git.io/vtIQh)zHoloMap of z objects cannot be displayed.zPlease call the z( method to generate a displayable objectzNLayout containing HoloMaps of Layout or GridSpace objects cannot be displayed.z$ method on the appropriate elements.z=GridSpace containing HoloMaps of Layouts cannot be displayed.
z<center>{msg}</center>z<br>z	<b>%s</b>z	<i>%s</i>)msgN)r#   r
   r+   r1   r   r	   r=   join)r.   htmlr;   infoerrorZremedyr'   r'   r(   r?   J  s     


r?   c                 C   sP   | j jdvrdS |dkrn"|dkr,|d }ntd| d|| } || |  S )z
    Scales point sizes according to a scaling factor,
    base size and size_fn, which will be applied before
    scaling.
    )ifNareawidthr   z.Invalid value for argument "scaling_method": "z%". Valid values are: "width", "area".)dtypekind
ValueError)sizesZsize_fnZscaling_factorZscaling_methodZ	base_sizer'   r'   r(   compute_sizes`  s    

r   c                 C   s`   t | trFt| dkr$| \}}d}qVt| dkr<| \}}}qVtdn| fd \}}}|||fS )zu
    Process a padding value supplied as a tuple or number and returns
    padding values for x-, y- and z-axis.
    r   r      zPadding must be supplied as an number applied to all axes or a length two or three tuple corresponding to the x-, y- and optionally z-axis)r#   rt   rF   r   )paddingZxpadZypadZzpadr'   r'   r(   get_axis_paddingt  s    

r   c                 C   sF   t | r>| |kr>t| tjr,|tdd }| | ||  } }| |fS )z`
    If lower and high values are equal ensures they are separated by
    the defined span.
    rE   rN   )r   r#   npZ
datetime64Ztimedelta64)lowhighspanr'   r'   r(   get_minimum_span  s
    r   c                 C   s   |rb|dkrb|rF|j |v rF||j  d }||j  d }||j  d }qv| j|dd}|j}|j}ntjtjf } }}|||fS )zt
    Computes the data, soft- and hard-range along a dimension given
    an element and a dictionary of ranges.
    categoricalru   ZsofthardF)Zdimension_range)r6   rangeZ
soft_ranger   nan)elementrangesZ	dimensionZdrangesrangeZhranger'   r'   r(   	get_range  s    r   c           	         s(  | j }| }d|d jv s*d|d jv r2|d n|d  |}t|trtt|jtrt fdd|	 d D }ntd|idgd}t
|j|} j|v r| j d	 }n@| |jd
jd}|r||dr||  }n
| }t|tr|j}t|trt fdd|D }|| fS )z
    Utility to find the range for an adjoined
    plot given the plot, the element, the
    Element the plot is adjoined to and the
    dictionary of ranges.
    Z	frequencyrE   countr   c                 3   s    | ]} | d v r|V  qdS allN
dimensions)r%   Zhmr    r'   r(   r)     s   z&get_sideplot_ranges.<locals>.<genexpr>ro   rs   ZcombinedZnorm	framewiseFc                 3   s    | ]} | d v r|V  qdS r   r   )r%   ovr    r'   r(   r)     s   )current_keyr   r6   r#   r
   rf   r+   r   r7   Z_split_overlaysr   rB   Zlookup_optionsoptionsgetr   )	plotr   mainr   r|   dimsZ
range_itemZ
main_ranger   r'   r    r(   get_sideplot_ranges  s(    ,
 


r   c                 C   sl   dd | D } dd |D }| d du sD|d du sD| d |d koj| d du pj|d du pj| d |d kS )z>Checks whether range1 is within the range specified by range2.c                 S   s   g | ]}t |r|nd qS r"   r   r%   rr'   r'   r(   
<listcomp>  r4   z within_range.<locals>.<listcomp>c                 S   s   g | ]}t |r|nd qS r"   r   r   r'   r'   r(   r     r4   r   NrE   r'   )Zrange1Zrange2r'   r'   r(   within_range  s
    (&r   c                    s|   t t| dgd ttdd | D  fddD tfdd|D rZtd	ntfd
d|D sxtdd S )NZtesting_kdimr   c                 S   s   g | ]}|j D ]
}|jqqS r'   )rs   r6   )r%   rc   rp   r'   r'   r(   r     r4   z+validate_unbounded_mode.<locals>.<listcomp>c                    s   i | ]}|  |qS r'   r   r%   d)	compositer'   r(   
<dictcomp>  r4   z+validate_unbounded_mode.<locals>.<dictcomp>c                 3   s$   | ]}d d |j D  k V  qdS )c                 S   s   h | ]
}|j qS r'   r5   r   r'   r'   r(   	<setcomp>  r4   z4validate_unbounded_mode.<locals>.<genexpr>.<setcomp>Nr   rb   )holomap_kdimsr'   r(   r)     s   z*validate_unbounded_mode.<locals>.<genexpr>z{DynamicMap that are unbounded must have key dimensions that are a subset of dimensions of the HoloMap(s) defining the keys.c                 3   s:   | ]2}   D ]$\}}||jv rt|||V  qqd S r"   )rR   rs   r   r   )r%   rc   r   Zhmrange)hmrangesr'   r(   r)     s   zGHoloMap(s) have keys outside the ranges specified on the DynamicMap(s).)r
   rP   setr   r*   r<   r   )holomapsdynmapsr'   )r   r   r   r(   validate_unbounded_mode  s    
r   c                 C   sd   |  dd tg}|  dd dg}tdd |D }|rFt|| n|rV|sVtd|o^| |fS )zEReturns the common mode of the dynamic maps in given composite objectc                 S   s   | S r"   r'   ri   r'   r'   r(   rk     r4   z"get_dynamic_mode.<locals>.<lambda>c                 S   s   | S r"   r'   ri   r'   r'   r(   rk     r4   r
   c                 s   s   | ]}|j V  qd S r"   )rn   )r%   mr'   r'   r(   r)     r4   z#get_dynamic_mode.<locals>.<genexpr>z[DynamicMaps in unbounded mode must be displayed alongside a HoloMap to define the sampling.)rm   r   r*   r   r<   )r   r   r   Zdynamic_unboundedr'   r'   r(   get_dynamic_mode  s    r   c                 C   sJ   t tdd |D |}z| jf dtgi| W n tyD   Y n0 dS )z8
    Initializes any DynamicMaps in unbounded mode.
    c                 S   s   g | ]
}|j qS r'   r5   r   r'   r'   r(   r     r4   z(initialize_unbounded.<locals>.<listcomp>Zselection_specsN)dictr   selectr   rv   )r.   r   r|   r   r'   r'   r(   initialize_unbounded  s
    r   c           	         s^   t  t||j} fddt|D }t||}|du rD|ddfS || d }||||kfS )zz
    Given a plot, subplot and dynamically generated (Nd)Overlay
    find the closest matching Element for that plot.
    c                    s(   g | ] \}\}}|t  t||fqS r'   )r   r   )r%   r   rZ   r/   overlayr'   r(   r     s   
z"dynamic_update.<locals>.<listcomp>NFrE   )r   r   current_framerP   r   )	r   Zsubplotr|   r   rR   r   rl   Zclosestmatchedr'   r   r(   dynamic_update  s    


r   Tc                 C   s   t |tr*t|}t|| }|| } nVt |tr>|\}}nt| t|  }}| | ||  } tjj	| t
t| d} || } |rt| S | S dS )z[
    Maps an array of values to RGB hex strings, given
    a color range and colormap.
    )maskN)r#   r   r   ZargsortZsearchsortedrt   ZnanminZnanmaxmaarrayZlogical_notr   rgb2hex)ZarrZcrangecmaphexZxsortedZyposcmincmaxr'   r'   r(   
map_colors  s    




r   c                    sd   t  |kr`|r,|r, fddt|D  n4d\}}t|t  d | |} fdd|D   S )zL
    Resample the number of colors in a palette to the selected number.
    c                    s   g | ]} |t    qS r'   rF   r%   r   paletter'   r(   r   (  r4   z$resample_palette.<locals>.<listcomp>)g      gP@?rE   c                    s   g | ]} t t| qS r'   )intr   roundr%   r[   r   r'   r(   r   ,  r4   )rF   r   r   linspace)r   ncolorsr   cmap_categoricalZlpadZrpadZindexesr'   r   r(   resample_palette"  s    r   c                    sT  ddl }ddlm}m} |pd}t |s dr@ dd t|jtdk rddl m	} z|
  W q ty   |
   Y q0 n"dd	l m} | |   t |r8|r܇ fd
dt|D S  j|kr8dd  t jD t|kr4fddtdtd |D S dd  tdd|D S )zH
    Converts a matplotlib colormap to palette of RGB hex strings."
    r   N)ColormapListedColormap   Categorytabz3.5cm)	colormapsc                    s    g | ]}t  j| j  qS r'   )r   colorsNr   r   r'   r(   r   I  r4   z&mplcmap_to_palette.<locals>.<listcomp>c                 S   s   g | ]}t |qS r'   r   r%   cr'   r'   r(   r   L  r4   c                    s   g | ]} t | qS r'   r   r   r   r'   r(   r   N  r4   rE   c                 S   s   g | ]}t |qS r'   r   r   r'   r'   r(   r   P  r4   )
matplotlibZmatplotlib.colorsr   r   r#   
startswithreplacer   __version__r   Zget_cmapr<   lowerr   r   r   r   r   ZarangerF   r   )r   r   r   mplr   r   r   r   r'   )r   r   r(   mplcmap_to_palette0  s0    

$r   c                    sj   ddl m} dg}|pd}t fdd|D } drTtt| d d  }n|  }t||||S )	Nr   r   glasbeyr   c                 3   s   | ]}| v V  qd S r"   r'   r   r   r'   r(   r)   Y  r4   z+colorcet_cmap_to_palette.<locals>.<genexpr>_r)colorcetr   r*   endswithrO   reversedr   )r   r   r   r   
categoriesr   r'   r   r(   colorcet_cmap_to_paletteS  s    
r   c           	         s  ddl m} g d}t fdd|D }d} drH d d  d	}| of  |jvof d
 }|rr| }|pxd} dr dd  |jv r|j  }nt	| t	|  d }|d u rt
d  dn8t|tr |v s  |v r| |  }t|trH|t| }|sZt||k rZt||}nt|rZ||}|rn|d d d }tt||||S )Nr   palettes)	ZaccentcategorydarkZ
colorblindZpastelZset1Zset2Zset3Zpairedc                 3   s   | ]}|   v V  qd S r"   r   r%   catr   r'   r(   r)   i  r4   z+bokeh_palette_to_palette.<locals>.<genexpr>Fr   r   Tfirer   r   r   zSupplied palette z not found among bokeh palettes)bokehr   r*   r   
capitalizer   r   r   all_palettesgetattrr   r#   r   r   rV   rF   polylinear_gradientcallablerO   r   )	r   r   r   r   r   r   reverseinvertedr   r'   r   r(   bokeh_palette_to_palettec  s>    



"
r  
   c                    sZ   t | t | g}tdD ]* fddtdD }|| q dd |D S )z?
    Interpolates the color gradient between to hex colors
    rE   c                    s8   g | ]0}t | td    | |    qS )rE   )r   float)r%   jr   nrN   tr'   r(   r     r4   z#linear_gradient.<locals>.<listcomp>r   c                 S   s   g | ]}t d d |D qS )c                 S   s   g | ]}|d  qS )g     o@r'   r   r'   r'   r(   r     r4   z.linear_gradient.<locals>.<listcomp>.<listcomp>r   )r%   rgbr'   r'   r(   r     r4   )hex2rgbr   rS   )Z	start_hexZ
finish_hexr  gradientZcurr_vectorr'   r  r(   linear_gradient  s    r  c                 C   s   t t|t| d  }t| d | d |}t| t|kr@|S tdt| d D ]@}t| | | |d  |d }|t|dkr|dd n|7 }qR|S )zH
    Interpolates the color gradients between a list of hex colors.
    rE   r   N)r   r  rF   r  r   )r   r  Zn_outr  colZnext_colorsr'   r'   r(   r    s    "r  CMapInfor6   providerr   sourcebg)r   r  r   c                    s  | du rt } n,t| tr:| t vr4td| dt | g} g } fdd}d| v rz~ddl}ddlm} t|d	r~t|j}n*t|d
rt|j	}nt|j
t|j }||d|7 }||ddd |D 7 }W n ty   Y n0 d| v r>z:ddlm} ||d|j7 }||ddd |jD 7 }W n ty<   Y n0 d| v rzJddlm}m}	 |	 }
||
d< ||d|
7 }||ddd |
D 7 }W n ty   Y n0 tt|S )z
    List available colormaps by combining matplotlib, bokeh, and
    colorcet colormaps or palettes if available. May also be
    narrowed down to a particular provider or list of providers.
    NzColormap provider z  not recognized, must be one of c                    s   r fdd|D S t |S )Nc              	      s   g | ]}t | d d d dqS )Nr  )r  )r%   r  r  r'   r(   r     r4   z-_list_cmaps.<locals>.info.<locals>.<listcomp>)rO   )r  namesrecordsr   r(   r     s    z_list_cmaps.<locals>.infor   r   r   r   _cmap_registryc                 S   s   g | ]}| d s|d  qS r   r   )r%   r   r'   r'   r(   r     s   
z_list_cmaps.<locals>.<listcomp>r  r   c                 S   s   g | ]}| d s|d  qS r%  r&  rH   r'   r'   r(   r     s   
r   )
glasbey_hv	palette_nr'  c                 S   s   g | ]}| d s|d  qS r%  r&  rH   r'   r'   r(   r     r4   )	providersr#   strr   r   r   hasattrrO   r   r$  Zcmaps_listedZdatadImportErrorr  r   r	  r   r'  r(  copysortedr   )r  r#  Zcmapsr   r   r   	mpl_cmapsr   r'  r(  Zcet_mapsr'   r"  r(   _list_cmaps  sP    





r0  c                 C   s(   |D ]}t tt||| ||d qdS )a  
    Maintain descriptions of colormaps that include the following information:

    name     - string name for the colormap
    category - intended use or purpose, mostly following matplotlib
    provider - package providing the colormap directly
    source   - original source or creator of the colormaps
    bg       - base/background color expected for the map
               ('light','dark','medium','any' (unknown or N/A))
    r  N)bisectinsort	cmap_infor  )r   r  r  r  r!  r6   r'   r'   r(   register_cmaps  s
    r4  c                 C   s  t | dd}t }|D ]X}	|	j}
d}|
dr<|
dd n|
}|du sl|dkrZ|
dsl|dkr|
dstD ]}|j|krpd}|j|
d}|
dr|jdkr|jd	kr|jd
d}n|jd
kr|jd	d}|du s||jv rp| du s| |jv rp|du s||jv rp|du s||j	v rp|du s0||jv rp|
| qp|s|du sR|dkrt|
|	jdddd}|
| q|rt|dd dS tttdd |D dd dS dS )z?
    Return colormap names matching the specified filters.
    T)r  r#  Fr   Nr   r5   	Diverginglightr  )r  Miscellaneous)r  r   r  r  c                 S   s.   | j dd | jpd| j | j| jp*dfS )N r   )r   splitr  r6   r   r  r  )r   r'   r'   r(   rk   -  r4   zlist_cmaps.<locals>.<lambda>)r|   c                 S   s   g | ]
}|j qS r'   r5   )r%   Zrecr'   r'   r(   r   0  r4   zlist_cmaps.<locals>.<listcomp>c                 S   s   |   S r"   r  )r  r'   r'   r(   rk   0  r4   )r0  r   r6   r   r3  _replacer   r  r  r  addr  r.  rO   r   )r  r#  r6   r   r  r  r  	availablematchesZavailanamer   basenamer   r'   r'   r(   
list_cmaps  sf    



rA  zUniform Sequentialr   Zbidsr  )ZviridisZplasmaZinfernoZmagmaZcividiszMono SequentialZcolorbrewerr6  )GreysPurplesBluesGreensOrangesRedsYlOrBrYlOrRdOrRdPuRdRdPuBuPuGnBuPuBuYlGnBuPuBuGnBuGnYlGnzOther SequentialmiscZ	gist_yargbinary)ZafmhotgrayZboneZ	gist_grayZ	gist_heatZhotZpinkr*   )ZcopperZspringZsummerZautumnZwinterZcoolZWistiar5  )	ZBrBGZPiYGZPRGnZPuOrZRdBuZRdGyZRdYlBuZRdYlGnZSpectral)coolwarmZbwrZseismicZCategorical)ZAccentZDark2ZPairedZPastel1ZPastel2ZSet1ZSet2ZSet3Zd3)Ztab10Ztab20Ztab20bZtab20cZRainbowZnipy_spectralZ	gist_ncar)ZbrgZhsvZgist_rainbowrainbowZjetr7  )ZCMRmapZ	cubehelixZ
gist_earthZ
gist_sternZgnuplotZgnuplot2ZoceanZterrainflagZprismr   Zcet)	ZbgywZbgyZkbcZbmwZbmyZkgyrV  Zdimgrayr  )ZbluesZkrZkgkbzUniform Diverging)rW  ZgwvZbwyZcwrZbkrZbkyZmediumZbjyzUniform Rainbow)rX  Z
colorwheelZisolumr  )ZViridisZPlasmaZInfernoZMagma)rD  rR  rM  rN  rE  rB  rJ  rF  rO  rQ  rK  rC  rL  rG  rS  rP  rH  rI  )Z
Category10Z
Category20ZCategory20bZCategory20cZ
ColorblindzUniform Categorical)r   Zglasbey_coolZglasbey_warmr'  Zglasbey_lightZglasbey_darkc                    s  |du rdn|}t | tr.dd | jD  nt | trDt|  nt | trT|  nt | trtd}td}td}|dks|du r| |v s|  |v rt| || nr|dks|du r| |v s| 	 |v rt
| || n@|dks|du r| |v rt| || ntd|  d	| d
n(zt| | W n tyD   d Y n0 t  tshtd|  d| d|rt |kr fddt|D S  S )zD
    Convert valid colormap specifications to a list of colors.
    Nzmatplotlib, bokeh, or colorcetc                 S   s"   g | ]}t |trt|n|qS r'   )r#   rt   r   r   r'   r'   r(   r     r4   z process_cmap.<locals>.<listcomp>r   r  r   zSupplied cmap z not found among z colormaps.zcmap argument z  expects a list, Cycle or valid z colormap or palette.c                    s   g | ]} |t    qS r'   r   r   r   r'   r(   r     r4   )r#   r   r,   rt   rO   r*  r0  r   r   r  r  r   r   r<   	TypeErrorrF   r   )r   r   r  r   Zproviders_checkedr/  Zbk_cmapsZ	cet_cmapsr'   r   r(   process_cmap  s6    


$$
r\     c                 C   sJ  t | t |d kr(td|t | f t|}t|t| }}|| }g }t|| D ]&\}	}
||
gtt||	|   7 }qZ|durB|\}}tt||| |  }tt||| |  }|| }||kr|d }||| }||krBt	t
t|| }t ||d kr.|||d  n||d |d  }||fS )a  
    Maps the supplied colors into bins defined by the supplied levels.
    If a clip tuple is defined the bins are clipped to the defined
    range otherwise the range is computed from the levels and returned.

    Arguments
    ---------
    colors: list
      List of colors (usually hex string or named colors)
    levels: list or array_like
      Levels specifying the bins to map the colors to
    clip: tuple (optional)
      Lower and upper limits of the color range
    N: int
      Number of discrete colors to map the range onto

    Returns
    -------
    cmap: list
      List of colors
    clip: tuple
      Lower and upper bounds of the color range
    rE   zwThe number of colors in the colormap must match the intervals defined in the color_levels, expected %d colors found %d.Nr   )rF   r   r   diffminrV   r   r   r   Zargminabsr   )r   levelsZclipr   Z	intervalsr   r   intervalr   Zintvr   ZclminZclmaxZlidxZuidxidxr'   r'   r(   color_intervals  s,    

 

6rd  , c                 C   s$   t | ts| g} |dd | D S )z;
    Returns an axis label for one or more dimensions.
    c                 S   s   g | ]
}|j qS r'   )Zpprint_labelr   r'   r'   r(   r     r4   z"dim_axis_label.<locals>.<listcomp>)r#   rO   r   )r   	separatorr'   r'   r(   dim_axis_label  s    rg  c                 C   sp   d}t | tr@td| }|r<| }| |d}t|} n| S |rL| | } |durl| ddd| } | S )z/
    Scales a numeric or string font size.
    Nz[-+]?\d*\.\d+|\d+r9  z.3f0.)r#   r*  rematchgroupr   r  rstrip)sizeZscalingextrk  valuer'   r'   r(   scale_fontsize  s    

rq  皙?c                    s    fdd}| |tgS )z=
    Attaches plot refresh to all streams on the object.
    c                    s,   t | D ]} j|jvr| j qd S r"   )r   Zrefresh_subscribersZadd_subscriber)rd   streamr   
precedencer'   r(   append_refresh  s    z&attach_streams.<locals>.append_refresh)rm   r   )r   r.   rv  rw  r'   ru  r(   attach_streams	  s    rx  c                    s   |   fdd dS )z
    Traverses the object and sets the supplied attribute on the
    object. Supports Dimensioned and DimensionedPlot types.
    c                    s   t |  S r"   )setattrri   	attributerp  r'   r(   rk     r4   z!traverse_setter.<locals>.<lambda>N)rm   )r.   r{  rp  r'   rz  r(   traverse_setter  s    r|  c                 C   s   |  ddg}t v tdd |dtj}t|j	| }t
|tj ||dk }t|r~| W  d   S W d   n1 s0    Y  dS )z8
    NumPy based implementation of get_min_distance
    r   rE   ignorezinvalid value encountered infloat32N)r   warningscatch_warningsfilterwarningsastypeviewr   Z	complex64r`  TZfill_diagonalinfrF   r_  )r   ZxysZ	distancesr'   r'   r(   _get_min_distance_numpy  s    
4r  c                 C   sD   z$ddl m} || ddg W S  ty>   t|  Y S 0 dS )zW
    Gets the minimum sampling distance of the x- and y-coordinates
    in a grid.
    r   )pdistrE   N)Zscipy.spatial.distancer  r   r_  r<   r  )r   r  r'   r'   r(   get_min_distance,  s
    r  c              
   C   s   | j }|jd|jd}g }|D ]}|d \}}|d \}}	t|	| || }
|t|
tjd  |  }|	t|
tjd  |  }|t|
tjd  |  }|	t|
tjd  |  }t||f||	ftj	tj	f||f||	f||fg}|
| q|S )zt
    Computes paths for a directed path which include an arrow to
    indicate the directionality of each edge.
    r   )datatyper   r   rE      )Z_split_edgepathsr:  rs   r   Zarctan2cospisinr   r   rS   )r   Zarrow_lengthZ	edgepathsedgesZarrowsrA   ZsxZsyexZeyZradZxa0Zya0Zxa1Zya1Zarrowr'   r'   r(   get_directed_graph_paths8  s     r  c                 C   s,   t | dkr| dd } djdd | D  S )z&
    Convert RGB(A) tuple to hex.
    r   Nr  z#{:02x}{:02x}{:02x}c                 s   s   | ]}t |d  V  qdS )r]  Nr   r   r'   r'   r(   r)   T  r4   zrgb2hex.<locals>.<genexpr>)rF   r=   )r  r'   r'   r(   r   N  s    r   c                 C   s>   t | tr4t| }|dr:|dr:|dd }n| j}|S )z7
    Returns the key to look up a dimension range.
    zdim('z')   r   )r#   r!   reprr   r   r6   )ZeldimZdim_namer'   r'   r(   dim_range_keyW  s    
r  c                    s    fddt dddD S )z "#FFFFFF" -> [255,255,255] c                    s"   g | ]}t  ||d   dqS )r      r   r   r   r'   r(   r   g  r4   zhex2rgb.<locals>.<listcomp>rE      r   r   r  r'   r  r(   r  d  s    r  c                   @   s8   e Zd ZejddZejdddZdd Zd
dd	Z	dS )apply_nodataT)defaultNz
        Optional missing-data value for integer data.
        If non-None, data with this value will be replaced with NaN so
        that it is transparent (by default) when plotted.r  docc                 C   s>   | d}|| jjk}t|dr.||tjS t||tjS )z=Replace `nodata` value in data with NaN, if specified in optsfloat64where)r  rI   nodatar+  r  r   r   )selfru   r   r'   r'   r(   _replace_values  s
    

zapply_nodata._replace_valuec                 C   s   | j jd u r|S t|drb|jd }|j||}|jdvr@|S t|| j}|j	f i |j
|iS |jdddj}|jjdvr|S |d}|| |S d S )N	interfacer   iur   F)Zflatr  )rI   r  r+  vdimsr  r   r   r!   r  	transformr6   dimension_valuesr  r  r   )r  r   r|   Zvdimr   r  r   r'   r'   r(   _process{  s    



zapply_nodata._process)N)
r1   r2   r3   r9   BooleanrT   ZIntegerr  r  r  r'   r'   r'   r(   r  j  s   r  z^#(?:[0-9a-fA-F]{3}){1,2}$)r   r   rE   )r         ?r  )r   g      ?r   )r   r   r   )r  r   r  )rE   r   r   )rE   rE   rE   )r  r  r   )r   r   r   r   )	br   grZ   r   r   wyZtransparent)gwg?gbx>r   )g@gҦ?gC?r   )gM~N?g
<"?r   )g-9(a?g^W*^+?r   )g7?gM%,Fq2?r   )gX?gX|[T7?g72{<)gؿ?g_1D<?g'i˲`<)gϽK;?g8@?g`x<)gQfL2r?gMl^0C?r   )gs?gnTe	G?r   )g7̒?g3pV?r   )gcAJ?gLsW?r   )gD4ؙ?g?JTT?r   )god?gvb Y?r   )gb?g-R\?r   )gQH?gj}]X?r   )gwJ?gLX?r   )g]P?gAȘ`?r   )g&?gjP`?r   )g8gDio?gjD\?r   )g6o1?g&"dTY?gjUCɁ>)g:ǀ?g-Z?gw(;[?)g?gS3+\?gzm|?)gݰmQf?gQ2n]?gy^u>)gB?go=1_?gr>>)g0Bxq?g_!se`?gGm?)g4c?g%7a?g%>?)goe1?gtb?gvŷpS>)g2d?g+gb?gYAi.>)g*<?g (c?g(=?)gFw;S?g簱d?g[NIC>)gi?gZ)e?gR>T>)g9]?g2f?g>)gx?ggg,g?gߺ]?)grPL?g@7oh?gq)\>)g?x=?gei?g`>)g0?g-%&k?g/sA?)gNE*-?g2$)l?g3Qh2?)gGg?gpWm?gST->)g?gng_yn?gݟ>)gXO0?gαro?gA	N\?)g0GĔ?gRm"p?gU"(>)gN]?g_7q?gA/b>)g^?gq?g+.zf1?)g?gRp'lr?g;fF>)gk)?g3Rs?gb">)g	?g-t?gqG͑tQ>)gJ^c@?gNt?g:t/?)g>٬\?gWu?g*=->)g?gHiv?gga>)gBC+?g?5g3=w?gzk?)gQy?gOjx?g>)g/?g+|"x?g휌H>)g2bb?g]91y?g}n?)g\?ggP<z?g2S>)gP}:3?ghyܝ{?g-%=>)g\*?g)ko|?gv8 ?)g4)?gY^!}?gw|HF>)gXVn?gd4<~?gG}j}>)g?g[?gٶtA= ?)g6!A?gM`g?gd>)g@"2?g͎%?g8>)g9]?ggp?g>)g/$?gaWI?g;>)g@?gy?g.v>)g+?g)bS?g{v>)gp1=a?gk?gu">)g{?g4yS?g1E8>)gU?g[z4?gr.2>)g<?gajK?g$?>)gMbX9?gk?g>)g[='o?g:6U?gPnD*>)gg67?gdϞ$?g(;>)g? M?gZ?g?8>)gN@?gǁW˝?gk%el>)gcAJ?gZa?g{c>)gTr3܀?g&4?gJ>)gdCԷ?gEaE?gd/±>)gW>?g;?g>Qr>)g.&?g&(̍?g@7<`>)gN]?g,?gW('>)gMO?g??gI.6>)g9?ghUM?gY};>)gݘ?g|zlː?gPԠ>)g4Ry;?gyrM?gz%t>)gYBs?g#ӑ?g@w>)gZ!?gV
\?gP>)gPc*?g?g0 ʋ>)g#G?gC?{?glTh>)g3yS?gD?gw.>)g]wb֋?g7櫔?g?I>)g?gbJ?gHf~ >)g*?gR.?gXBT>)g8*5?gk?gq>)g m?gQ&E?g[Z>)g؞Y?gUP?g7>)gVzNz?gV,?gv`0>)gXQi?g|r?gq~V>)gQ?gY8?g~,>)g
ϛ?g?gPrm&>)g?gڛ?r   )gx?g~U.T?r   )gz6?g҈?r   )go?g@v?r   )gui?gR{?r   )g ?g:ؗl<?r   )g{?gb? ?r   )gJiWV?g}F?r   )gUB?g!?r   )g`-?gKHr?r   )g3?gr3܀?r   )gup>?g?Z?r   )gd]Fx?g9ӄ'c?r   )gR?g9Վ?r   )g@?gե?r   )gKR%?gWL?r   )gV_?gٕz?r   )g`Ù?giƢd?r   )g.o?g3Ib?r   )g+j0?ggc?r   )gfc]F?g3Mg'?r   )gUMu?gA)V¬?r   )g~ R8?gn!?r   )go?gd<J%<?r   )g}Жs)?gVpA?r   )g9(a_?gXǱ?r   )g0*?g҈}?r   )gj?gpwnд?r   )gdu?gyUg?r   )g0L
F%?gj4?r   )gHP?gvOjM?r   )g	h"lx?g}bٽ?r   )g!X4?gdF?r   )g9b->?g+ٱ?r   )g:@0G?g@j'?r   )g#gaO;?gMۿҤ?r   )gq@H?gg
%?r   )gY-?gy?r   )gkC?g <.?r   )gDV?gC9Ѯ?r   )gղHh?gZ*oG8-?r   )gd]Fx?gn\?r   )gJY?gBL?r   )gPI5?gʡE?r   )gW[?g`"?r   )gU+~?g#GG?r   )g"?gBxqZ?r   )gM»?gI ?r   )gO`?g@_?r   )gn?geV?r   )g#bJ$?gB>٬?r   )gףp=
?gyt?r   )gjH?g~:?r   )gi?g>'I?r   )gL7A`?gS!uq?r   )gY9?g~k,	?r   )g?W[?gm?r   )g M?gl!A	3?r   )gQN?gi o?r   )gX?g|a2U?r   )g@j'?gZӼ?r   )g~k	?g+yp?r   )gB>٬?g1 {?r   )g\U]?git3?r   )g6?g:M?r   )g?gNz1?r   )gf?g?r   )gA	3m?g%ǝ?r   )gVe?g7l[ ?r   )rE   gQkw?r   )rE   gn?r   )rE   gS.Q?gy]JS>)rE   gUB?gɋ?)rE   g;%?g,l?)rE   g镲?gk,&?)rE   g'UHI?gJ0?)rE   g-&6׆?gQda7?)rE   g<!7?g
%@?)rE   gH.?gh*D?)rE   g&S:?g/]E\J?)rE   gdu?gߗ#@4P?)rE   gJ?gUbCAS?)rE   gC5v?g)FL?W?)rE   gjjZ_$?g(s=[?)rE   gʦ\]?g7`	_?)rE   g{?gv$$b?)rE   grt?gwcd?)rE   g
p?gUYXg?)rE   gm4@?g{
%8j?)rE   gx?gȱSnGm?)rE   g.Q5?gBp?)rE   gH|?g	q?)rE   gQ?gO}s?)rE   gh?RDU?g!9u?)rE   gME*?g~}w?)rE   glscz?gly?)rE   gh㈵?gC|?)rE   gtA}˜.?gz~?)rE   gN#Ed?gsy?)rE   gD4ؙ?gw/Rā?)rE   gŧ ?gi[%?)rE   g1߄B?g>I?)rE   g<.9?g(Bv?)rE   g m?g9d?)rE   gm~?gF0E?)rE   gD?gAL?)rE   gA&9?gA)V?)rE   gp>??gK?)rE   g-s?g2SZK?)rE   gIK?gR?o*R?)rE   g*?gx'e?)rE   g,?gb*?)rE   gK7A?go[t?)rE   g~jt?gzPPV?)rE   g+ڧ?g	m9?)rE   g?g0GĔ?)rE   g=!7?gG˵h?)rE   g[Ɏ@?g2;ީ?)rE   g-s?gwIQ?)rE   gb?gU?)rE   gG ^/?gWt5=?)rE   gqZ|
?g#bJ$?)rE   g?:u<?gͮ{+?)rE   gypwn?gV,?)rE   gk	?g]gE?)rE   g^F?g!s?)rE   gzk`?gvhX?)rE   gz6?g5
?)rE   gJh?gҤt{?)rE   g}"O?gME?)rE   g	^)?gR{mǬ?)rE   g*?gk?)rE   gvq-?gec]?)rE   g4)^?g@1d?)rE   gW?gǚA?)rE   g̯ ?g\sG˵?)rE   go?gr4?)rE   gq&"?gPN?)rE   gʉvR?g(ILپ?)rE   gh o?g\[%X?)rE   g㥛 ?gAf?)rE   g?gÙ_?)rE   g*	?gӟH?)rE   gJ4?g1*?)rE   gAH0[?gAe?)rE   g?g^x?)rE   g=U?g~nض?)rE   g|?5^?ge,i?)rE   gB=?gZ ?)rE   gzG?gH}?)rE   gJR?gKTol?)rE   g؁sF?gC9Ѯ?)rE   g@ޫV&?g!u?)rE   g:3P?g|,}?c                 C   sB   g | ]:\}}}d t |d dt |d dt |d dqS )#r]  Z02xr   )r%   r   r  r  r'   r'   r(   r   #  s   r   c                   @   s"   e Zd ZdZe ZdddZdS )categorical_legendz
    Generates a Points element which contains information for generating
    a legend by inspecting the pipeline of a datashaded RGB element.
    Nc                    s  dd l }ddlm}m}m} |jj|dd}t||r<|}n|jj|dd}d ||fv r\d S |j}	|jj	d |	}
|
|
|j}t||j|jfsd S |j}t|	jdrzt|	jj| j}W n( ty   t|	jj| j }Y n0 |dgkr t|	j| j j}nt|	j|dd}|jp.|jj d	d
 |D }t trb fddt|D }n fdd|D }i }| D ]8\}}t|trtdd
 |d d D }|||< qt |dgdj!|dd| j"j#ddS )Nr   r   )	datashade	rasterizeshadeF)Zskip_nonlinkeddtypesZ__UNKNOWN_CATEGORIES__)r@   c                 S   s   g | ]}d d |fqS )r   r'   r  r'   r'   r(   r   K  r4   z/categorical_legend._process.<locals>.<listcomp>c                    s   i | ]\}}| | qS r'   r'   )r%   r   r  r   r'   r(   r   M  r4   z/categorical_legend._process.<locals>.<dictcomp>c                    s   i | ]}| | qS r'   r'   r  r  r'   r(   r   O  r4   c                 S   s   g | ]}|d  qS )r   r'   r   r'   r'   r(   r   S  r4   r   r   )r  T)r   colorZshow_legendbackendZvisible)$Z
datashaderoperation.datashaderr  r  r  Zpipelinefindr#   Zdataset
operationsZ_get_aggregatorZ
aggregatorZ	count_catZbycolumnr+  ru   rO   r  r   r[  Z	to_pandasr  Zas_knownr  Z	color_keyr   ZSets1to3rP   rR   rt   r   r   optsrI   r  )r  r   r|   Zdsr  r  r  Zrasterize_opZshade_opZhvdsZinput_elZaggr  ZcatsZ
color_dataZ
cat_colorsr   r  r  r'   r  r(   r  /  sH    
zcategorical_legend._process)N)r1   r2   r3   __doc__r9   Stringr  r  r'   r'   r'   r(   r  '  s   r  c                   @   s(   e Zd ZdZeji ddZdddZdS )flatten_stackz
    Thin wrapper around datashader's shade operation to flatten
    ImageStacks into RGB elements.

    Used for the MPL and Plotly backends because these backends
    do not natively support ImageStacks, unlike Bokeh.
    zF
        Additional parameters passed to datashader's shade operation.r  Nc              
   C   sR   zddl m} W n. ty> } ztd|W Y d }~n
d }~0 0 ||fi | jS )Nr   )r  z+Flattening ImageStacks requires datashader.)r  r  r,  shade_params)r  r   r|   r  excr'   r'   r(   r  f  s
     zflatten_stack._process)N)r1   r2   r3   r  r9   Dictr  r  r'   r'   r'   r(   r  Z  s   r  )N)r   )F)F)F)T)NF)NF)NF)r  )NF)NFNNNNN)NNF)Nr]  )re  )rr  )jr1  rj  ry   r  collectionsr   r   numpyr   r9   Zpackaging.versionr   corer   r   r   r	   r
   r   r   r   r   Zcore.ndmappingr   Zcore.operationr   Zcore.optionsr   r   Zcore.spacesr   Z	core.utilr   r   r   r   r   r   r   r   r   r   r   rX   r   r   Zutil.transformr!   r-   ZParameterizedr0   r8   r;   rD   rG   rQ   ra   rg   re   r}   r   r?   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r3  r  r)  r0  r4  rA  r\  rd  rg  rq  rx  r|  r  r  r  r   r  r  r  compileZRGB_HEX_REGEXZCOLOR_ALIASESZfire_colorsZlinear_kryw_0_100_c71r  r  r  r'   r'   r'   r(   <module>   sR  ,,
2N"%#.: 
5



























%1	#

 
3