{"record":{"id":"117dafc83da53f48","repo":"jax-ml/jax","slug":"unimplemented-padding-mode-for-np-pad","errorCode":null,"errorMessage":"Unimplemented padding mode '{}' for np.pad.","messagePattern":"Unimplemented padding mode '(.+?)' for np\\.pad\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/lax_numpy.py","lineNumber":4364,"sourceCode":"  if callable(mode):\n    return _pad_func(asarray(array), pad_width, mode, **kwargs)\n\n  allowed_kwargs = {\n      'empty': [], 'edge': [], 'wrap': [],\n      'constant': ['constant_values'],\n      'linear_ramp': ['end_values'],\n      'maximum': ['stat_length'],\n      'mean': ['stat_length'],\n      'median': ['stat_length'],\n      'minimum': ['stat_length'],\n      'reflect': ['reflect_type'],\n      'symmetric': ['reflect_type'],\n  }\n  try:\n    unsupported_kwargs = set(kwargs) - set(allowed_kwargs[mode])\n  except KeyError:\n    msg = \"Unimplemented padding mode '{}' for np.pad.\"\n    raise NotImplementedError(msg.format(mode))\n  if unsupported_kwargs:\n    raise ValueError(\"unsupported keyword arguments for mode '{}': {}\"\n                     .format(mode, unsupported_kwargs))\n  # Set default value if not given.\n  constant_values = kwargs.get('constant_values', 0)\n  stat_length = kwargs.get('stat_length', None)\n  end_values = kwargs.get('end_values', 0)\n  reflect_type = kwargs.get('reflect_type', \"even\")\n\n  return _pad(array, pad_width, mode, constant_values, stat_length, end_values,\n              reflect_type)\n\n### Array-creation functions\n\n\n@export\ndef stack(arrays: np.ndarray | Array | Sequence[ArrayLike],\n          axis: int = 0, out: None = None, dtype: DTypeLike | None = None) -> Array:","sourceCodeStart":4346,"sourceCodeEnd":4382,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/lax_numpy.py#L4346-L4382","documentation":"jnp.pad supports a fixed set of modes (constant, edge, wrap, reflect, symmetric, empty, linear_ramp, maximum, mean, median, minimum). An unrecognized mode string hits a KeyError in the allowed-kwargs lookup and is re-raised as NotImplementedError.","triggerScenarios":"jnp.pad(x, 2, mode='circular') (numpy has no such mode either) or typo like mode='const'.","commonSituations":"Porting code expecting scipy-style mode names ('grid-wrap', 'grid-constant'); typos; newer numpy modes not yet implemented in JAX.","solutions":["Use one of the supported modes; 'wrap' is the circular equivalent","Check jnp.pad docstring for the current supported list in your JAX version"],"exampleFix":"// before\njnp.pad(x, 2, mode='circular')\n// after\njnp.pad(x, 2, mode='wrap')","handlingStrategy":"validation","validationCode":"SUPPORTED = {'constant','edge','wrap','reflect','symmetric','empty','linear_ramp','maximum','mean','median','minimum'}\nassert mode in SUPPORTED, f'unsupported pad mode {mode}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Map scipy mode names (circular->wrap, grid-wrap->wrap) when porting"],"tags":["jnp-pad","unsupported-mode","not-implemented"],"backgroundTag":"unsupported-argument-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}