{"record":{"id":"729da3fe134a137b","repo":"jax-ml/jax","slug":"only-1d-box-integrations-are-supported-use-integ","errorCode":null,"errorMessage":"only 1D box integrations are supported; use `integrate_box_1d`","messagePattern":"only 1D box integrations are supported; use `integrate_box_1d`","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/stats/kde.py","lineNumber":223,"sourceCode":"                                     dtype=self.dataset.dtype).T\n    return self.dataset[:, ind] + eps\n\n  def pdf(self, x):\n    \"\"\"Probability density function\"\"\"\n    return self.evaluate(x)\n\n  def logpdf(self, x):\n    \"\"\"Log probability density function\"\"\"\n    check_arraylike(\"logpdf\", x)\n    x = self._reshape_points(x)\n    result = _gaussian_kernel_eval(True, self.dataset.T, self.weights[:, None],\n                                   x.T, self.inv_cov)\n    return result[:, 0]\n\n  def integrate_box(self, low_bounds, high_bounds, maxpts=None):\n    \"\"\"This method is not implemented in the JAX interface.\"\"\"\n    del low_bounds, high_bounds, maxpts\n    raise NotImplementedError(\n        \"only 1D box integrations are supported; use `integrate_box_1d`\")\n\n  def set_bandwidth(self, bw_method=None):\n    \"\"\"This method is not implemented in the JAX interface.\"\"\"\n    del bw_method\n    raise NotImplementedError(\n        \"dynamically changing the bandwidth method is not supported\")\n\n  def _reshape_points(self, points):\n    if dtypes.issubdtype(lax.dtype(points), np.complexfloating):\n      raise NotImplementedError(\n          \"gaussian_kde does not support complex coordinates\")\n    points = jnp.atleast_2d(points)\n    d, m = points.shape\n    if d != self.d:\n      if d == 1 and m == self.d:\n        points = jnp.reshape(points, (self.d, 1))\n      else:","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/stats/kde.py#L205-L241","documentation":"Unlike scipy, JAX's gaussian_kde does not implement the general N-D integrate_box; it is stubbed to raise NotImplementedError and direct users to integrate_box_1d. This is an intentional API-parity gap documented in the method docstring.","triggerScenarios":"Calling kde.integrate_box(low, high) for any KDE, even 1-D ones.","commonSituations":"Porting scipy.stats.gaussian_kde code that used integrate_box for multidimensional probability mass; assuming jax.scipy mirrors the full scipy API.","solutions":["For 1-D KDEs use kde.integrate_box_1d(low, high)","For N-D, estimate via Monte Carlo: sample with kde.resample and count points in the box","Alternatively evaluate kde on a grid and numerically integrate (trapezoid/quad)"],"exampleFix":"// before\np = kde.integrate_box(lo, hi)\n// after (1-D)\np = kde.integrate_box_1d(lo, hi)","handlingStrategy":"fallback","validationCode":"hasattr check not needed; branch on dimensionality:\nuse_box_1d = kde.d == 1","typeGuard":null,"tryCatchPattern":"try:\n    p = kde.integrate_box(lo, hi)\nexcept NotImplementedError:\n    samples = kde.resample(200_000, seed=key)\n    p = ((samples >= lo[:, None]) & (samples <= hi[:, None])).all(0).mean()","preventionTips":["Replace integrate_box with integrate_box_1d when d == 1","Keep a Monte Carlo helper for N-D boxes","Check JAX docs for scipy API gaps before porting"],"tags":["jax","scipy","kde","not-implemented","api-parity"],"backgroundTag":"unsupported-operation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}