{"record":{"id":"614a6c911d8038cc","repo":"jax-ml/jax","slug":"for-select-i-select-range-must-be-specified","errorCode":null,"errorMessage":"for select='i', select_range must be specified.","messagePattern":"for select='i', select_range must be specified\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/linalg.py","lineNumber":1835,"sourceCode":"  pivmin = safemin * jnp.maximum(1, jnp.amax(beta_sq))\n  alpha0_perturbation = jnp.square(finfo.eps * beta_abs[0])\n  abs_tol = finfo.eps * t_norm\n  if tol is not None:\n    abs_tol = jnp.maximum(tol, abs_tol)\n\n  # In the worst case, when the absolute tolerance is eps*lambda_est_max and\n  # lambda_est_max = -lambda_est_min, we have to take as many bisection steps\n  # as there are bits in the mantissa plus 1.\n  # 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","sourceCodeStart":1817,"sourceCodeEnd":1853,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/linalg.py#L1817-L1853","documentation":"When eigh_tridiagonal is called with select='i' (select eigenvalues by index range), you must supply select_range=(lo, hi) specifying which eigenvalue indices to return. Without it, ValueError is raised.","triggerScenarios":"Calling jax.scipy.linalg.eigh_tridiagonal(d, e, select='i') with select_range left at its default None.","commonSituations":"Porting scipy.linalg.eigh_tridiagonal calls where select_range was always provided; conditionally setting select but forgetting to pass the matching range.","solutions":["Pass select_range=(lo, hi) inclusive, e.g. select='i', select_range=(0, k-1) for the lowest k eigenvalues","Or use the default select='a' and slice the full result if dynamic shapes are problematic under jit"],"exampleFix":"// before\nw = jax.scipy.linalg.eigh_tridiagonal(d, e, select='i', eigvals_only=True)\n// after\nw = jax.scipy.linalg.eigh_tridiagonal(d, e, select='i', select_range=(0, 4), eigvals_only=True)","handlingStrategy":"validation","validationCode":"if select == 'i': assert select_range is not None, 'select_range required for select=i'","typeGuard":"null","tryCatchPattern":null,"preventionTips":["Pair select='i' with an explicit select_range tuple in one place","Consider select='a' + slicing when shapes must stay static under jit"],"tags":["jax","linalg","tridiagonal","missing-argument"],"backgroundTag":"missing-required-parameter","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}