#1787·visdom

Bug: bar(), histogram(), and sunburst() crash on size-1 inputs due to unconditional np.squeeze()

Author: munazzaghazali7-hashCreated Sep 2, 2026Updated Sep 2, 2026

Bug Description Several plotting methods crash with AssertionError when given size-1 inputs. The root cause is an unconditional np.squeeze() call that collapses valid dimensions before the ndim assertion runs. This is the same bug class already partially fixed in #1751/#1762 (pie, boxplot, stem, _surface) — bar(), histogram(), and sunburst() have the identical unguarded pattern but weren't covered by that fix.

Reproduction Steps Enter steps to reproduce the behavior:

  1. Start a visdom server: python -m visdom.server
  2. In a Python terminal: `import visdom viz = visdom.Visdom() viz.bar(X=[5])

#AssertionError: X should be one or two-dimensional viz.histogram(X=[42]) #AssertionError: X should be one-dimensional viz.sunburst(labels=["A"], parents=[""], values=[7]) #AssertionError: values should be one-dimensional`

  1. Observe each call crashes with an AssertionError instead of rendering.

Expected behavior

  • bar(X=[5]) should render a single bar.
  • histogram(X=[42]) should render a single-bin histogram.
  • sunburst(...., values=[7]) single-segment sunburst with a value shown

Screenshots N/A — this is a server-side AssertionError, no UI is reached.

Client logs: N/A — crash happens server-side before reaching the frontend.

Server logs: AssertionError: X should be one or two-dimensional AssertionError: X should be one-dimensional AssertionError: values should be one-dimensional

Additional context

Confirmed on current dev branch, py/visdom/init.py:

  • bar() — L3646: X = np.squeeze(X), unguarded
  • histogram() — L3713: X = np.squeeze(X), unguarded
  • sunburst() values param — L4155: values = np.squeeze(values), unguarded. Note that labels/parents in this same function are already correctly guarded with np.atleast_1d() — only values still has the bug.

violin() (L4740) already uses the correct guarded pattern: X = np.asarray(X) if X.ndim > 2: X = np.squeeze(X)