line_dash=[] is treated as a field name for vectorized glyphs
Software versions
- Python 3.12.13, macOS 15 (arm64)
- Bokeh:
branch-4.0at 23c3d5912 (2026-09-24), run from source withPYTHONPATH=src - numpy 2.5.3
Expected behavior
line_dash=[] is the declared default of the property (DashPatternSpec(default=[], ...) in core/property_mixins.py), and it means a solid line. Passing it explicitly to a vectorized glyph should set the glyph's line_dash to [] and add nothing to the data source, exactly as it already does for the scalar figure.line and for np.array([], dtype=int).
Observed behavior
For any glyph whose line_dash is a DashPatternSpec (multi_line, patches, quad, rect, and so on), an empty list or tuple is reinterpreted as a field name: glyph.line_dash becomes the string "line_dash", an empty column named line_dash is injected into the auto-created ColumnDataSource, and a BokehUserWarning about mismatched column lengths is emitted. The plot is wrong.
The same call with np.array([], dtype=int) behaves correctly, and so does figure.line, which makes the empty-list case inconsistent in two directions at once.
patches [6, 3] -> glyph.line_dash=[6, 3] cols=['xs', 'ys']
patches [] -> glyph.line_dash='line_dash' cols=['line_dash', 'xs', 'ys'] <-- wrong
patches () -> glyph.line_dash='line_dash' cols=['line_dash', 'xs', 'ys'] <-- wrong
patches array([], dtype=int64) -> glyph.line_dash=[] cols=['xs', 'ys']
multi_line [] -> glyph.line_dash='line_dash' cols=['line_dash', 'xs', 'ys'] <-- wrong
line [] -> glyph.line_dash=[] cols=['x', 'y']The cause is in _is_scalar_dash_pattern (src/bokeh/plotting/_renderer.py:264), where the list/tuple branch requires a non-empty sequence while the ndarray branch above it accepts an empty one:
def _is_scalar_dash_pattern(val: Any) -> bool:
if isinstance(val, np.ndarray):
return val.ndim == 1 and val.dtype.kind in ('i', 'u') # empty array: True
elif isinstance(val, (list, tuple)):
return len(val) > 0 and all(isinstance(v, int) for v in val) # empty list: False
return FalseThe two existing empty-pattern tests (test_line_dash_empty_list and test_line_dash_numpy_empty_array) both go through p.line(...), which is the scalar path and returns before _is_scalar_dash_pattern is ever called, so the vectorized path is uncovered.
Example code
import warnings
from bokeh.plotting import figure
p = figure()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
r = p.patches(xs=[[0, 1, 2]], ys=[[0, 1, 0]], line_dash=[])
print(r.glyph.line_dash) # 'line_dash' (expected: [])
print(sorted(r.data_source.data)) # ['line_dash', 'xs', 'ys'] (expected: ['xs', 'ys'])
print([str(x.message) for x in w])Stack traceback or browser console output
BokehUserWarning: ColumnDataSource's columns must be of the same length.
Current lengths: ('line_dash', 0), ('xs', 1), ('ys', 1)I have a fix ready (dropping the len(val) > 0 condition, which aligns the list/tuple branch with the ndarray branch, since all(...) of an empty sequence is already True) plus four tests covering the vectorized path for list, tuple, empty ndarray and multi_line. Per BEP-1 I am waiting for this issue to be triaged before opening the PR.
Source: bokeh/bokeh