Skip to content
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

scipy.sparse.linalg.inv cannot take ndarray as argument despite what documentation says #14607

Closed
gdupras opened this issue Aug 18, 2021 · 4 comments · Fixed by #15126
Closed
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.sparse.linalg
Milestone

Comments

@gdupras
Copy link

gdupras commented Aug 18, 2021

The documentation (scipy.sparse.linalg.inv) says

Parameters

A(M,M) ndarray or sparse matrix

square matrix to be inverted

But this code

import numpy as np
from scipy.sparse import linalg
linalg.inv(np.array([[1, 2], [3, 4]]))

throws:

TypeError: Input must be a sparse matrix
@gdupras gdupras changed the title scipy.sparse.linalg.inv can take ndarray as argument despite what documentation says scipy.sparse.linalg.inv cannot take ndarray as argument despite what documentation says Aug 18, 2021
@WarrenWeckesser WarrenWeckesser added defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.sparse.linalg labels Aug 19, 2021
@WarrenWeckesser
Copy link
Member

WarrenWeckesser commented Aug 19, 2021

I suspect the best option here is to fix the docs.

@gdupras
Copy link
Author

gdupras commented Aug 19, 2021

Would it be possible for scipy.sparse.linalg.inv to call np.linalg.inv if A is an ndarray?

@WarrenWeckesser
Copy link
Member

@gdupras, yes, that's possible, and it may have been the original intent of the docstring author, but the explicit check for a sparse input has been there for many years, so I suspect there isn't much demand for that convenience. @perimosocordiae, @pv: any preferences?

@stefanv
Copy link
Member

stefanv commented Oct 9, 2021

May be best to fix the docs here, since it is not clear which inv to dispatch to otherwise (scipy? numpy?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.sparse.linalg
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants