def get_colors(palette, funcs):
 palettes = import_required('bokeh.palettes', _BOKEH_MISSING_MSG)
 tz = import_required('toolz', _TOOLZ_MISSING_MSG)
 unique_funcs = list(sorted(tz.unique(funcs)))
 n_funcs = len(unique_funcs)
 palette_lookup = palettes.all_palettes[palette]
 keys = list(sorted(palette_lookup.keys()))
 index = keys[min(bisect_left(keys, n_funcs), (len(keys) - 1))]
 palette = palette_lookup[index]
 palette = list(tz.unique(palette))
 if (len(palette) > n_funcs):
  random.Random(42).shuffle(palette)
 color_lookup = dict(zip(unique_funcs, cycle(palette)))
 return [color_lookup[n] for n in funcs]

def get_colors ( palette , funcs ) : palettes = import_required ( 'bokeh.palettes' , _BOKEH_MISSING_MSG ) tz = import_required ( 'toolz' , _TOOLZ_MISSING_MSG ) unique_funcs = list ( sorted ( tz . unique ( funcs ) ) ) n_funcs = len ( unique_funcs ) palette_lookup = palettes . all_palettes [ palette ] keys = list ( sorted ( palette_lookup . keys ( ) ) ) index = keys [ min ( bisect_left ( keys , n_funcs ) , ( len ( keys ) - 1 ) ) ] palette = palette_lookup [ index ] palette = list ( tz . unique ( palette ) ) if ( len ( palette ) > n_funcs ) : random . Random ( 42 ) . shuffle ( palette ) color_lookup = dict ( zip ( unique_funcs , cycle ( palette ) ) ) return [ color_lookup [ n ] for n in funcs ]
returns k colours selected by the colorspiral object .