{"record":{"id":"fb330db5cd880c6f","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-argmin-is-not-supported","errorCode":null,"errorMessage":"The 'out' argument to jnp.argmin is not supported.","messagePattern":"The 'out' argument to jnp\\.argmin is not supported\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/lax_numpy.py","lineNumber":8334,"sourceCode":"    - :func:`jax.numpy.nanargmin`: compute ``argmin`` while ignoring NaN values.\n\n  Examples:\n    >>> x = jnp.array([1, 3, 5, 4, 2])\n    >>> jnp.argmin(x)\n    Array(0, dtype=int32)\n\n    >>> x = jnp.array([[1, 3, 2],\n    ...                [5, 4, 1]])\n    >>> jnp.argmin(x, axis=1)\n    Array([0, 2], dtype=int32)\n\n    >>> jnp.argmin(x, axis=1, keepdims=True)\n    Array([[0],\n           [2]], dtype=int32)\n  \"\"\"\n  arr = util.ensure_arraylike(\"argmin\", a)\n  if out is not None:\n    raise NotImplementedError(\"The 'out' argument to jnp.argmin is not supported.\")\n  return _argmin(arr, None if axis is None else operator.index(axis),\n                 keepdims=bool(keepdims))\n\n@api.jit(static_argnames=('axis', 'keepdims'), inline=True)\ndef _argmin(a: Array, axis: int | None = None, keepdims: bool = False) -> Array:\n  if axis is None:\n    dims = list(range(np.ndim(a)))\n    a = ravel(a)\n    axis = 0\n  else:\n    dims = [axis]\n  if a.shape[axis] == 0:\n    raise ValueError(\"attempt to get argmin of an empty sequence\")\n  # TODO(phawkins): use an int64 index if the dimension is large enough.\n  result = lax.argmin(a, _canonicalize_axis(axis, a.ndim), int)\n  return expand_dims(result, dims) if keepdims else result\n\n","sourceCodeStart":8316,"sourceCodeEnd":8352,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/lax_numpy.py#L8316-L8352","documentation":"jnp.argmin does not support the out parameter; JAX arrays are immutable and functional, so writing results into a caller-supplied buffer is unsupported, unlike NumPy.","triggerScenarios":"Calling jnp.argmin(a, out=buf), typically from ported NumPy code that preallocated an output buffer.","commonSituations":"NumPy performance idioms using out=; generic **kwargs forwarding wrappers that pass out through.","solutions":["Drop out and assign the return value: idx = jnp.argmin(a)","Simulate buffer reuse via buf.at[:].set(jnp.argmin(a)) if truly needed","Filter out= from kwargs before delegating to jnp"],"exampleFix":"// before\njnp.argmin(a, axis=0, out=buf)\n// after\nbuf = jnp.argmin(a, axis=0)\n","handlingStrategy":"validation","validationCode":"kwargs.pop('out', None)  # before calling jnp.argmin","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remove out= when porting NumPy argmin code","Use functional assignment of the result","Audit wrappers that forward **kwargs"],"tags":["jax","argmin","unsupported-argument","numpy-compat"],"backgroundTag":"unsupported-out-parameter","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}