{"record":{"id":"6ebe619bcb967893","repo":"jax-ml/jax","slug":"select-must-have-a-value-in-a-i-v","errorCode":null,"errorMessage":"'select must have a value in {'a', 'i', 'v'}.","messagePattern":"'select must have a value in (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/linalg.py","lineNumber":1844,"sourceCode":"  # The proof is left as an exercise to the reader.\n  max_it = finfo.nmant + 1\n\n  # Determine the indices of the desired eigenvalues, based on select and\n  # select_range.\n  if select == 'a':\n    target_counts = jnp.arange(n, dtype=np.int32)\n  elif select == 'i':\n    if select_range is None:\n      raise ValueError(\"for select='i', select_range must be specified.\")\n    if select_range[0] > select_range[1]:\n      raise ValueError('Got empty index range in select_range.')\n    target_counts = jnp.arange(select_range[0], select_range[1] + 1, dtype=np.int32)\n  elif select == 'v':\n    # TODO(phawkins): requires dynamic shape support.\n    raise NotImplementedError(\"eigh_tridiagonal(..., select='v') is not \"\n                              \"implemented\")\n  else:\n    raise ValueError(\"'select must have a value in {'a', 'i', 'v'}.\")\n\n  # Run binary search for all desired eigenvalues in parallel, starting from\n  # the interval lightly wider than the estimated\n  # [lambda_est_min, lambda_est_max].\n  fudge = 2.1  # We widen starting interval the Gershgorin interval a bit.\n  norm_slack = jnp.array(n, alpha.dtype) * fudge * finfo.eps * t_norm\n  lower = lambda_est_min - norm_slack - 2 * fudge * pivmin\n  upper = lambda_est_max + norm_slack + fudge * pivmin\n\n  # Pre-broadcast the scalars used in the Sturm sequence for improved\n  # performance.\n  target_shape = np.shape(target_counts)\n  lower = jnp.broadcast_to(lower, shape=target_shape)\n  upper = jnp.broadcast_to(upper, shape=target_shape)\n  mid = 0.5 * (upper + lower)\n  pivmin = jnp.broadcast_to(pivmin, target_shape)\n  alpha0_perturbation = jnp.broadcast_to(alpha0_perturbation, target_shape)\n","sourceCodeStart":1826,"sourceCodeEnd":1862,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/linalg.py#L1826-L1862","documentation":"eigh_tridiagonal validates its select argument and only accepts 'a', 'i', or 'v'. Any other string (including typos, None, or a non-canonical spelling) reaches the final else branch and raises ValueError. Note that even valid-but-unimplemented 'v' raises a different error (NotImplementedError).","triggerScenarios":"Calling eigh_tridiagonal with select='A', select='index', select='values', select=None, or any string not exactly in {'a','i','v'} (case-sensitive).","commonSituations":"Typos or case mistakes when porting SciPy code; passing a variable that defaulted to None; assuming case-insensitive matching as in some other APIs.","solutions":["Pass exactly one of 'a', 'i', or 'v' (lowercase)","If you meant an index range, use select='i' with select_range=(il, iu)","If you meant a value range, use select='v' (but note JAX raises NotImplementedError for it — use select='a' plus filtering)"],"exampleFix":"# before\neigh_tridiagonal(d, e, select='index', select_range=(0, 5))\n# after\neigh_tridiagonal(d, e, select='i', select_range=(0, 5))","handlingStrategy":"validation","validationCode":"VALID = {'a', 'i', 'v'}\nif select not in VALID:\n    raise ValueError(f\"select must be one of {VALID}, got {select!r}\")\nw = eigh_tridiagonal(d, e, select=select, ...)\n# note: 'v' itself raises NotImplementedError in JAX","typeGuard":null,"tryCatchPattern":"try:\n    eigh_tridiagonal(d, e, select=select)\nexcept ValueError as e:\n    if \"select must have a value\" in str(e):\n        raise ValueError('bad select') from e","preventionTips":["Keep enum-like arguments in module-level constants next to the call site","Validate mode strings at the API boundary (CLI/config parser), not deep in numerics","Add unit tests covering each valid select mode"],"tags":["jax","argument-validation","linalg","eigenvalues"],"backgroundTag":"invalid-enum-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}