Skip to content

Commit

Permalink
handle scipy change to ndarray
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgigante committed May 31, 2019
1 parent 438bbf3 commit 4803a0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions graphtools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def diff_aff(self):
symmetric diffusion affinity matrix defined as a
doubly-stochastic form of the kernel matrix
"""
row_degrees = self.kernel.sum(axis=1).A
row_degrees = utils.to_array(self.kernel.sum(axis=1))
if sparse.issparse(self.kernel):
# diagonal matrix
degrees = sparse.csr_matrix((1 / np.sqrt(row_degrees.flatten()),
Expand Down Expand Up @@ -638,7 +638,7 @@ def to_igraph(self, attribute="weight", **kwargs):
# not a pygsp graph
W = self.K.copy()
W = utils.set_diagonal(W, 0)
return ig.Graph.Weighted_Adjacency(utils.to_dense(W).tolist(),
return ig.Graph.Weighted_Adjacency(utils.to_array(W).tolist(),
attr=attribute, **kwargs)

def to_pickle(self, path):
Expand Down
4 changes: 3 additions & 1 deletion graphtools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def set_submatrix(X, i, j, values):
return X


def to_dense(X):
def to_array(X):
if sparse.issparse(X):
X = X.toarray()
elif isinstance(X, np.matrix):
X = X.A
return X

0 comments on commit 4803a0b

Please sign in to comment.