{"record":{"id":"a091e3ae587b32b3","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-var-is-not-supported","errorCode":null,"errorMessage":"The 'out' argument to jnp.var is not supported.","messagePattern":"The 'out' argument to jnp\\.var is not supported\\.","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/reductions.py","lineNumber":1134,"sourceCode":"     [6.22]]\n  \"\"\"\n  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(\"var\", a)\n  return _var(a, axis=_ensure_optional_axes(axis), dtype=dtype, out=out, correction=correction, keepdims=keepdims,\n              where=where, a_mean=mean)\n\n@api.jit(static_argnames=('axis', 'dtype', 'keepdims'))\ndef _var(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, a_mean: ArrayLike | None = None) -> Array:\n  where = check_where(\"var\", where)\n  if dtype is not None:\n    dtype = dtypes.check_and_canonicalize_user_dtype(dtype, \"var\")\n  if out is not None:\n    raise NotImplementedError(\"The 'out' argument to jnp.var is not supported.\")\n\n  computation_dtype, dtype = _var_promote_types(a.dtype, dtype)\n  a = lax.asarray(a).astype(computation_dtype)\n  if a_mean is None:\n    a_mean = mean(a, axis, dtype=computation_dtype, keepdims=True, where=where)\n  else:\n    a_mean = ensure_arraylike(\"var\", a_mean).astype(computation_dtype)\n\n  centered = lax.sub(a, a_mean)\n  if dtypes.issubdtype(computation_dtype, np.complexfloating):\n    centered = lax.real(lax.mul(centered, lax.conj(centered)))\n    computation_dtype = centered.dtype  # avoid casting to complex below.\n  else:\n    centered = lax.square(centered)\n\n  normalizer = _count(\n      a,\n      axis=axis,","sourceCodeStart":1116,"sourceCodeEnd":1152,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/reductions.py#L1116-L1152","documentation":"jnp.var does not support the numpy-style 'out' in-place output argument because JAX arrays are immutable; out is accepted only as None for API compatibility with numpy delegation.","triggerScenarios":"jnp.var(x, out=buf), np.var(jax_array, out=...) via method delegation, or x.var(out=buf) on a JAX array.","commonSituations":"Statistics pipelines ported from numpy that write into preallocated buffers; kwargs-forwarding variance wrappers.","solutions":["Use the returned value: v = jnp.var(x, axis=0)","Update buffers with .at[...].set(jnp.var(...)) under jit","Strip out from forwarded kwargs"],"exampleFix":"// before\njnp.var(x, axis=0, out=var_buf)\n// after\nvar_buf = jnp.var(x, axis=0)","handlingStrategy":"validation","validationCode":"v = jnp.var(x, axis=0)  # no out kwarg","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use return values; update buffers with .at[].set() under jit"],"tags":["jax","var","out-parameter"],"backgroundTag":"unsupported-out-parameter","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}