Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions ripser/ripser.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,24 +299,16 @@ def ripser(
dm = sparse.coo_matrix(dm)

if sparse.issparse(dm):
if sparse.isspmatrix_coo(dm):
# If the matrix is already COO, we need to order the row and column indices
# lexicographically to avoid errors. See issue #103
row, col, data = dm.row, dm.col, dm.data
lex_sort_idx = np.lexsort((col, row))
row, col, data = row[lex_sort_idx], col[lex_sort_idx], data[lex_sort_idx]
else:
# Lexicographic ordering is performed by scipy upon conversion to COO
coo = dm.tocoo()
row, col, data = coo.row, coo.col, coo.data
coo = dm.tocoo()
res = DRFDMSparse(
row.astype(dtype=np.int32, order="C"),
col.astype(dtype=np.int32, order="C"),
np.array(data, dtype=np.float32, order="C"),
coo.row.astype(dtype=np.int32, order="C"),
coo.col.astype(dtype=np.int32, order="C"),
np.array(coo.data, dtype=np.float32, order="C"),
n_points,
maxdim,
thresh,
coeff,
do_cocycles,
)
else:
I, J = np.meshgrid(np.arange(n_points), np.arange(n_points))
Expand Down