{"record":{"id":"4f1d140192c693f6","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-nanstd-is-not-supported","errorCode":null,"errorMessage":"The 'out' argument to jnp.nanstd is not supported.","messagePattern":"The 'out' argument to jnp\\.nanstd is not supported\\.","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/reductions.py","lineNumber":2028,"sourceCode":"    >>> with jnp.printoptions(precision=2, suppress=True):\n    ...   print(jnp.nanstd(x, axis=0, keepdims=True, ddof=1))\n    [[0.71 0.71 1.41 1.41]]\n\n    To include specific elements of the array to compute standard deviation, you\n    can use ``where``.\n\n    >>> where=jnp.array([[1, 0, 1, 0],\n    ...                  [0, 1, 0, 1],\n    ...                  [1, 1, 0, 1]], dtype=bool)\n    >>> jnp.nanstd(x, axis=0, keepdims=True, where=where)\n    Array([[0.5, 0.5, 0. , 0. ]], dtype=float32)\n  \"\"\"\n  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\"","sourceCodeStart":2010,"sourceCodeEnd":2046,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/reductions.py#L2010-L2046","documentation":"jnp.nanstd does not support the NumPy-style out= in-place output argument; it raises NotImplementedError before delegating to nanvar/sqrt. This mirrors JAX's blanket policy of immutable outputs.","triggerScenarios":"Calling jnp.nanstd(a, out=buf) directly.","commonSituations":"NumPy→JAX ports of NaN-aware standard-deviation computations that relied on out= for memory reuse.","solutions":["Remove the out argument and assign the result","Replace out=-based allocation tricks with jax.jit-compiled kernels"],"exampleFix":"// before\njnp.nanstd(x, out=buf)\n// after\nbuf = jnp.nanstd(x)","handlingStrategy":"validation","validationCode":"s = jnp.nanstd(a, ddof=ddof)  # simply never pass out","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat out= as unsupported across all of jax.numpy","Use jit for allocation concerns instead of out="],"tags":["jax","numpy","nanstd","out-argument"],"backgroundTag":"unsupported-out-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}