{"record":{"id":"1957608bb12659e9","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-std-is-not-supported","errorCode":null,"errorMessage":"The 'out' argument to jnp.std is not supported.","messagePattern":"The 'out' argument to jnp\\.std is not supported\\.","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/reductions.py","lineNumber":1284,"sourceCode":"  if correction is None:\n    correction = ddof\n  elif not isinstance(ddof, int) or ddof != 0:\n    raise ValueError(\"ddof and correction can't be provided simultaneously.\")\n  a = ensure_arraylike(\"std\", a)\n  return _std(a, axis=_ensure_optional_axes(axis), dtype=dtype, out=out, correction=correction, keepdims=keepdims,\n              where=where, mean=mean)\n\n@api.jit(static_argnames=('axis', 'dtype', 'keepdims'))\ndef _std(a: Array, *, axis: Axis = None, dtype: DTypeLike | None = None,\n         out: None = None, correction: int | float = 0, keepdims: bool = False,\n         where: ArrayLike | None = None, mean: ArrayLike | None = None) -> Array:\n  where = check_where(\"std\", where)\n  if dtype is not None:\n    dtype = dtypes.check_and_canonicalize_user_dtype(dtype, \"std\")\n    if not dtypes.issubdtype(dtype, np.inexact):\n      raise ValueError(f\"dtype argument to jnp.std must be inexact; got {dtype}\")\n  if out is not None:\n    raise NotImplementedError(\"The 'out' argument to jnp.std is not supported.\")\n  return lax.sqrt(var(a, axis=axis, dtype=dtype, correction=correction,\n                      keepdims=keepdims, where=where, mean=mean))\n\n\n@export\ndef ptp(a: ArrayLike, axis: Axis = None, out: None = None,\n        keepdims: bool = False) -> Array:\n  r\"\"\"Return the peak-to-peak range along a given axis.\n\n  JAX implementation of :func:`numpy.ptp`.\n\n  Args:\n    a: input array.\n    axis: optional, int or sequence of ints, default=None. Axis along which the\n      range is computed. If None, the range is computed on the flattened array.\n    keepdims: bool, default=False. If true, reduced axes are left in the result\n      with size 1.\n    out: Unused by JAX.","sourceCodeStart":1266,"sourceCodeEnd":1302,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/reductions.py#L1266-L1302","documentation":"JAX uses immutable arrays, so the NumPy out= buffer-write pattern cannot be supported. jnp.std exposes out only for API compatibility and raises NotImplementedError whenever it is not None.","triggerScenarios":"Calling jnp.std(x, out=buf) or any positional third argument being interpreted as out.","commonSituations":"Porting NumPy code that uses out= to avoid allocations; generic wrappers forwarding all NumPy kwargs.","solutions":["Drop the out argument and use the returned array: y = jnp.std(x)","If reusing a buffer name is needed, reassign: buf = jnp.std(x) at runtime (jit will still avoid reallocation)"],"exampleFix":"// before\nnp.std(x, out=buf)\n// after\nbuf = jnp.std(x)","handlingStrategy":"validation","validationCode":"kwargs.pop('out', None)  # strip NumPy-style out before calling jnp.std","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip out= in NumPy→JAX adapter layers","Remember all jnp reductions reject out=","Grep ports for 'out=' before running"],"tags":["jax","numpy","out-argument","immutable-arrays"],"backgroundTag":"unsupported-out-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}