Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
try proposed fix according to StatBiomed#25 (comment)
  • Loading branch information
joan-yanqiong authored May 17, 2024
1 parent 74d548d commit 5afc00c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spatialdm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ def _Euclidean_to_RBF(X, l, singlecell=single_cell):

# At single-cell resolution, no within-spot communications
if singlecell:
np.fill_diagonal(rbf_d, 0)
# Convert csr_matrix to lil_matrix for efficient row operations
rbf_d_lil = rbf_d.tolil()

# Set diagonal elements to zero
rbf_d_lil.setdiag(0)

# Convert back to csr_matrix if needed
rbf_d = rbf_d_lil.tocsr()
else:
rbf_d.setdiag(np.exp(-X.diagonal()**2 / (2 * l ** 2)))

Expand Down

0 comments on commit 5afc00c

Please sign in to comment.