Skip to content

Commit

Permalink
handle precomputed lil, dok, dia matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed Jun 13, 2018
1 parent e9ece00 commit bd50a55
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions graphtools/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,8 @@ def build_kernel(self):
elif self.precomputed is "adjacency":
# need to set diagonal to one to make it an affinity matrix
K = self.data_nu
if not (isinstance(K, sparse.dok_matrix) or isinstance(K, sparse.lil_matrix)):
K = K.tolil()
K = set_diagonal(K, 1)
else:
log_start("affinities")
Expand All @@ -705,6 +707,8 @@ def build_kernel(self):
log_complete("affinities")
# truncate
if sparse.issparse(K):
if not (isinstance(K, sparse.csr_matrix) or isinstance(K, sparse.csc_matrix) or isinstance(K, sparse.bsr_matrix)):
K = K.tocsr()
K.data[K.data < self.thresh] = 0
K = K.tocoo()
K.eliminate_zeros()
Expand Down

0 comments on commit bd50a55

Please sign in to comment.