Skip to content

Commit c7f3f5c

Browse files
committed
Fixed ruff warnings
1 parent 5539612 commit c7f3f5c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

modules/transforms/liftings/graph2hypergraph/spectral_lifting.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ def __init__(
3737
def init_clust_alg(self, cluster_alg: str):
3838
cluster_algs = {"KMeans": KMeans}
3939
if cluster_alg not in cluster_algs:
40-
warnings.warn(
41-
f"KMeans will be used since the algorithm {cluster_alg} was not recognized. Available algorithms: {list(cluster_algs.values())}"
40+
warnings.warn( # noqa: B028
41+
f"KMeans will be used since the algorithm {cluster_alg} was not recognized. Available algorithms: {list(cluster_algs.values())}",
42+
stacklevel=2,
4243
)
4344
self.cluster_alg = cluster_algs.get(cluster_alg, KMeans)
4445

@@ -81,6 +82,7 @@ def find_gap(a):
8182
s = v[:k].std()
8283
if v[k] > m + s * a:
8384
return k - 1
85+
return None
8486

8587
def find_k_largest_diff():
8688
"""Finds index largest gap usings absolute differences"""
@@ -101,13 +103,15 @@ def find_k_largest_diff():
101103

102104
if k is None or k == 1:
103105
# Fall back to using largest absolute difference in case gap heuristic did not work
104-
warnings.warn(
105-
"Unable to confidently determine the number of clusters n_c. The largest difference between consecutive eigenvalues was used to determine the number of clusters. Please provide n_c."
106+
warnings.warn( # noqa: B028
107+
"Unable to confidently determine the number of clusters n_c. The largest difference between consecutive eigenvalues was used to determine the number of clusters. Please provide n_c.",
108+
stacklevel=2,
106109
)
107110
k = find_k_largest_diff()
108111
if k == 1:
109-
warnings.warn(
110-
"Please provide the number of clusters n_c. The heuristics identified a single cluster and n_c was set to 2."
112+
warnings.warn( # noqa: B028
113+
"Please provide the number of clusters n_c. The heuristics identified a single cluster and n_c was set to 2.",
114+
stacklevel=2,
111115
)
112116
k += 1
113117
return k

test/transforms/liftings/graph2hypergraph/test_spectral_lifting.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Test the message passing module."""
22

3-
import torch
4-
53
from modules.data.utils.utils import load_manual_graph
64
from modules.transforms.liftings.graph2hypergraph.spectral_lifting import (
75
SpectralLifting,

0 commit comments

Comments
 (0)