New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: np.linalg.eigvalsh and np.linalg.eigh returns arbitrary values for nan input, but they make different mistakes #20280
Comments
Misunderstood the issue. Interesting that Edit: Identical results with OpenBLAS. |
Probably needs a nan detector for correctness. From https://spec.oneapi.io/versions/0.7/elements/oneMKL/source/domains/lapack/lapack.html |
@fdraxler, thanks for reporting this inconsistency in how As noted above,
See the concrete examples below. A simple fix is to follow the example of An alternative that is more in line with how ufuncs behave is to return all I guess a third option is to just put a warning in the documentation that passing What do folks think? Example of 1.
Example of 2.
Example of 3.
|
I would rank the options 2, 1, and then 3. 2I think would could modify 2 so that it returns 1This is easy and is closest to what 33 feels a bit wrong to me since the |
Describe the issue:
np.linalg.eigh
andnp.linalg.eigvalsh
produce unexpected results for certain inputs containing nan (see code example with outputs). They do so inconsistently (first example).I would argue that any nan in a matrix should result in at least one eigenvalue set to nan. To be more precise, if the matrix is a block diagonal matrix, only the blocks containing nan should return nan.
To avoid block identification, it might be sufficient to check if a matrix contains nan and return all eigenvalues set to nan in this case. This would be an improvement over the current outputs.
Reproduce the code example:
Error message:
No response
NumPy/Python version information:
1.21.3 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 20:33:18)
[Clang 11.1.0 ]
The text was updated successfully, but these errors were encountered: