{"record":{"id":"5d02329f25dad593","repo":"jax-ml/jax","slug":"x-must-be-a-one-dimensional-array","errorCode":null,"errorMessage":"x must be a one-dimensional array","messagePattern":"x must be a one-dimensional array","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/lax_numpy.py","lineNumber":8149,"sourceCode":"\n    >>> jnp.vander(x, N=2)\n    Array([[1, 1],\n           [2, 1],\n           [3, 1],\n           [4, 1]], dtype=int32)\n\n    Generates the Vandermonde matrix in increasing order of powers, when\n    ``increasing=True``.\n\n    >>> jnp.vander(x, increasing=True)\n    Array([[ 1,  1,  1,  1],\n           [ 1,  2,  4,  8],\n           [ 1,  3,  9, 27],\n           [ 1,  4, 16, 64]], dtype=int32)\n  \"\"\"\n  x = util.ensure_arraylike(\"vander\", x)\n  if x.ndim != 1:\n    raise ValueError(\"x must be a one-dimensional array\")\n  N = x.shape[0] if N is None else core.concrete_or_error(\n    operator.index, N, \"'N' argument of jnp.vander()\")\n  if N < 0:\n    raise ValueError(\"N must be nonnegative\")\n\n  iota = lax.iota(x.dtype, N)\n  if not increasing:\n    iota = lax.sub(lax._const(iota, N - 1), iota)\n\n  return ufuncs.power(x[..., None], expand_dims(iota, tuple(range(x.ndim))))\n\n\n### Misc\n\n@export\ndef argwhere(\n    a: ArrayLike,\n    *,","sourceCodeStart":8131,"sourceCodeEnd":8167,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/lax_numpy.py#L8131-L8167","documentation":"Raised by jnp.vander when the input x is not one-dimensional; the Vandermonde matrix is only defined for a 1-D vector of roots.","triggerScenarios":"jnp.vander on a 2-D matrix, a (n,1) column, or a list that asarray promotes to >1-D.","commonSituations":"Passing a column vector from slicing (shape (n,1)) instead of ravel; feeding a batch of points where per-row vander via vmap was intended.","solutions":["Flatten input: jnp.vander(x.ravel(), N)","Use jax.vmap over rows if you need per-row Vandermonde matrices","Fix upstream slicing to produce 1-D (x[:, 0] instead of x[:, :1])"],"exampleFix":"// before\njnp.vander(x[:, :1])  # shape (n,1)\n// after\njnp.vander(x[:, 0])   # shape (n,)\n","handlingStrategy":"validation","validationCode":"x = jnp.asarray(x)\nif x.ndim != 1: x = x.ravel()","typeGuard":"def is_1d(x):\n    return jnp.asarray(x).ndim == 1","tryCatchPattern":null,"preventionTips":["Ravel column slices (n,1) before vander","Use vmap(jnp.vander) for batched Vandermonde","Check .ndim of sliced inputs in data pipelines"],"tags":["jax","vander","shape-validation"],"backgroundTag":"array-dimension-validation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}