{"record":{"id":"eb734c77555be8d2","repo":"jax-ml/jax","slug":"unknown-polar-decomposition-method-method","errorCode":null,"errorMessage":"Unknown polar decomposition method {method}.","messagePattern":"Unknown polar decomposition method (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/linalg.py","lineNumber":2042,"sourceCode":"    elif m < n and side == \"left\":\n      a = a.T.conj()\n      unitary, posdef, _, _ = qdwh.qdwh(a, is_hermitian=False, eps=eps)\n      posdef = posdef.T.conj()\n      unitary = unitary.T.conj()\n    else:\n      raise NotImplementedError(\"method='qdwh' only supports mxn matrices \"\n                                \"where m < n where side='right' and m >= n \"\n                                f\"side='left', got {a.shape} with {side=}\")\n  elif method == \"svd\":\n    u_svd, s_svd, vh_svd = lax_linalg.svd(a, full_matrices=False)\n    s_svd = s_svd.astype(u_svd.dtype)\n    unitary = u_svd @ vh_svd\n    if side == \"right\":\n      posdef = (vh_svd.T.conj() * s_svd[None, :]) @ vh_svd\n    else:\n      posdef = (u_svd * s_svd[None, :]) @ (u_svd.T.conj())\n  else:\n    raise ValueError(f\"Unknown polar decomposition method {method}.\")\n  return unitary, posdef\n\n\n@jit(static_argnames=('side', 'method'))\ndef polar(a: ArrayLike, side: str = 'right', *, method: str = 'qdwh', eps: float | None = None,\n          max_iterations: int | None = None) -> tuple[Array, Array]:\n  r\"\"\"Computes the polar decomposition.\n\n  Given the :math:`m \\times n` matrix :math:`a`, returns the factors of the polar\n  decomposition :math:`u` (also :math:`m \\times n`) and :math:`p` such that\n  :math:`a = up` (if side is ``\"right\"``; :math:`p` is :math:`n \\times n`) or\n  :math:`a = pu` (if side is ``\"left\"``; :math:`p` is :math:`m \\times m`),\n  where :math:`p` is positive semidefinite.  If :math:`a` is nonsingular,\n  :math:`p` is positive definite and the\n  decomposition is unique. :math:`u` has orthonormal columns unless\n  :math:`n > m`, in which case it has orthonormal rows.\n\n  Writing the SVD of :math:`a` as","sourceCodeStart":2024,"sourceCodeEnd":2060,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/linalg.py#L2024-L2060","documentation":"jax.scipy.linalg.polar accepts only method='qdwh' or method='svd'. The dispatch chain ends in an else branch raising ValueError('Unknown polar decomposition method {method}.') for anything else. Unlike SciPy (which has no method parameter), JAX exposes the algorithm choice explicitly.","triggerScenarios":"Calling polar(a, method='hartung'/'newton'/'numpy'/...) or any string other than 'qdwh' or 'svd'.","commonSituations":"Assuming SciPy-style or other iterative polar algorithms exist; passing a config variable that is None or misspelled.","solutions":["Use method='qdwh' (default, faster on TPU/GPU) or method='svd'","Omit method entirely to get the default"],"exampleFix":"# before\nU, H = polar(a, method='newton')\n# after\nU, H = polar(a, method='qdwh')  # or method='svd'","handlingStrategy":"validation","validationCode":"METHODS = ('qdwh', 'svd')\nif method not in METHODS:\n    raise ValueError(f\"method must be one of {METHODS}, got {method!r}\")\nU, H = polar(a, method=method)","typeGuard":null,"tryCatchPattern":"try:\n    polar(a, method=method)\nexcept ValueError as e:\n    if 'Unknown polar decomposition' in str(e):\n        method = 'svd'; polar(a, method=method)\n    else: raise","preventionTips":["Restrict method to a whitelist constant shared across the codebase","Default method='qdwh' and only override deliberately","Validate config-sourced algorithm names before use"],"tags":["jax","argument-validation","polar-decomposition"],"backgroundTag":"invalid-enum-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}