Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
jnke2016 committed Jan 10, 2025
1 parent c9945cd commit f4d811a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
26 changes: 16 additions & 10 deletions python/cugraph/cugraph/tests/community/test_leiden.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,17 @@ def test_leiden(graph_file):
leiden_parts, leiden_mod = cugraph_leiden(G)
louvain_parts, louvain_mod = cugraph_louvain(G)

unique_parts = leiden_parts["partition"].drop_duplicates().sort_values(
ascending=True).reset_index(drop=True)

unique_parts = (
leiden_parts["partition"]
.drop_duplicates()
.sort_values(ascending=True)
.reset_index(drop=True)
)

idx_col = cudf.Series(unique_parts.index)

# Ensure Leiden cluster's ID are numbered consecutively
assert_series_equal(
unique_parts, idx_col, check_dtype=False, check_names=False)
assert_series_equal(unique_parts, idx_col, check_dtype=False, check_names=False)

# Leiden modularity score is smaller than Louvain's
assert leiden_mod >= (0.75 * louvain_mod)
Expand All @@ -212,14 +215,17 @@ def test_leiden_nx(graph_file):
leiden_parts, leiden_mod = cugraph_leiden(G)
louvain_parts, louvain_mod = cugraph_louvain(G)

unique_parts = cudf.Series(leiden_parts.values()).drop_duplicates().sort_values(
ascending=True).reset_index(drop=True)

unique_parts = (
cudf.Series(leiden_parts.values())
.drop_duplicates()
.sort_values(ascending=True)
.reset_index(drop=True)
)

idx_col = cudf.Series(unique_parts.index)

# Ensure Leiden cluster's ID are numbered consecutively
assert_series_equal(
unique_parts, idx_col, check_dtype=False, check_names=False)
assert_series_equal(unique_parts, idx_col, check_dtype=False, check_names=False)

# Calculating modularity scores for comparison
# Leiden modularity score is smaller than Louvain's
Expand Down
14 changes: 9 additions & 5 deletions python/cugraph/cugraph/tests/community/test_leiden_mg.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ def test_mg_leiden_with_edgevals_undirected_graph(dask_client, dataset):
dg = get_mg_graph(dataset, directed=False)
parts, mod = dcg.leiden(dg)

unique_parts = parts["partition"].compute().drop_duplicates().sort_values(
ascending=True).reset_index(drop=True)

unique_parts = (
parts["partition"]
.compute()
.drop_duplicates()
.sort_values(ascending=True)
.reset_index(drop=True)
)

idx_col = cudf.Series(unique_parts.index)

# Ensure Leiden cluster's ID are numbered consecutively
assert_series_equal(
unique_parts, idx_col, check_dtype=False, check_names=False)
assert_series_equal(unique_parts, idx_col, check_dtype=False, check_names=False)

# FIXME: either call Nx with the same dataset and compare results, or
# hardcode golden results to compare to.
Expand Down

0 comments on commit f4d811a

Please sign in to comment.