{"record":{"id":"cb9a05875f329b3c","repo":"jax-ml/jax","slug":"unsupported-keyword-arguments-for-mode","errorCode":null,"errorMessage":"unsupported keyword arguments for mode '{}': {}","messagePattern":"unsupported keyword arguments for mode '(.+?)': (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/lax_numpy.py","lineNumber":4366,"sourceCode":"\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:\n  \"\"\"Join arrays along a new axis.\n","sourceCodeStart":4348,"sourceCodeEnd":4384,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/lax_numpy.py#L4348-L4384","documentation":"Each pad mode only accepts certain kwargs (e.g. 'constant' accepts constant_values; 'reflect' accepts reflect_type). Passing kwargs not in the mode's allow-list raises ValueError naming the unsupported kwargs.","triggerScenarios":"jnp.pad(x, 2, mode='wrap', constant_values=1) or mode='edge', stat_length=3.","commonSituations":"Copy-pasting kwargs between modes when switching; passing all possible kwargs defensively.","solutions":["Remove kwargs not applicable to the chosen mode","Check the allowed_kwargs table in the jnp.pad source/docstring"],"exampleFix":"// before\njnp.pad(x, 2, mode='wrap', constant_values=1)\n// after\njnp.pad(x, 2, mode='constant', constant_values=1)","handlingStrategy":"validation","validationCode":"ALLOWED = {'constant': {'constant_values'}, 'reflect': {'reflect_type'}, 'symmetric': {'reflect_type'}}\nassert set(kwargs) <= ALLOWED.get(mode, set()), 'bad kwargs for mode'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass kwargs relevant to the chosen mode; strip kwargs on mode switch"],"tags":["jnp-pad","unsupported-kwarg","keyword-arguments"],"backgroundTag":"unsupported-argument-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}