jax-ml/jax · error · ValueError
Expected kind to be on of
Error message
Expected kind to be on of: {valid_kind}; got {kind} What it means
Raised by jax.scipy.linalg.lesp... actually the matrix-generation helper (e.g. hadamard/pascal-family) when the `kind` argument is not one of 'symmetric', 'lower', 'upper'. JAX validates the string up front because downstream code branches on it. It mirrors scipy's parameter but with eager checking.
Solutions
- Set kind to one of the exact strings 'symmetric', 'lower', or 'upper'
- Check for leading/trailing whitespace or wrong case in the string
- If kind came from config/CLI input, normalize and validate it before passing
Example fix
# before linalg.pascal(n, kind='Lower') # after linalg.pascal(n, kind='lower')
Defensive patterns
Strategy: validation
Validate before calling
if kind not in ('symmetric','lower','upper'): raise ValueError(kind) Type guard
def is_valid_kind(k: str) -> bool: return k in ('symmetric', 'lower', 'upper') Prevention
- Whitelist kind strings at config load
- Keep enum constants in one module
When it happens
Trigger: Calling the public linalg routine with kind='Low', kind='diag', or any misspelled/unsupported string; default is 'symmetric' when kind is None.
Common situations: Porting scipy code that used a different spelling, passing kind positionally with the wrong argument order, or typos/case mismatches.
Understand the failure class
Background: "invalid argument", "unknown mode", "not supported": invalid enum-like argument errors explained — this error's family across 19 libraries.
Related errors
- Expected kind to be one of
- ind must be a positive integer; got
- n must be a positive power of 2; got
- scale must be None, 'sqrtn', or 'n'; got
- Unrecognized method . The two valid methods are either…
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/7708adbbcf38bf90.
Report an issue: GitHub.
Appendix: source
Thrown at jax/_src/scipy/linalg.py:3008
[1. 1. 0.]
[1. 2. 1.]]
[[1. 1. 1. 1.]
[0. 1. 2. 3.]
[0. 0. 1. 3.]
[0. 0. 0. 1.]]
[[ 1. 1. 1. 1. 1.]
[ 1. 2. 3. 4. 5.]
[ 1. 3. 6. 10. 15.]
[ 1. 4. 10. 20. 35.]
[ 1. 5. 15. 35. 70.]]
"""
if kind is None:
kind = "symmetric"
valid_kind = ["symmetric", "lower", "upper"]
if kind not in valid_kind:
raise ValueError(f"Expected kind to be on of: {valid_kind}; got {kind}")
a = jnp.arange(n, dtype=np.float32)
L_n = _binom(a[:, None], a[None, :])
if kind == "lower":
return L_n
if kind == "upper":
return L_n.T
return jnp.dot(L_n, L_n.T)
@jit
def _binom(n, k):
a = lax.lgamma(n + 1.0)
b = lax.lgamma(n - k + 1.0)
c = lax.lgamma(k + 1.0)View on GitHub (pinned to 1e1c6a8fc0)