holoviews icon indicating copy to clipboard operation
holoviews copied to clipboard

Renaming data attribute on PolyDraw stream creates race condition for styling properties

Open wx4stg opened this issue 1 year ago • 0 comments

bokeh 3.2.2 holoviews 1.18.0 python 3.11.6

The following block of code will create a poly draw tool that produces polygons that are always filled black and show their vertices:

import holoviews as hv
import panel as pn
from holoviews import opts, streams

hv.extension('bokeh')

def myfunc(data):
    print(data)
    return hv.VLine(0.5)

poly1 = hv.Polygons([]).opts(opts.Polygons(fill_alpha=0.3, fill_color='red', active_tools=['poly_draw']))
poly_stream1 = streams.PolyDraw(source=poly1, drag=False, num_objects=1, show_vertices=True,
                                styles={'fill_color' : 'black'}, vertex_style={'size': 5, 'fill_color': 'white', 'line_color' : 'black'}).rename(data='dat')
mirror_to_1 = hv.DynamicMap(lambda dat: myfunc(dat), streams=[poly_stream1])

ax1 = poly1 * mirror_to_1

However, if you replace the poly_stream1 and mirror_to_1 definitions with the following, the polygons will sometimes (around 25%) not show their vertices and will instead be filled red.

poly_stream1 = streams.PolyDraw(source=poly1, drag=False, num_objects=1, show_vertices=True,
                                styles={'fill_color' : 'black'}, vertex_style={'size': 5, 'fill_color': 'white', 'line_color' : 'black'}).rename(data='dat')
mirror_to_1 = hv.DynamicMap(lambda dat: myfunc(dat), streams=[poly_stream1])

Tested with panel and jupyter lab

  • [x] I may be interested in making a pull request to address this (but I will need some guidance as to where to look)

wx4stg avatar Jan 11 '24 20:01 wx4stg