Skip to content

Commit

Permalink
Merge branch 'branch-24.10' into update-version-improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice authored Aug 15, 2024
2 parents 66f62a2 + a538745 commit cc5db20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions python/cugraph/cugraph/structure/hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def _create_hyper_edges(
for key, col in events[columns].items():
cat = categories.get(key, key)
fs = [EVENTID] + ([key] if drop_edge_attrs else edge_attrs)
fs = list(set(fs))
df = events[fs].dropna(subset=[key]) if dropna else events[fs]
if len(df) == 0:
continue
Expand All @@ -464,8 +465,7 @@ def _create_hyper_edges(
if not drop_edge_attrs:
columns += edge_attrs

edges = cudf.concat(edges)[columns]
edges.reset_index(drop=True, inplace=True)
edges = cudf.concat(edges, ignore_index=True)[list(set(columns))]
return edges


Expand Down Expand Up @@ -546,6 +546,7 @@ def _create_direct_edges(
for key2, col2 in events[sorted(edge_shape[key1])].items():
cat2 = categories.get(key2, key2)
fs = [EVENTID] + ([key1, key2] if drop_edge_attrs else edge_attrs)
fs = list(set(fs))
df = events[fs].dropna(subset=[key1, key2]) if dropna else events[fs]
if len(df) == 0:
continue
Expand Down Expand Up @@ -573,7 +574,7 @@ def _create_direct_edges(
if not drop_edge_attrs:
columns += edge_attrs

edges = cudf.concat(edges)[columns]
edges = cudf.concat(edges)[list(set(columns))]
edges.reset_index(drop=True, inplace=True)
return edges

Expand Down
11 changes: 7 additions & 4 deletions python/cugraph/cugraph/tests/structure/test_hypergraph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2023, NVIDIA CORPORATION.
# Copyright (c) 2020-2024, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Expand Down Expand Up @@ -171,7 +171,8 @@ def test_hyperedges(categorical_metadata):
if categorical_metadata:
edges = edges.astype({"edge_type": "category"})

assert_frame_equal(edges, h["edges"], check_dtype=False)
# check_like ignores the order of columns as long as all correct ones are present
assert_frame_equal(edges, h["edges"], check_dtype=False, check_like=True)
for (k, v) in [("entities", 12), ("nodes", 15), ("edges", 12), ("events", 3)]:
assert len(h[k]) == v

Expand Down Expand Up @@ -266,7 +267,8 @@ def test_drop_edge_attrs(categorical_metadata):
if categorical_metadata:
edges = edges.astype({"edge_type": "category"})

assert_frame_equal(edges, h["edges"], check_dtype=False)
# check_like ignores the order of columns as long as all correct ones are present
assert_frame_equal(edges, h["edges"], check_dtype=False, check_like=True)

for (k, v) in [("entities", 9), ("nodes", 12), ("edges", 9), ("events", 3)]:
assert len(h[k]) == v
Expand Down Expand Up @@ -308,7 +310,8 @@ def test_drop_edge_attrs_direct(categorical_metadata):
if categorical_metadata:
edges = edges.astype({"edge_type": "category"})

assert_frame_equal(edges, h["edges"], check_dtype=False)
# check_like ignores the order of columns as long as all correct ones are present
assert_frame_equal(edges, h["edges"], check_dtype=False, check_like=True)

for (k, v) in [("entities", 9), ("nodes", 9), ("edges", 6), ("events", 0)]:
assert len(h[k]) == v
Expand Down

0 comments on commit cc5db20

Please sign in to comment.