jax-ml/jax · error · ValueError

Unexpected value for 'order' argument: {order}.

Error message

Unexpected value for 'order' argument: {order}.

What it means

Array.reshape validates the `order` argument and only accepts 'C', 'F' (and 'A' which raises NotImplementedError). Any other string raises ValueError immediately with the offending value. This catches typos like 'c', 'fortran', or 'rows'.

Source

Thrown at jax/_src/numpy/array_methods.py:388

  """Returns an array containing the same data with a new shape.

  Refer to :func:`jax.numpy.reshape` for full documentation.
  """
  __tracebackhide__ = True
  newshape = _compute_newshape(self, args[0] if len(args) == 1 else args)
  if order == "C":
    return lax.reshape(self, newshape, None, out_sharding=out_sharding)
  elif order == "F":
    dims = list(range(self.ndim)[::-1])
    out_sharding = canonicalize_sharding(out_sharding, "jnp.reshape")
    out_sharding = (
        None if out_sharding is None else out_sharding.update(
            spec=out_sharding.spec.update(partitions=out_sharding.spec[::-1])))
    return lax.reshape(self, newshape[::-1], dims, out_sharding=out_sharding).T
  elif order == "A":
    raise NotImplementedError("np.reshape order=A is not implemented.")
  else:
    raise ValueError(f"Unexpected value for 'order' argument: {order}.")

def _round(self: Array, decimals: int = 0, out: None = None) -> Array:
  """Round array elements to a given decimal.

  Refer to :func:`jax.numpy.round` for full documentation.
  """
  return lax_numpy.round(self, decimals=decimals, out=out)

def _searchsorted(self: Array, v: ArrayLike, side: str = 'left',
                  sorter: ArrayLike | None = None, *, method: str = 'scan') -> Array:
  """Perform a binary search within a sorted array.

  Refer to :func:`jax.numpy.searchsorted` for full documentation."""
  return lax_numpy.searchsorted(self, v, side=side, sorter=sorter, method=method)

def _sort(self: Array, axis: int | None = -1, *, kind: None = None,
          order: None = None, stable: bool = True, descending: bool = False) -> Array:
  """Return a sorted copy of an array.

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Use exactly 'C' or 'F' (uppercase)
  2. Normalize/validate the order string before passing it
  3. Check for stray whitespace or unicode quotes in config-supplied values

Example fix

# before
a.reshape(2, 3, order='c')

# after
a.reshape(2, 3, order='C')
Defensive patterns

Strategy: validation

Validate before calling

def check_order(order):
    if order not in ('C', 'F'):
        raise ValueError(f"order must be 'C' or 'F', got {order!r}")
    return order

Prevention

When it happens

Trigger: Calling `arr.reshape(..., order=...)` with any value other than 'C', 'F', or 'A', e.g. order='c' (lowercase) or order='row-major'.

Common situations: Case typos; passing user-provided or config-driven order strings straight through to reshape.

Related errors


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