-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Open
Description
My issue is about the error message reported with sparse iterative solver. I'm using scipy version 1.5.0 on Windows 10 under Anaconda.
Reproducing code example:
import numpy as np
from scipy.sparse.linalg import * # gets solvers
from scipy import sparse,linalg
data=(1,1,1)
rows=(0,1,2)
cols=(0,1,2)
kk=sparse.coo_matrix((data,(rows,cols)),shape=(3,3))
data=(1,1,1)
rows=(0,1,2)
cols=(0,0,0)
rhs=sparse.coo_matrix((data,(rows,cols)),shape=(3,1))
The following
x,exitCode=bicg(kk,rhs)
yields the error message
Error message:
Traceback (most recent call last):
File "G:\Work\Misc\sparserhsbugreport.py", line 23, in <module>
x,exitCode=bicg(kk,rhs)
File "<decorator-gen-1>", line 2, in bicg
File "C:\Users\aa\anaconda3\envs\py383\lib\site-packages\scipy\_lib\_threadsafety.py", line 44, in caller
return func(*a, **kw)
File "C:\Users\aa\anaconda3\envs\py383\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 151, in bicg
A,M,x,b,postprocess = make_system(A, M, x0, b)
File "C:\Users\aa\anaconda3\envs\py383\lib\site-packages\scipy\sparse\linalg\isolve\utils.py", line 74, in make_system
raise ValueError('A and b have incompatible dimensions')
ValueError: A and b have incompatible dimensions
However, the following works:
x,exitCode=bicg(kk,rhs.todense())
as noted here. This shows that the problem is not the dimensions of the rhs. The issue is that the rhs is a sparse vector. Maybe a better error message saying "Sparse right hand sides are not allowed" instead of the misleading "A and b have incompatible dimensions"
Scipy/Numpy/Python version information:
1.5.0 1.18.5 sys.version_info(major=3, minor=8, micro=3, releaselevel='final', serial=0)