jax-ml/jax · error · ValueError
Expected 'output' to be either 'real' or 'complex', got {out
Error message
Expected 'output' to be either 'real' or 'complex', got {output=}. What it means
jax.scipy.linalg.schur requires the `output` argument to be exactly the string 'real' or 'complex'; anything else (including typos, wrong case, or None) raises ValueError before dispatching to the underlying Schur decomposition.
Source
Thrown at jax/_src/scipy/linalg.py:575
upper-triangular in this case because the input matrix is symmetric:
>>> T # doctest: +SKIP
Array([[-2.0000005 , 0.5066295 , -0.43360388],
[ 0. , 1.5505103 , 0.74519426],
[ 0. , 0. , 6.449491 ]], dtype=float32)
The transformation matrix ``Z`` is unitary:
>>> jnp.allclose(Z.T @ Z, jnp.eye(3), atol=1E-5)
Array(True, dtype=bool)
The input can be reconstructed from the outputs:
>>> jnp.allclose(Z @ T @ Z.T, a)
Array(True, dtype=bool)
"""
if output not in ('real', 'complex'):
raise ValueError(
f"Expected 'output' to be either 'real' or 'complex', got {output=}.")
return _schur(ensure_arraylike("scipy.schur", a), output)
def inv(a: ArrayLike, overwrite_a: bool = False, check_finite: bool = True) -> Array:
"""Return the inverse of a square matrix
JAX implementation of :func:`scipy.linalg.inv`.
Args:
a: array of shape ``(..., N, N)`` specifying square array(s) to be inverted.
overwrite_a: unused in JAX
check_finite: unused in JAX
Returns:
Array of shape ``(..., N, N)`` containing the inverse of the input.
Notes:View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Pass output='real' for real Schur form or output='complex' for complex Schur form explicitly
- If building output dynamically, validate/normalize the value before calling schur
Example fix
// before T, Z = jax.scipy.linalg.schur(A, output=np.iscomplexobj(A)) // after T, Z = jax.scipy.linalg.schur(A, output='complex' if np.iscomplexobj(A) else 'real')
Defensive patterns
Strategy: type-guard
Validate before calling
null
Type guard
def is_valid_schur_output(o: str) -> bool: return o in ('real', 'complex') Try / catch
try: T, Z = jax.scipy.linalg.schur(A, output=out) except ValueError as e: if 'output' in str(e): out = 'complex' if np.iscomplexobj(A) else 'real'; T, Z = jax.scipy.linalg.schur(A, output=out) else: raise
Prevention
- Derive output from array complexity: 'complex' if np.iscomplexobj(A) else 'real'
- Validate enum-like kwargs at your API boundary
When it happens
Trigger: Calling jax.scipy.linalg.schur(A, output='r'), output='REAL', output=None, or any other string.
Common situations: Passing a variable that was never validated, or assuming schur defaults output to None like older SciPy versions; porting code where output was optional.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ind must be a positive integer; got {ind=}
- multi_dot requires at least two arrays; got len(arrays)={len
- Unsupported QR decomposition mode '{mode}'
- mode must be 'right' or 'left', got {mode!r}
- Expected assume_a to be one of {valid_assume_a}; got {assume
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/933dd7dae11c6b1b.
Report an issue: GitHub.