Skip to content

Wrong return type for linalg.eigh in function signature #922

Closed
@Saransh-cpp

Description

@Saransh-cpp

eigh returns a Tuple[array] according to the function signature -

def eigh(x: array, /) -> Tuple[array]:

but it actually returns a NamedTuple (hence, Tuple[array, array]) -

Returns
-------
out: Tuple[array]
a namedtuple (``eigenvalues``, ``eigenvectors``) whose
- first element must have the field name ``eigenvalues`` (corresponding to :math:`\operatorname{diag}\Lambda` above) and must be an array consisting of computed eigenvalues. The array containing the eigenvalues must have shape ``(..., M)`` and must have a real-valued floating-point data type whose precision matches the precision of ``x`` (e.g., if ``x`` is ``complex128``, then ``eigenvalues`` must be ``float64``).
- second element have have the field name ``eigenvectors`` (corresponding to :math:`Q` above) and must be an array where the columns of the inner most matrices contain the computed eigenvectors. These matrices must be orthogonal. The array containing the eigenvectors must have shape ``(..., M, M)`` and must have the same data type as ``x``.

which causes problems with type checkers.

Is this intentional or is it a bug? I'd be happy to submit a quick patch to fix the function signature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions