{"record":{"id":"7708adbbcf38bf90","repo":"jax-ml/jax","slug":"expected-kind-to-be-on-of-valid-kind-got-kind","errorCode":null,"errorMessage":"Expected kind to be on of: {valid_kind}; got {kind}","messagePattern":"Expected kind to be on of: (.+?); got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/linalg.py","lineNumber":3008,"sourceCode":"     [1. 1. 0.]\n     [1. 2. 1.]]\n    [[1. 1. 1. 1.]\n     [0. 1. 2. 3.]\n     [0. 0. 1. 3.]\n     [0. 0. 0. 1.]]\n    [[ 1.  1.  1.  1.  1.]\n     [ 1.  2.  3.  4.  5.]\n     [ 1.  3.  6. 10. 15.]\n     [ 1.  4. 10. 20. 35.]\n     [ 1.  5. 15. 35. 70.]]\n  \"\"\"\n  if kind is None:\n    kind = \"symmetric\"\n\n  valid_kind = [\"symmetric\", \"lower\", \"upper\"]\n\n  if kind not in valid_kind:\n    raise ValueError(f\"Expected kind to be on of: {valid_kind}; got {kind}\")\n\n  a = jnp.arange(n, dtype=np.float32)\n\n  L_n = _binom(a[:, None], a[None, :])\n\n  if kind == \"lower\":\n    return L_n\n\n  if kind == \"upper\":\n    return L_n.T\n\n  return jnp.dot(L_n, L_n.T)\n\n@jit\ndef _binom(n, k):\n  a = lax.lgamma(n + 1.0)\n  b = lax.lgamma(n - k + 1.0)\n  c = lax.lgamma(k + 1.0)","sourceCodeStart":2990,"sourceCodeEnd":3026,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/linalg.py#L2990-L3026","documentation":"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.","triggerScenarios":"Calling the public linalg routine with kind='Low', kind='diag', or any misspelled/unsupported string; default is 'symmetric' when kind is None.","commonSituations":"Porting scipy code that used a different spelling, passing kind positionally with the wrong argument order, or typos/case mismatches.","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"],"exampleFix":"# before\nlinalg.pascal(n, kind='Lower')\n# after\nlinalg.pascal(n, kind='lower')","handlingStrategy":"validation","validationCode":"if kind not in ('symmetric','lower','upper'): raise ValueError(kind)","typeGuard":"def is_valid_kind(k: str) -> bool: return k in ('symmetric', 'lower', 'upper')","tryCatchPattern":null,"preventionTips":["Whitelist kind strings at config load","Keep enum constants in one module"],"tags":["jax","scipy","linalg","argument-validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}