Skip to content

Commit

Permalink
Fix sparse construction for old scipy
Browse files Browse the repository at this point in the history
  • Loading branch information
mwshinn committed Apr 10, 2020
1 parent a35ec44 commit c8671a5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ddm/tridiag.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ def __init__(self, diag=None, up=None, down=None):
@pns.returns(sparse.spmatrix)
def to_scipy_sparse(self):
"""Returns the matrix as a scipy sparse matrix in CSR format."""
return sparse.diags([self.up, self.diag, self.down], [1, 0, -1], format="csr")
if len(self.up) == 0:
return sparse.diags([self.diag], [0])
else:
return sparse.diags([self.up, self.diag, self.down], [1, 0, -1], format="csr")
@classmethod
def eye(cls, size):
"""Return an identity matrix of size `size`."""
Expand Down

0 comments on commit c8671a5

Please sign in to comment.