Skip to content

Commit

Permalink
Merge pull request #112 from klausweinbauer/master
Browse files Browse the repository at this point in the history
make RandomWalk kernel compatible with SciPy version >= 1.12.0
  • Loading branch information
ysig authored Oct 24, 2024
2 parents 2a49dc7 + 25f7926 commit 6a9cebf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions grakel/kernels/random_walk.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def lsf(x, lamda):
# A*x=b
A = LinearOperator((mn, mn), matvec=lambda x: lsf(x, self.lamda))
b = np.ones(mn)
x_sol, _ = cg(A, b, tol=1.0e-6, maxiter=20, atol='legacy')
x_sol, _ = cg(A, b, rtol=1.0e-6, maxiter=20)
return np.sum(x_sol)


Expand Down Expand Up @@ -467,7 +467,7 @@ def lsf(x, lamda):
# A*x=b
A = LinearOperator((mn, mn), matvec=lambda x: lsf(x, self.lamda))
b = np.ones(mn)
x_sol, _ = cg(A, b, tol=1.0e-6, maxiter=20, atol='legacy')
x_sol, _ = cg(A, b, rtol=1.0e-6, maxiter=20)
return np.sum(x_sol)


Expand Down
14 changes: 12 additions & 2 deletions grakel/kernels/vertex_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,25 @@ def parse_input(self, X):
self.sparse_ = bool(self.sparse)

if self.sparse_:
features = csr_matrix((data, (rows, cols)), shape=(ni, len(labels)), copy=False)
features = csr_matrix(
(data, (rows, cols)),
shape=(ni, len(labels)),
copy=False,
dtype=">f8",
)
else:
# Initialise the feature matrix
try:
features = zeros(shape=(ni, len(labels)))
features[rows, cols] = data
except MemoryError:
warn('memory-error: switching to sparse')
self.sparse_, features = True, csr_matrix((data, (rows, cols)), shape=(ni, len(labels)), copy=False)
self.sparse_, features = True, csr_matrix(
(data, (rows, cols)),
shape=(ni, len(labels)),
copy=False,
dtype=">f8",
)

if ni == 0:
raise ValueError('parsed input is empty')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
numpy>=1.14.0
cython>=0.27.3
scikit-learn>=0.19
scipy>=1.12.0
six>=1.11.0
future>=0.16.0
joblib

0 comments on commit 6a9cebf

Please sign in to comment.