{"record":{"id":"884ab084501b7e5a","repo":"jax-ml/jax","slug":"valid-values-for-indexing-are-xy-and-ij-got","errorCode":null,"errorMessage":"Valid values for indexing are 'xy' and 'ij', got {indexing}","messagePattern":"Valid values for indexing are 'xy' and 'ij', got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/lax_numpy.py","lineNumber":6094,"sourceCode":"    [[10]\n     [20]\n     [30]]\n\n    2D matrix-index mesh grid:\n\n    >>> x_grid, y_grid = jnp.meshgrid(x, y, indexing='ij')\n    >>> print(x_grid)\n    [[1 1 1]\n     [2 2 2]]\n    >>> print(y_grid)\n    [[10 20 30]\n     [10 20 30]]\n  \"\"\"\n  args = list(util.ensure_arraylike_tuple(\"meshgrid\", tuple(xi)))\n  if not copy:\n    raise ValueError(\"jax.numpy.meshgrid only supports copy=True\")\n  if indexing not in [\"xy\", \"ij\"]:\n    raise ValueError(f\"Valid values for indexing are 'xy' and 'ij', got {indexing}\")\n  if any(a.ndim != 1 for a in args):\n    raise ValueError(\"Arguments to jax.numpy.meshgrid must be 1D, got shapes \"\n                     f\"{[a.shape for a in args]}\")\n  if indexing == \"xy\" and len(args) >= 2:\n    args[0], args[1] = args[1], args[0]\n  shape = [1 if sparse else a.shape[0] for a in args]\n  _a_shape = lambda i, a: [*shape[:i], a.shape[0], *shape[i + 1:]] if sparse else shape\n  output = [lax.broadcast_in_dim(a, _a_shape(i, a), (i,)) for i, a, in enumerate(args)]\n  if indexing == \"xy\" and len(args) >= 2:\n    output[0], output[1] = output[1], output[0]\n  return tuple(output)\n\n\n@export\n@api.jit\ndef i0(x: ArrayLike) -> Array:\n  r\"\"\"Calculate modified Bessel function of first kind, zeroth order.\n","sourceCodeStart":6076,"sourceCodeEnd":6112,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/lax_numpy.py#L6076-L6112","documentation":"jnp.meshgrid's indexing argument must be exactly 'xy' (Cartesian, default) or 'ij' (matrix) indexing. Any other value raises this ValueError echoing the invalid value. The two modes differ in output shape ordering for two or more inputs.","triggerScenarios":"jnp.meshgrid(x, y, indexing='XY') (wrong case), indexing='ji' (typo), or passing None. Note default is 'xy' in both NumPy and JAX.","commonSituations":"Confusion with other libraries (e.g. MATLAB conventions) or simple typos; users switching between 'xy' and 'ij' to fix downstream transposition bugs and mistyping the string.","solutions":["Use exactly 'xy' or 'ij' (lowercase)","If outputs are transposed unexpectedly, switch between the two valid values rather than inventing new ones"],"exampleFix":"// before\nX, Y = jnp.meshgrid(x, y, indexing='yx')\n// after\nX, Y = jnp.meshgrid(x, y, indexing='ij')","handlingStrategy":"validation","validationCode":"assert indexing in ('xy', 'ij')","typeGuard":"from typing import Literal\nIndexing = Literal['xy', 'ij']","tryCatchPattern":null,"preventionTips":["Type-annotate indexing as Literal['xy','ij']","Centralize grid-construction helpers so the mode string is set once"],"tags":["jax","meshgrid","indexing","invalid-argument"],"backgroundTag":"invalid-enum-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}