{"record":{"id":"b9897189c94c1076","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-nanargmin-is-not-support","errorCode":null,"errorMessage":"The 'out' argument to jnp.nanargmin is not supported.","messagePattern":"The 'out' argument to jnp\\.nanargmin is not supported\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/lax_numpy.py","lineNumber":8467,"sourceCode":"    - :func:`jax.numpy.argmin`: return the index of the minimum value.\n    - :func:`jax.numpy.nanargmax`: compute ``argmax`` while ignoring NaN values.\n\n  Examples:\n    >>> x = jnp.array([jnp.nan, 3, 5, 4, 2])\n    >>> jnp.nanargmin(x)\n    Array(4, dtype=int32)\n\n    >>> x = jnp.array([[1, 3, jnp.nan],\n    ...                [5, 4, jnp.nan]])\n    >>> jnp.nanargmin(x, axis=1)\n    Array([0, 1], dtype=int32)\n\n    >>> jnp.nanargmin(x, axis=1, keepdims=True)\n    Array([[0],\n           [1]], dtype=int32)\n  \"\"\"\n  if out is not None:\n    raise NotImplementedError(\"The 'out' argument to jnp.nanargmin is not supported.\")\n  a = util.ensure_arraylike(\"nanargmin\", a)\n  return _nanargmin(a, None if axis is None else operator.index(axis), keepdims=bool(keepdims))\n\n\n@api.jit(static_argnames=('axis', 'keepdims'))\ndef _nanargmin(a: Array, axis: int | None = None, keepdims : bool = False):\n  if not issubdtype(a.dtype, np.inexact):\n    return argmin(a, axis=axis, keepdims=keepdims)\n  nan_mask = ufuncs.isnan(a)\n  a = where(nan_mask, np.inf, a)\n  res = argmin(a, axis=axis, keepdims=keepdims)\n  return where(reductions.all(nan_mask, axis=axis, keepdims=keepdims), -1, res)\n\n\n@api.jit(static_argnums=(2,))\ndef _roll_dynamic(a: Array, shift: Array, axis: Sequence[int]) -> Array:\n  b_shape = lax.broadcast_shapes(shift.shape, np.shape(axis))\n  if len(b_shape) != 1:","sourceCodeStart":8449,"sourceCodeEnd":8485,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/lax_numpy.py#L8449-L8485","documentation":"jnp.nanargmin does not support the out parameter; JAX's functional model returns new arrays rather than mutating caller-supplied buffers.","triggerScenarios":"Calling jnp.nanargmin(a, out=buf), typically from NumPy code migration.","commonSituations":"Legacy NumPy allocation-avoidance idioms; generic reduction wrappers forwarding **kwargs.","solutions":["Drop out and capture the return value","Pop out from kwargs in shared wrappers before calling jnp","Use functional updates (x = x.at[i].set(...)) for buffer-like semantics"],"exampleFix":"// before\njnp.nanargmin(a, out=buf)\n// after\nbuf = jnp.nanargmin(a)\n","handlingStrategy":"validation","validationCode":"kwargs.pop('out', None)  # before calling jnp.nanargmin","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remove out= when migrating NumPy nanargmin","Use x.at[...].set(...) for buffer-like updates","Keep jnp calls purely functional"],"tags":["jax","nanargmin","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"}