Skip to content

Commit

Permalink
Merge pull request #67 from loganbvh/sparray
Browse files Browse the repository at this point in the history
Allow scipy.sparse.sparray inputs
  • Loading branch information
haasad authored Mar 5, 2024
2 parents fed4dd5 + 9fef055 commit f2ede0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pypardiso/pardiso_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ def _check_A(self, A):
if A.shape[0] != A.shape[1]:
raise ValueError('Matrix A needs to be square, but has shape: {}'.format(A.shape))

if sp.isspmatrix_csr(A):
if sp.issparse(A) and A.format == "csr":
self._solve_transposed = False
self.set_iparm(12, 0)
elif sp.isspmatrix_csc(A):
elif sp.issparse(A) and A.format == "csc":
self._solve_transposed = True
self.set_iparm(12, 1)
else:
Expand All @@ -241,7 +241,7 @@ def _check_A(self, A):
raise TypeError('PyPardiso currently only supports float64, but matrix A has dtype: {}'.format(A.dtype))

def _check_b(self, A, b):
if sp.isspmatrix(b):
if sp.issparse(b):
warnings.warn('PyPardiso requires the right-hand side b to be a dense array for maximum efficiency',
SparseEfficiencyWarning)
b = b.todense()
Expand Down
2 changes: 1 addition & 1 deletion pypardiso/scipy_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def spsolve(A, b, factorize=True, squeeze=True, solver=pypardiso_solver, *args,
in two steps, therefore it is factorized by default. Subsequent calls to spsolve with the same matrix A
will be drastically faster. This makes the "factorized" method obsolete, but it is kept for compatibility.
"""
if sp.isspmatrix_csc(A):
if sp.issparse(A) and A.format == "csc":
A = A.tocsr() # fixes issue with brightway2 technosphere matrix

solver._check_A(A)
Expand Down

0 comments on commit f2ede0e

Please sign in to comment.