Skip to content

Commit

Permalink
bug: fixed non-finalized conversion to siesta
Browse files Browse the repository at this point in the history
This was apparent for non-finalized sparsity patterns (custom made ones).
  • Loading branch information
zerothi committed Sep 8, 2022
1 parent 593498d commit 64915eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sisl/io/siesta/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ def _ensure_diagonal(csr):
# Create index arrays
row = (csr.ncol > 0).nonzero()[0]
row = np.repeat(row, csr.ncol[row])
# Ensure we only take those elements that are in play (i.e. this
# will work regardless of the csr being finalized or not)
col = csr.col[_a.array_arange(csr.ptr[:-1], n=csr.ncol, dtype=np.int32)]

# figure out where they are the same (diagonals)
present_diags = row[row == csr.col]
present_diags = row[row == col]

# Now figure out which elements are missing
missing_diags = np.delete(np.arange(csr.shape[0]), present_diags)
Expand Down

0 comments on commit 64915eb

Please sign in to comment.