{"record":{"id":"906dd8130d215d87","repo":"jax-ml/jax","slug":"the-only-valid-string-value-of-right-is-extrapo","errorCode":null,"errorMessage":"the only valid string value of `right` is 'extrapolate', but got: {right!r}","messagePattern":"the only valid string value of `right` is 'extrapolate', but got: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/lax_numpy.py","lineNumber":2615,"sourceCode":"           right: ArrayLike | str | None = None,\n           period: ArrayLike | None = None) -> Array:\n  x, xp, fp = util.ensure_arraylike(\"interp\", x, xp, fp)\n  if np.shape(xp) != np.shape(fp) or np.ndim(xp) != 1:\n    raise ValueError(\"xp and fp must be one-dimensional arrays of equal size\")\n  x_arr, xp_arr = util.promote_dtypes_inexact(x, xp)\n  fp_arr, = util.promote_dtypes_inexact(fp)\n  del x, xp, fp\n\n  if isinstance(left, str):\n    if left != 'extrapolate':\n      raise ValueError(\"the only valid string value of `left` is \"\n                       f\"'extrapolate', but got: {left!r}\")\n    extrapolate_left = True\n  else:\n    extrapolate_left = False\n  if isinstance(right, str):\n    if right != 'extrapolate':\n      raise ValueError(\"the only valid string value of `right` is \"\n                       f\"'extrapolate', but got: {right!r}\")\n    extrapolate_right = True\n  else:\n    extrapolate_right = False\n\n  if dtypes.issubdtype(x_arr.dtype, np.complexfloating):\n    raise ValueError(\"jnp.interp: complex x values not supported.\")\n\n  if period is not None:\n    if np.ndim(period) != 0:\n      raise ValueError(f\"period must be a scalar; got {period}\")\n    period = ufuncs.abs(period)\n    x_arr = x_arr % period\n    xp_arr = xp_arr % period\n    xp_arr, fp_arr = lax.sort_key_val(xp_arr, fp_arr)\n    xp_arr = concatenate([xp_arr[-1:] - period, xp_arr, xp_arr[:1] + period])\n    fp_arr = concatenate([fp_arr[-1:], fp_arr, fp_arr[:1]])\n","sourceCodeStart":2597,"sourceCodeEnd":2633,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/lax_numpy.py#L2597-L2633","documentation":"jnp.interp accepts the special string 'extrapolate' for the right argument (to extrapolate above the last xp point). Any other string is rejected; only 'extrapolate' or a numeric bound is valid.","triggerScenarios":"Calling jnp.interp(x, xp, fp, right='extend') or any non-'extrapolate' string for right.","commonSituations":"Migrating SciPy np.interp-style code with custom sentinel strings; copy-paste from codebases that use different extrapolation flags.","solutions":["Use right='extrapolate' or a numeric scalar","Fix string typos","Leave right unset for the default fp[-1] behavior"],"exampleFix":"// before\njnp.interp(x, xp, fp, right='extrapolte')\n// after\njnp.interp(x, xp, fp, right='extrapolate')","handlingStrategy":"validation","validationCode":"if isinstance(right, str) and right != 'extrapolate':\n    right = 'extrapolate'  # or raise","typeGuard":"def is_valid_interp_bound(v) -> bool:\n    return not isinstance(v, str) or v == 'extrapolate'","tryCatchPattern":"catch ValueError, fall back to numeric bound or default","preventionTips":["Use typing.Literal['extrapolate'] in wrappers to get static checking","Centralize interp kwargs in one config object"],"tags":["jax","interp","invalid-argument","sentinel-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}