{"record":{"id":"1658d1545cc1dc52","repo":"jax-ml/jax","slug":"the-only-valid-string-value-of-left-is-extrapol","errorCode":null,"errorMessage":"the only valid string value of `left` is 'extrapolate', but got: {left!r}","messagePattern":"the only valid string value of `left` is 'extrapolate', but got: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/lax_numpy.py","lineNumber":2608,"sourceCode":"    lax.add(atol, lax.mul(rtol, lax.abs(b))))\n  out = ufuncs.logical_or(lax.eq(a, b), ufuncs.logical_and(check_fin, in_range))\n  return ufuncs.logical_or(out, both_nan) if equal_nan else out\n\n\ndef _interp(x: ArrayLike, xp: ArrayLike, fp: ArrayLike,\n           left: ArrayLike | str | None = None,\n           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}\")","sourceCodeStart":2590,"sourceCodeEnd":2626,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/lax_numpy.py#L2590-L2626","documentation":"jnp.interp accepts the special string 'extrapolate' for the left argument (to extrapolate below the first xp point). Any other string value is rejected because the API only defines one valid string sentinel; numeric/scalar bounds are fine, strings other than 'extrapolate' are not.","triggerScenarios":"Calling jnp.interp(x, xp, fp, left='extend'), left='min', left='none', or any non-'extrapolate' string. Numeric left values do not trigger this.","commonSituations":"Porting NumPy/SciPy interpolation code that used a different sentinel string, or passing None/'None' expecting a null bound; typos like 'extrapolte'.","solutions":["Pass left='extrapolate' exactly, or pass a numeric scalar (e.g. left=-1.0) for a constant fill value","Check for typos in the string","Omit left to get the default fp[0] behavior"],"exampleFix":"// before\njnp.interp(x, xp, fp, left='extend')\n// after\njnp.interp(x, xp, fp, left='extrapolate')","handlingStrategy":"validation","validationCode":"if isinstance(left, str) and left != 'extrapolate':\n    raise ValueError(\"left must be a number or 'extrapolate'\")","typeGuard":"def is_valid_interp_bound(v) -> bool:\n    return not isinstance(v, str) or v == 'extrapolate'","tryCatchPattern":"catch ValueError and re-raise with caller context showing the offending left value","preventionTips":["Validate sentinel strings in a thin wrapper around jnp.interp","Keep interpolation config as dataclasses with validated Literal['extrapolate'] fields"],"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"}