{"record":{"id":"fc152e3371c7f7a3","repo":"jax-ml/jax","slug":"jax-scipy-ndimage-map-coordinates-does-not-yet-sup","errorCode":null,"errorMessage":"jax.scipy.ndimage.map_coordinates does not yet support mode {}. Currently supported modes are {}.","messagePattern":"jax\\.scipy\\.ndimage\\.map_coordinates does not yet support mode (.+?)\\. Currently supported modes are (.+?)\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/ndimage.py","lineNumber":85,"sourceCode":"  lower_weight = 1 - upper_weight\n  index = lower.astype(np.int32)\n  return [(index, lower_weight), (index + 1, upper_weight)]\n\n\n@api.jit(static_argnums=(2, 3, 4))\ndef _map_coordinates(input: ArrayLike, coordinates: Sequence[ArrayLike],\n                     order: int, mode: str, cval: ArrayLike) -> Array:\n  input_arr = jnp.asarray(input)\n  coordinate_arrs = [jnp.asarray(c) for c in coordinates]\n  cval = jnp.asarray(cval, input_arr.dtype)\n\n  if len(coordinates) != input_arr.ndim:\n    raise ValueError('coordinates must be a sequence of length input.ndim, but '\n                     '{} != {}'.format(len(coordinates), input_arr.ndim))\n\n  index_fixer = _INDEX_FIXERS.get(mode)\n  if index_fixer is None:\n    raise NotImplementedError(\n        'jax.scipy.ndimage.map_coordinates does not yet support mode {}. '\n        'Currently supported modes are {}.'.format(mode, set(_INDEX_FIXERS)))\n\n  if mode == 'constant':\n    is_valid = lambda index, size: (0 <= index) & (index < size)\n  else:\n    is_valid = lambda index, size: True\n\n  if order == 0:\n    interp_fun = _nearest_indices_and_weights\n  elif order == 1:\n    interp_fun = _linear_indices_and_weights\n  else:\n    raise NotImplementedError(\n        'jax.scipy.ndimage.map_coordinates currently requires order<=1')\n\n  valid_1d_interpolations = []\n  for coordinate, size in zip(coordinate_arrs, input_arr.shape):","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/ndimage.py#L67-L103","documentation":"JAX's map_coordinates only implements a subset of scipy's boundary modes (those in _INDEX_FIXERS). Unsupported modes like 'wrap', 'reflect' (older versions), 'grid-wrap', or 'mirror' raise NotImplementedError.","triggerScenarios":"Passing mode='wrap' or mode='mirror' on a JAX version that has not implemented it; copying scipy.ndimage.map_coordinates calls verbatim.","commonSituations":"Porting scipy image pipelines (e.g. elastic deformations) to JAX and hitting missing mode parity.","solutions":["Use a supported mode such as 'constant', 'nearest', or the reflect variants listed in the error message","Upgrade jax/jaxlib — more modes have been added over time","Implement the boundary fix-up yourself by clamping coordinates before the call"],"exampleFix":"# before\nout = ndimage.map_coordinates(img, coords, mode='wrap', order=1)\n# after\nout = ndimage.map_coordinates(img, coords, mode='nearest', order=1)","handlingStrategy":"fallback","validationCode":"from jax._src.scipy.ndimage import _INDEX_FIXERS\nmode = mode if mode in _INDEX_FIXERS else 'nearest'","typeGuard":"def mode_supported(mode: str) -> bool: return mode in {'constant','nearest','reflect','mirror'}  # verify for your jax version","tryCatchPattern":"try:\n    out = map_coordinates(img, coords, mode=mode)\nexcept NotImplementedError:\n    out = map_coordinates(img, coords, mode='nearest')","preventionTips":["Pin your jax version and check its supported modes once"],"tags":["jax","scipy","ndimage","unsupported-feature","boundary-mode"],"backgroundTag":"unsupported-argument-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}