Bug: parallel_coordinates() crashes on size-1 inputs when Y is provided due to unconditional np.squeeze()
Bug Description
In py/visdom/__init__.py:4664, parallel_coordinates() calls np.squeeze() unconditionally on Y:
X = np.asarray(X, dtype=float)
assert X.ndim == 2, "X must be a 2D matrix (N experiments x M dimensions)"
N, M = X.shape
assert N >= 1, "X must have at least 1 experiment (row)"
assert M >= 2, "X must have at least 2 dimensions (columns)"
if Y is not None:
Y = np.squeeze(np.asarray(Y, dtype=float))
assert Y.ndim == 1, "Y must be a 1D vector"While N >= 1 explicitly permits a single experiment ($N=1$ row and $M \ge 2$ columns), passing a 1-element Y (such as Y=[0.5] or np.array([0.5])) causes np.squeeze() to collapse Y to a 0-D scalar (ndim == 0).
The subsequent assertion assert Y.ndim == 1 immediately fails with AssertionError: Y must be a 1D vector.
This belongs to the same class of bugs recently addressed in pie, boxplot, stem, bar, and histogram (#1787, #1817), where np.atleast_1d(np.squeeze(...)) preserves 1-D vector shapes for size-1 inputs while preserving squeezing of 2D row/column vectors.
Reproduction Steps
import visdom
viz = visdom.Visdom()
# Single experiment (N=1, M=3) with color target Y
viz.parallel_coordinates(X=[[1.0, 2.0, 3.0]], Y=[0.5])Result:
AssertionError: Y must be a 1D vectorExpected behavior
parallel_coordinates() should accept valid size-1 Y inputs without collapsing them to 0-dimensional scalars, allowing single-experiment plots with target colors to render properly.
Source: fossasia/visdom