
    -eR1                        d dl mZ d dlZ ej        e          Zd dlZd dlmZ d dl	Z
ddlmZ ddlmZmZmZ ddlmZ dd	lmZmZ d
Zg dZddZd Zd Zdi i fdZd Zd Zd Zd Zd Z dZ!dS )    )annotationsN)Iterable   )	ColorSpec)ColumnarDataSourceColumnDataSourceGlyphRenderer)	nice_join   )pop_legend_kwargupdate_legend)create_renderer
make_glyphpop_visuals)namecoordinatesx_range_namey_range_namelevelviewvisiblemutedc                r    g d}| r*| j         }d |D             }t          |          }||         S |d         S )N)z#1f77b4z#ff7f0ez#ffbb78z#2ca02cz#98df8az#d62728z#ff9896z#9467bdz#c5b0d5z#8c564bz#c49c94z#e377c2z#f7b6d2z#7f7f7fz#bcbd22z#dbdb8dz#17becfz#9edae5c                (    g | ]}|j         d k    |S )r	   )__view_model__.0xs     8lib/python3.11/site-packages/bokeh/plotting/_renderer.py
<listcomp>z%get_default_color.<locals>.<listcomp>A   s%    QQQ1Q-=-P-PQ-P-P-P    r   )	rendererslen)plotcolorsr"   num_rendererss       r   get_default_colorr'   2   sW      F  N	QQ	QQQ	Im$$ayr!   c           	        t          |          }t          |          }t          |          }|d         }t          | |          }g }|t	          | |||          z  }|t	          | |||          z  }|r&t          t          t          |d          z            t          | |d|ddi          }	t          d |D                       rt          | |d	|
          }
nd }
t          d |D                       rt          | |d|
          }nd }t          | |d|ddi          }t          | ||          }t          | ||	          }t          | ||
          }t          | ||          }t          | ||          }t          d||pd|pd||pdd|}|j                            |           |rt          |||           |S )Ndata_sourceand)conjunctionnonselection_alphag?)prefixdefaultsoverride_defaultsc              3  @   K   | ]}|                     d           V  dS )
selection_N
startswithr   s     r   	<genexpr>z"create_renderer.<locals>.<genexpr>c   s.      
6
6!1<<%%
6
6
6
6
6
6r!   r2   )r.   r/   c              3  @   K   | ]}|                     d           V  dS )hover_Nr3   r   s     r   r5   z"create_renderer.<locals>.<genexpr>i   s.      
2
2a1<<!!
2
2
2
2
2
2r!   r7   muted_g?auto)glyphnonselection_glyphselection_glyphhover_glyphmuted_glyph )_convert_data_sourcer   _pop_renderer_argsr   _process_sequence_literalsRuntimeError_GLYPH_SOURCE_MSGr
   anyr   r	   r"   appendr   )
glyphclassr$   kwargsis_user_sourcelegend_kwargrenderer_kwssourceglyph_visuals incompatible_literal_spec_valuesnonselection_visualsselection_visualshover_visualsmuted_visualsr:   r;   r<   r=   r>   glyph_renderers                      r   r   r   L   s_   )&11N $F++L &f--L-(F  
F33M')$$(B:vW]_m(n(nn$$(B:}^dft(u(uu$' o,y9Ygl/m/m/mmnnn 'z6/\i  F  GJ  ~K  L  L  L 
6
6v
6
6
666 !'
F<Zghhh  
2
26
2
2
222 #JxR_```  
F8mpwx{o|}}}Mz6=99E#J8LMM V5FGGOZ??KZ??K" -7'16)6   N 	N.))) : 	dL.999r!   c                l    |d S |                                 }|                    |            | di |S )Nr?   )copyupdate)rG   kwsextras      r   r   r      sA    }t
((**CJJu:r!    c                   |                                 }|                    dd           |                    dd           i }|                    dt                                 |                    dd           t                      t	                      }}t	          |                                           }t          t          |          D ]}	t          |	          \  }
}||	z   |v r|	                    ||	z             ||	<   nI||vr||z   |v r|||z            ||	<   n/||v r||         ||	<   n|	|v r||	         ||	<   n||v r||         ||	<   ||vr|
                    |           |D ]}|	                    ||z   d           |S )a  
    Applies basic cascading logic to deduce properties for a glyph.

    Args:
        glyphclass :
            the type of glyph being handled

        props (dict) :
            Maps properties and prefixed properties to their values.
            Keys in `props` matching `glyphclass` visual properties (those of
            'line_', 'fill_', 'hatch_' or 'text_') with added `prefix` will get
            popped, other keys will be ignored.
            Keys take the form '[{prefix}][{feature}_]{trait}'. Only {feature}
              must not contain underscores.
            Keys of the form '{prefix}{trait}' work as lower precedence aliases
              for {trait} for all {features}, as long as the glyph has no
              property called {trait}. I.e. this won't apply to "width" in a
              `rect` glyph.
            Ex: {'fill_color': 'blue', 'selection_line_width': 0.5}

        prefix (str) :
            Prefix used when accessing `props`. Ex: 'selection_'

        override_defaults (dict) :
            Explicitly provided fallback based on '{trait}', in case property
            not set in `props`.
            Ex. 'width' here may be used for 'selection_line_width'.

        defaults (dict) :
            Property fallback, in case prefixed property not in `props` or
            `override_defaults`.
            Ex. 'line_width' here may be used for 'selection_line_width'.

    Returns:
        result (dict) :
            Resulting properties for the instance (no prefixes).

    Notes:
        Feature trait 'text_color', as well as traits 'color' and 'alpha', have
        ultimate defaults in case those can't be deduced.
    
text_colorblackhatch_colorcolorr-   g      ?N)rU   
setdefaultr'   dictset
propertiesfilter
_is_visual_split_feature_traitpopadd)rG   propsr.   r/   r0   trait_defaultsresulttraits
prop_namesr   _traits               r   r   r      s   V }}Hg...w///Ng'8':':;;;gs+++VVSUUFFZ**,,--Jz:..  '--5 $;% 99VD[11F4LL *$$)>)> .F4LL ''',U3F4LL X#D>F4LL n$$)%0F4L
""JJu & &		&,%%%%Mr!   c                `   |                      dd           d u}|r| d         }t          |t                    sv	 t          |          }n`# t          $ rS}dt          |           d| }t	          |                              t          j                    d                   d }~ww xY w|| d<   |S )NrL   zFailed to auto-convert z' to ColumnDataSource.
 Original error: r   )	get
isinstancer   r   
ValueErrortypewith_tracebacksysexc_info)rH   rI   rL   errmsgs        r   r@   r@      s    ZZ$//t;N &!&"455 		&H)&11 H H HkVkkfikk oo44S\^^A5FGGGH
  &F8s   A	 	
B&AB!!B&c                x      fdt           D             }                     dt                                |d<   |S )Nc                D    i | ]}|v |                     |          S r?   )rf   )r   attrrH   s     r   
<dictcomp>z&_pop_renderer_args.<locals>.<dictcomp>   s8     ! ! ! FJJt$$r!   rL   r)   )RENDERER_ARGSrf   r   )rH   rj   s   ` r   rA   rA      sQ    ! ! ! !'! ! !F #JJx1A1C1CDDF=Mr!   c                
   g }|                                  }|                                D ]\  }}t          |t                    st          |t                    r2||vr7t          |t
                    rMt          ||         t                    r||                             |          rt          |t          j	                  rt          ||         t                    r|j
        dk    r|j        dk    rn|j
        dk    r|j        dk    rn|j
        j        dk    r|j        dk    rn|j
        dk    s|j
        j        dk    r|j        dk    r|j        d         dv rngt          d| d	|j
         d
d                    t!          t
          |j                             d          |j        dk    rt          d| d          |r|                    |           |                    ||           |||<   |S )Nuint32r   uint8Ufr   )      zPColor columns need to be of type uint32[N], uint8[N] or uint8/float[N, {3, 4}] (z is [z, ]zColumns need to be 1D (z is not))r   )	dataspecsitemsrq   r   r`   strr   is_color_tuple_shapenpndarraydtypendimkindshaperC   joinmaprF   rg   )rG   rH   rL   rI   rN   r   varvals           r   rB   rB      sM   ')$$$&&ILLNN * *S #x(( 	 c4   	 i c3 	 ini00 	Ys^5X5XY\5]5] 	c2:&& 	L)C.)44 L9((SX]]Y'))ch!mmY^s**sx1}}i7**cin.C.CUV[^[def[gkq[q[q& (c,/(c (c58Y(c (cAE3sTWT]K^K^A_A_(c (c (c d d dQ"#JS#J#J#JKKK 	,33C8888JJsJ%%%F3KK++r!   c                d    |                      dd          } t          |           dk    r| ng | dS )zAFeature is up to first '_'. Ex. 'line_color' => ['line', 'color']rm   r   r   N)splitr#   )fts    r   re   re   0  s5    	#q		BR!222t,r!   c                6    t          |           \  }}|dv o|duS )z&Whether a feature trait name is visual)linefillhatchtextglobalN)re   )r   featurern   s      r   rd   rd   5  s*    )"--NGUAAWeSWFWWr!   aH  

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

)N)"
__future__r   logging	getLogger__name__logru   collections.abcr   numpyr   core.propertiesr   modelsr   r   r	   util.stringsr
   _legendsr   r   __all__r}   r'   r   r   r   r@   rA   rB   re   rd   rD   r?   r!   r   <module>r      s   # " " " " " g!! 


 $ $ $ $ $ $     ( ' ' ' ' ' H H H H H H H H H H $ $ $ $ $ $ 5 5 5 5 5 5 5 56 6 6   4; ; ;z   +-rR Q Q Q Qn  "  /, /, /,b- - -
X X X
   r!   