{"record":{"id":"33c54adf6a8d0aeb","repo":"jax-ml/jax","slug":"method-doesn-t-support-weights-only-method-inv","errorCode":null,"errorMessage":"{method} doesn't support weights. Only method 'inverted_cdf' supports weights.","messagePattern":"(.+?) doesn't support weights\\. Only method 'inverted_cdf' supports weights\\.","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/reductions.py","lineNumber":2523,"sourceCode":"  \"\"\"\n  a, q = ensure_arraylike(\"nanquantile\", a, q)\n  if weights is not None:\n    weights = ensure_arraylike(\"nanquantile\", weights)\n  if overwrite_input or out is not None:\n    msg = (\"jax.numpy.nanquantile does not support overwrite_input=True or \"\n           \"out != None\")\n    raise ValueError(msg)\n  return _quantile(a, q, axis, method, keepdims, True, weights)\n\ndef _quantile(a: Array, q: Array, axis: int | tuple[int, ...] | None,\n              method: str, keepdims: bool, squash_nans: bool, weights: Array | None = None) -> Array:\n  if method not in [\"linear\", \"lower\", \"higher\", \"midpoint\", \"nearest\", \"inverted_cdf\"]:\n    raise ValueError(\"method can only be 'linear', 'lower', 'higher', 'midpoint', 'nearest' or 'inverted_cdf'\")\n  if weights is not None:\n    if dtypes.issubdtype(weights.dtype, np.complexfloating):\n      raise ValueError(\"Weights cannot be complex types.\")\n    if method != \"inverted_cdf\":\n      raise NotImplementedError(f\"{method} doesn't support weights. Only method 'inverted_cdf' supports weights.\")\n    a, weights = promote_dtypes_inexact(a, weights)\n    if weights.shape != a.shape:\n      if axis is None:\n        raise ValueError(\"Weights shape must match 'a' shape when axis is None.\")\n      ax_tuple = canonicalize_axis_tuple(axis, a.ndim)\n      if weights.shape != tuple(a.shape[ax] for ax in ax_tuple):\n        raise ValueError(f\"Weights shape {weights.shape} must match reduction axes \"\n                          f\"{tuple(a.shape[ax] for ax in ax_tuple)}\")\n      weights = lax.broadcast_in_dim(weights, a.shape, broadcast_dimensions=ax_tuple)\n  else:\n    a, = promote_dtypes_inexact(a)\n  keepdim = []\n  if dtypes.issubdtype(a.dtype, np.complexfloating):\n    raise ValueError(\"quantile does not support complex input, as the operation is poorly defined.\")\n  if axis is None:\n    if keepdims:\n      keepdim = [1] * a.ndim\n    a = a.ravel()","sourceCodeStart":2505,"sourceCodeEnd":2541,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/reductions.py#L2505-L2541","documentation":"Weighted quantiles in JAX are only implemented for method='inverted_cdf'. Requesting weights with any other method (the default 'linear' included) raises NotImplementedError.","triggerScenarios":"Calling jnp.quantile(a, q, weights=w) without setting method (defaults to 'linear'), or with method='lower'/'higher'/'midpoint'/'nearest'.","commonSituations":"Assuming NumPy-style weighted quantiles work with default interpolation; enabling weights in an existing quantile call during feature work.","solutions":["Add method='inverted_cdf' to the call","If interpolated weighted quantiles are required, implement manually (e.g. weighted cumulative distribution + interpolation) or compute on host with NumPy"],"exampleFix":"// before\njnp.quantile(a, q, weights=w)\n// after\njnp.quantile(a, q, weights=w, method='inverted_cdf')","handlingStrategy":"validation","validationCode":"if weights is not None:\n    method = 'inverted_cdf'\njnp.quantile(a, q, weights=weights, method=method)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember weights imply inverted_cdf in JAX","Add an integration test for every weighted-statistics path","Document the limitation next to weight config options"],"tags":["jax","numpy","quantile","weights","not-implemented"],"backgroundTag":"unsupported-parameter-combination","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}