{"record":{"id":"3006e218677a772e","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-name-is-not-supported-3006e2","errorCode":null,"errorMessage":"The 'out' argument to jnp.{name} is not supported","messagePattern":"The 'out' argument to jnp\\.(.+?) is not supported","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/reductions.py","lineNumber":2041,"sourceCode":"  a = ensure_arraylike(\"nanstd\", a)\n  where = check_where(\"nanstd\", where)\n  if dtype is not None:\n    dtype = dtypes.check_and_canonicalize_user_dtype(dtype, \"nanstd\")\n  if out is not None:\n    raise NotImplementedError(\"The 'out' argument to jnp.nanstd is not supported.\")\n  return lax.sqrt(nanvar(a, axis=axis, dtype=dtype, ddof=ddof,\n                         keepdims=keepdims, where=where, mean=mean))\n\n\ndef _cumulative_reduction(\n    name: str, reduction: Callable[..., Array],\n    a: ArrayLike, axis: int | None, dtype: DTypeLike | None, out: None = None,\n    fill_nan: bool = False, fill_value: ArrayLike = 0,\n    promote_integers: bool = False) -> Array:\n  \"\"\"Helper function for implementing cumulative reductions.\"\"\"\n  a = ensure_arraylike(name, a)\n  if out is not None:\n    raise NotImplementedError(f\"The 'out' argument to jnp.{name} is not supported\")\n\n  if axis is None or _isscalar(a):\n    if not builtins.all(s is None for s in core.typeof(a).sharding.spec):\n      raise core.ShardingTypeError(\n          \"The input should be fully replicated when axis is not specified to\"\n          f\" {name}. Got input type={core.typeof(a)}\")\n    a = lax.reshape(a, (np.size(a),))\n  if axis is None:\n    axis = 0\n\n  a_shape = list(np.shape(a))\n  num_dims = len(a_shape)\n  axis = canonicalize_axis(axis, num_dims)\n\n  if fill_nan:\n    a = _where(lax._isnan(a), lax._const(a, fill_value), a)\n\n  computation_type: DType","sourceCodeStart":2023,"sourceCodeEnd":2059,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/reductions.py#L2023-L2059","documentation":"The shared helper behind jnp.cumsum, cumprod, nancumsum, and nancumprod rejects the out= argument because JAX arrays are immutable and cannot be filled in place.","triggerScenarios":"Calling jnp.cumsum(x, out=buf), jnp.cumprod(x, out=buf), jnp.nancumsum(x, out=buf), or jnp.nancumprod(x, out=buf).","commonSituations":"Porting NumPy cumulative-reduction code that preallocated output buffers; generic **kwargs forwarding from array-API shims.","solutions":["Drop out= and use the return value","Preallocate nothing — rely on jit to fuse and manage memory"],"exampleFix":"// before\nnp.cumsum(x, out=buf)\n// after\nbuf = jnp.cumsum(x)","handlingStrategy":"validation","validationCode":"def cumulate(fn, x, **kw):\n    kw.pop('out', None)\n    return fn(x, **kw)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip out= in cumulative-reduction wrappers","Prefer jitted helpers over manual buffer reuse"],"tags":["jax","numpy","cumsum","cumprod","out-argument"],"backgroundTag":"unsupported-out-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}