{"record":{"id":"16a5757986f52a59","repo":"jax-ml/jax","slug":"out-argument-of-self","errorCode":null,"errorMessage":"out argument of {self}","messagePattern":"out argument of (.+?)","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/ufunc_api.py","lineNumber":178,"sourceCode":"  def __hash__(self) -> int:\n    # In both __hash__ and __eq__, we do not consider call, reduce, etc.\n    # because they are considered implementation details rather than\n    # necessary parts of object identity.\n    return hash((self._func, self.__name__, self.identity,\n                 self.nin, self.nout, self.nargs))\n\n  def __eq__(self, other: Any) -> bool:\n    return isinstance(other, ufunc) and (\n      (self._func, self.__name__, self.identity, self.nin, self.nout, self.nargs) ==\n      (other._func, other.__name__, other.identity, other.nin, other.nout, other.nargs))\n\n  def __repr__(self) -> str:\n    return f\"<jnp.ufunc '{self.__name__}'>\"\n\n  def __call__(self, *args: ArrayLike, out: None = None, where: None = None) -> Any:\n    check_arraylike(self.__name__, *args)\n    if out is not None:\n      raise NotImplementedError(f\"out argument of {self}\")\n    if where is not None:\n      raise NotImplementedError(f\"where argument of {self}\")\n    call = (self.__static_props['call']\n            or cast(Callable[..., Any], self._call_vectorized))\n    return call(*args)\n\n  @api.jit(static_argnames=['self'])\n  def _call_vectorized(self, *args):\n    return vectorize(self._func)(*args)\n\n  @api.jit(static_argnames=['self', 'axis', 'dtype', 'out', 'keepdims'])\n  def reduce(self, a: ArrayLike, axis: int | None = 0,\n             dtype: DTypeLike | None = None,\n             out: None = None, keepdims: bool = False, initial: ArrayLike | None = None,\n             where: ArrayLike | None = None) -> Array:\n    \"\"\"Reduction operation derived from a binary function.\n\n    JAX implementation of :meth:`numpy.ufunc.reduce`.","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/ufunc_api.py#L160-L196","documentation":"JAX ufunc objects (jnp.add, jnp.multiply, etc.) accept numpy's out keyword for signature compatibility but cannot write into a buffer because JAX arrays are immutable. Passing a non-None out raises NotImplementedError naming the ufunc.","triggerScenarios":"jnp.add(x, y, out=buf) or any jnp.ufunc call with out=<array>.","commonSituations":"Ported numpy code using out= for in-place accumulation; generic wrapper code that forwards **kwargs including out.","solutions":["Remove the out argument and assign the result","Rewrite in-place accumulation patterns as functional updates (e.g. x = x + y or x.at[idx].set(...))"],"exampleFix":"// before\njnp.add(x, y, out=x)\n// after\nx = jnp.add(x, y)","handlingStrategy":"type-guard","validationCode":"kwargs.pop('out', None)  # before forwarding to a jnp.ufunc","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt functional style: results are returned, never written into buffers"],"tags":["jax","ufunc","immutable-arrays","numpy-compat"],"backgroundTag":"unsupported-out-parameter","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}