jax-ml/jax · error · ValueError
points have dimension {}, dataset has dimension {}
Error message
points have dimension {}, dataset has dimension {} What it means
When evaluating a gaussian_kde, points are atleast_2d'd and their leading dimension must equal the KDE dimensionality self.d. A convenience case reshapes a single point given as a d-length row vector; any other mismatch (e.g. m points supplied as (m, d) instead of (d, m)) raises this error.
Source
Thrown at jax/_src/scipy/stats/kde.py:242
"only 1D box integrations are supported; use `integrate_box_1d`")
def set_bandwidth(self, bw_method=None):
"""This method is not implemented in the JAX interface."""
del bw_method
raise NotImplementedError(
"dynamically changing the bandwidth method is not supported")
def _reshape_points(self, points):
if dtypes.issubdtype(lax.dtype(points), np.complexfloating):
raise NotImplementedError(
"gaussian_kde does not support complex coordinates")
points = jnp.atleast_2d(points)
d, m = points.shape
if d != self.d:
if d == 1 and m == self.d:
points = jnp.reshape(points, (self.d, 1))
else:
raise ValueError(
"points have dimension {}, dataset has dimension {}".format(
d, self.d))
return points
def _gaussian_kernel_convolve(chol, norm, target, weights, mean):
diff = target - mean[:, None]
alpha = linalg.cho_solve(chol, diff)
arg = 0.5 * jnp.sum(diff * alpha, axis=0)
return norm * jnp.sum(jnp.exp(-arg) * weights)
@api.jit(static_argnums=0)
def _gaussian_kernel_eval(in_log, points, values, xi, precision):
points, values, xi, precision = promote_dtypes_inexact(
points, values, xi, precision)
d = points.shape[1]
View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Transpose the query points: kde.evaluate(X.T)
- For a single point pass a flat d-vector: kde.evaluate(p) with p.shape == (d,)
- Check d with kde.d and shape points accordingly
Example fix
// before dens = kde.evaluate(X) # X.shape == (N, d) // after dens = kde.evaluate(X.T) # (d, N)
Defensive patterns
Strategy: validation
Validate before calling
pts = jnp.asarray(points)
if pts.ndim == 2 and pts.shape[0] != kde.d:
pts = pts.T # assume (N, d) input
assert pts.shape[0] == kde.d Type guard
def points_oriented_for_kde(points, kde) -> bool:
p = jnp.atleast_2d(jnp.asarray(points))
return p.shape[0] == kde.d or (p.shape[0] == 1 and p.shape[1] == kde.d) Prevention
- Standardize on (d, N) layout for KDE queries
- Transpose ML-style (N, d) arrays at the boundary
- Write a small evaluate wrapper that fixes orientation
When it happens
Trigger: Calling kde.evaluate(X) with X.shape == (n_points, d) instead of (d, n_points); passing a single point of shape (d,) is fine, but (n_points,) with n_points != d fails.
Common situations: Feeding machine-learning-style (samples, features) arrays directly; the KDE stores dataset as (d, n) via atleast_2d so users must transpose their points.
Related errors
- `weights` input should be one-dimensional.
- mean does not have dimension {self.d}
- covariance does not have dimension {self.d}
- KDEs are not the same dimensionality
- points and xi must have same trailing dim
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/27053fdd562bae39.
Report an issue: GitHub.