jax-ml/jax · error · ValueError

'select must have a value in {'a', 'i', 'v'}.

Error message

'select must have a value in {'a', 'i', 'v'}.

What it means

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).

Source

Thrown at jax/_src/scipy/linalg.py:1844

  # The proof is left as an exercise to the reader.
  max_it = finfo.nmant + 1

  # Determine the indices of the desired eigenvalues, based on select and
  # select_range.
  if select == 'a':
    target_counts = jnp.arange(n, dtype=np.int32)
  elif select == 'i':
    if select_range is None:
      raise ValueError("for select='i', select_range must be specified.")
    if select_range[0] > select_range[1]:
      raise ValueError('Got empty index range in select_range.')
    target_counts = jnp.arange(select_range[0], select_range[1] + 1, dtype=np.int32)
  elif select == 'v':
    # TODO(phawkins): requires dynamic shape support.
    raise NotImplementedError("eigh_tridiagonal(..., select='v') is not "
                              "implemented")
  else:
    raise ValueError("'select must have a value in {'a', 'i', 'v'}.")

  # Run binary search for all desired eigenvalues in parallel, starting from
  # the interval lightly wider than the estimated
  # [lambda_est_min, lambda_est_max].
  fudge = 2.1  # We widen starting interval the Gershgorin interval a bit.
  norm_slack = jnp.array(n, alpha.dtype) * fudge * finfo.eps * t_norm
  lower = lambda_est_min - norm_slack - 2 * fudge * pivmin
  upper = lambda_est_max + norm_slack + fudge * pivmin

  # Pre-broadcast the scalars used in the Sturm sequence for improved
  # performance.
  target_shape = np.shape(target_counts)
  lower = jnp.broadcast_to(lower, shape=target_shape)
  upper = jnp.broadcast_to(upper, shape=target_shape)
  mid = 0.5 * (upper + lower)
  pivmin = jnp.broadcast_to(pivmin, target_shape)
  alpha0_perturbation = jnp.broadcast_to(alpha0_perturbation, target_shape)

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Pass exactly one of 'a', 'i', or 'v' (lowercase)
  2. If you meant an index range, use select='i' with select_range=(il, iu)
  3. If you meant a value range, use select='v' (but note JAX raises NotImplementedError for it — use select='a' plus filtering)

Example fix

# before
eigh_tridiagonal(d, e, select='index', select_range=(0, 5))
# after
eigh_tridiagonal(d, e, select='i', select_range=(0, 5))
Defensive patterns

Strategy: validation

Validate before calling

VALID = {'a', 'i', 'v'}
if select not in VALID:
    raise ValueError(f"select must be one of {VALID}, got {select!r}")
w = eigh_tridiagonal(d, e, select=select, ...)
# note: 'v' itself raises NotImplementedError in JAX

Try / catch

try:
    eigh_tridiagonal(d, e, select=select)
except ValueError as e:
    if "select must have a value" in str(e):
        raise ValueError('bad select') from e

Prevention

When it happens

Trigger: Calling eigh_tridiagonal with select='A', select='index', select='values', select=None, or any string not exactly in {'a','i','v'} (case-sensitive).

Common situations: Typos or case mistakes when porting SciPy code; passing a variable that defaulted to None; assuming case-insensitive matching as in some other APIs.

Related errors


AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27). Data as JSON: /api/errors/6ebe619bcb967893. Report an issue: GitHub.