{"record":{"id":"62d2ead82c3232e4","repo":"jax-ml/jax","slug":"array-takes-at-most-5-positional-arguments-but","errorCode":null,"errorMessage":"array() takes at most 5 positional arguments but {len(args) + 2} were given","messagePattern":"array\\(\\) takes at most 5 positional arguments but (.+?) were given","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/array_constructors.py","lineNumber":184,"sourceCode":"\n    Constructing JAX arrays from NumPy arrays:\n\n    >>> jnp.array(np.linspace(0, 2, 5))\n    Array([0. , 0.5, 1. , 1.5, 2. ], dtype=float32)\n\n    Constructing a JAX array via the Python buffer interface, using Python's\n    built-in :mod:`array` module.\n\n    >>> from array import array\n    >>> pybuffer = array('i', [2, 3, 5, 7])\n    >>> jnp.array(pybuffer)\n    Array([2, 3, 5, 7], dtype=int32)\n\n  .. _explicit sharding: https://docs.jax.dev/en/latest/parallel.html\n  \"\"\"\n  if args:\n    if len(args) > 3:\n      raise TypeError(f\"array() takes at most 5 positional arguments but {len(args) + 2} were given\")\n\n    for i, name in enumerate([\"copy\", \"order\", \"ndmin\"]):\n      if i < len(args) and [copy, order, ndmin][i] != [True, \"K\", 0][i]:\n        raise TypeError(f\"array() got multiple values for argument '{name}'\")\n    copy, order, ndmin = (list(args) + [copy, order, ndmin][len(args):])[:3]\n\n    deprecations.warn(\n        \"jax-array-positional-args\",\n        \"Passing the copy, order, and ndmin arguments to jnp.array positionally \"\n        \"is deprecated. Use keyword arguments instead.\",\n        stacklevel=2)\n\n  if order is not None and order != \"K\":\n    raise NotImplementedError(\"Only implemented for order='K'\")\n\n  # Fast path: if we're not actually doing any conversion, in many cases we\n  # can call lax.stage to lift the value into the trace.\n  if dtype is None and device is None and out_sharding is None and ndmin == 0:","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/array_constructors.py#L166-L202","documentation":"jnp.array's signature only accepts object plus at most three additional positional args (copy, order, ndmin). Passing more raises this TypeError mirroring NumPy's argument-count error, since positional extras cannot be mapped.","triggerScenarios":"jnp.array(obj, True, 'K', 0, extra) — more than 3 positional arguments after object.","commonSituations":"Code written against NumPy's np.array positional convention migrated to jnp.array with extra positional parameters, or a refactor that splats *args into jnp.array.","solutions":["Pass copy, order, ndmin as keyword arguments","Remove the extra positional argument; check the signature of jnp.array in the installed version"],"exampleFix":"# before\na = jnp.array(x, True, 'K', 0, 1)\n# after\na = jnp.array(x, copy=True, order='K', ndmin=0)","handlingStrategy":"validation","validationCode":"# lint/guard: never pass copy/order/ndmin positionally\ndef safe_array(obj, *, copy=None, order=None, ndmin=0, **kw):\n    return jnp.array(obj, copy=copy, order=order, ndmin=ndmin, **kw)","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Always use keywords for copy/order/ndmin (positional use is deprecated anyway)","Don't splat *args into jnp.array"],"tags":["jax","argument-validation","numpy-compat"],"backgroundTag":"too-many-arguments","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}