Skip to content

Commit d5e4fef

Browse files
authored
Prevent negative edge weights in Graclus
Change to flake8 standards and move to first weight is not None call
1 parent b312d95 commit d5e4fef

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

torch_cluster/graclus.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def graclus_cluster(
3939
row, col = row[mask], col[mask]
4040

4141
if weight is not None:
42+
if (weight < 0).any().item():
43+
raise ValueError(f"PyG's implementation of Graclus clustering "
44+
f"does not support negative edge weights.")
4245
weight = weight[mask]
4346

4447
# Randomly shuffle nodes.
@@ -51,9 +54,6 @@ def graclus_cluster(
5154
row, col = row[perm], col[perm]
5255

5356
if weight is not None:
54-
if (weight < 0).any().item():
55-
raise ValueError(f"PyG's implementation of Graclus clustering "
56-
f"does not support negative edge weights.")
5757
weight = weight[perm]
5858

5959
deg = row.new_zeros(num_nodes)

0 commit comments

Comments
 (0)