jax-ml/jax · error · TypeError

array() got multiple values for argument '{name}'

Error message

array() got multiple values for argument '{name}'

What it means

When copy/order/ndmin are supplied positionally as *args, jnp.array checks whether the same option was ALSO given as a keyword. If both positional and keyword values are present, it raises this 'multiple values' TypeError like a normal Python signature would.

Source

Thrown at jax/_src/numpy/array_constructors.py:188

    Array([0. , 0.5, 1. , 1.5, 2. ], dtype=float32)

    Constructing a JAX array via the Python buffer interface, using Python's
    built-in :mod:`array` module.

    >>> from array import array
    >>> pybuffer = array('i', [2, 3, 5, 7])
    >>> jnp.array(pybuffer)
    Array([2, 3, 5, 7], dtype=int32)

  .. _explicit sharding: https://docs.jax.dev/en/latest/parallel.html
  """
  if args:
    if len(args) > 3:
      raise TypeError(f"array() takes at most 5 positional arguments but {len(args) + 2} were given")

    for i, name in enumerate(["copy", "order", "ndmin"]):
      if i < len(args) and [copy, order, ndmin][i] != [True, "K", 0][i]:
        raise TypeError(f"array() got multiple values for argument '{name}'")
    copy, order, ndmin = (list(args) + [copy, order, ndmin][len(args):])[:3]

    deprecations.warn(
        "jax-array-positional-args",
        "Passing the copy, order, and ndmin arguments to jnp.array positionally "
        "is deprecated. Use keyword arguments instead.",
        stacklevel=2)

  if order is not None and order != "K":
    raise NotImplementedError("Only implemented for order='K'")

  # Fast path: if we're not actually doing any conversion, in many cases we
  # can call lax.stage to lift the value into the trace.
  if dtype is None and device is None and out_sharding is None and ndmin == 0:
    if isinstance(object, core.Tracer) and not core.is_concrete(object):
      return lax._array_copy(object) if copy else object
    if isinstance(object, (int, float, complex, np.number)):
      return lax.stage(object)

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Use keyword arguments exclusively for copy, order, ndmin
  2. Audit call sites mixing positional and keyword forms of these three options

Example fix

# before
a = jnp.array(x, True, ndmin=1)
# after
a = jnp.array(x, copy=True, ndmin=1)
Defensive patterns

Strategy: validation

Validate before calling

# ensure copy/order/ndmin passed only once, as keywords
assert not positional_copy_order_ndmin, 'use keywords'

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: jnp.array(x, True, ndmin=1) — copy passed positionally and ndmin also as keyword — where the positional slot conflicts with a non-default keyword value.

Common situations: Migrating old NumPy-style positional calls while partially modernizing some arguments to keywords; positional use is deprecated anyway.

Related errors


AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27). Data as JSON: /api/errors/5b5133face47cd37. Report an issue: GitHub.