{"record":{"id":"29692bb3f5c483f2","repo":"jax-ml/jax","slug":"unrecognized-method-method-the-two-valid-method","errorCode":null,"errorMessage":"Unrecognized method {method}. The two valid methods are either \\\"schur\\\" or \\\"eigen\\\".","messagePattern":"Unrecognized method (.+?)\\. The two valid methods are either \\\\\"schur\\\\\" or \\\\\"eigen\\\\\"\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/linalg.py","lineNumber":3291,"sourceCode":"\n@jit(static_argnames=[\"method\"])\ndef _solve_sylvester_2d(A: Array, B: Array, C: Array, *, method: str, tol: float) -> Array:\n  m, n = C.shape[-2:]\n  if method == \"schur\":\n    R, U = schur(A, output='complex')\n    S, V = schur(B.conj().T, output='complex')\n    F = U.conj().T @ C.astype(R.dtype) @ V\n    Y = _solve_sylvester_triangular_scan(R, S.conj().T, F)\n    X = U @ Y @ V.conj().T\n  elif method == \"eigen\":\n    RA, UA = jnp.linalg.eig(A)\n    RB, UB = jnp.linalg.eig(B)\n    F = solve(UA, C.astype(RA.dtype) @ UB)\n    W = RA[:, None] + RB[None, :]\n    Y = F / W\n    X = UA[:m,:m] @ Y[:m,:n] @ inv(UB)[:n,:n]\n  else:\n    raise ValueError(f\"Unrecognized method {method}. The two valid methods are either \\\"schur\\\" or \\\"eigen\\\".\")\n  if not dtypes.issubdtype(C.dtype, np.complexfloating):\n    X = X.real\n  return lax.cond(\n    jnp.any(jnp.abs(jnp.linalg.eigvals(A)[:, None] + jnp.linalg.eigvals(B)[None, :]) < tol),\n    lambda: jnp.zeros_like(X) * np.nan,\n    lambda: X,\n  )\n\n\n@jit(static_argnames=[\"method\"])\ndef solve_sylvester(A: ArrayLike, B: ArrayLike, C: ArrayLike, *, method: str = \"schur\", tol: float = 1e-8) -> Array:\n  \"\"\"\n  Solves the Sylvester equation\n  .. math::\n\n    AX + XB = C\n\n  Using one of two methods.","sourceCodeStart":3273,"sourceCodeEnd":3309,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/linalg.py#L3273-L3309","documentation":"jax.scipy.linalg.solve_sylvester supports only method='schur' or method='eigen'; anything else reaches the else-branch raising this ValueError. The method selects the Bartels-Stewart Schur decomposition or eigendecomposition path.","triggerScenarios":"Calling solve_sylvester(A, B, C, method='qr'), method='', or a misspelled string like 'Schur'.","commonSituations":"Copy-paste from custom solvers; passing a method intended for a different scipy function.","solutions":["Use 'schur' (default, more stable) or 'eigen'","Validate method strings before calling"],"exampleFix":"# before\nX = linalg.solve_sylvester(A, B, C, method='schur ')  # stray space\n# after\nX = linalg.solve_sylvester(A, B, C, method='schur')","handlingStrategy":"validation","validationCode":"if method not in ('schur','eigen'): raise ValueError(method)","typeGuard":"def is_valid_method(m: str) -> bool: return m in ('schur', 'eigen')","tryCatchPattern":null,"preventionTips":["Strip/normalize method strings from configs"],"tags":["jax","scipy","linalg","sylvester","argument-validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}